Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1110;
LastUpgradeCheck = 1110;
LastUpgradeCheck = 1200;
ORGANIZATIONNAME = Exyte;
TargetAttributes = {
6652980B235F0A69004D1557 = {
Expand Down Expand Up @@ -256,6 +256,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -316,6 +317,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down
204 changes: 181 additions & 23 deletions Activity App/ActivityAppReplicating/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,146 @@ import SwiftUI

struct ContentView: View {

enum WeekDays: Int {
case Monday, Tuesday, Wednsday, Thursday, Friday, Satuday, Sunday
}

@State private var weekDay: Int = WeekDays.Monday.rawValue

var body: some View {
GeometryReader { geometry in
ZStack(alignment: .top) {
Color.black.edgesIgnoringSafeArea(.all)
ScrollView {
VStack {
Spacer(minLength: Constants.navigationBarHeight).frame(width: geometry.size.width, height: Constants.navigationBarHeight, alignment: .top)
self.createRings()

// showing the rings of main ring chart in dependance of selected weekday
switch weekDay {
case 0:
createRings(
standPercentage: ActivityData.weekdays[0].standPercentage, standBackgroundColor: .standRingWeekdayBackground,
standStartColor: .standRingStartColor,
standEndColor: .standRingEndColor,

exePercentage: ActivityData.weekdays[0].exercisePercentage,
exeBackgroundColor: .exerciseRingWeekdayBackground,
exeStartColor: .exerciseRingStartColor,
exeEndColor: .exerciseRingEndColor,

movePercentage: ActivityData.weekdays[0].movePercentage,
moveBackgroundColor: .moveRingWeekdayBackground,
moveStartColor: .moveRingStartColor,
moveEndColor: .moveRingEndColor,
thickness: Constants.mainRingThickness
)
case 1:
createRings(
standPercentage: ActivityData.weekdays[1].standPercentage, standBackgroundColor: .standRingWeekdayBackground,
standStartColor: .standRingStartColor,
standEndColor: .standRingEndColor,

exePercentage: ActivityData.weekdays[1].exercisePercentage,
exeBackgroundColor: .exerciseRingWeekdayBackground,
exeStartColor: .exerciseRingStartColor,
exeEndColor: .exerciseRingEndColor,

movePercentage: ActivityData.weekdays[1].movePercentage,
moveBackgroundColor: .moveRingWeekdayBackground,
moveStartColor: .moveRingStartColor,
moveEndColor: .moveRingEndColor,
thickness: Constants.mainRingThickness
)
case 2:
createRings(
standPercentage: ActivityData.weekdays[2].standPercentage, standBackgroundColor: .standRingWeekdayBackground,
standStartColor: .standRingStartColor,
standEndColor: .standRingEndColor,

exePercentage: ActivityData.weekdays[2].exercisePercentage,
exeBackgroundColor: .exerciseRingWeekdayBackground,
exeStartColor: .exerciseRingStartColor,
exeEndColor: .exerciseRingEndColor,

movePercentage: ActivityData.weekdays[2].movePercentage,
moveBackgroundColor: .moveRingWeekdayBackground,
moveStartColor: .moveRingStartColor,
moveEndColor: .moveRingEndColor,
thickness: Constants.mainRingThickness
)
case 3:
createRings(
standPercentage: ActivityData.weekdays[3].standPercentage, standBackgroundColor: .standRingWeekdayBackground,
standStartColor: .standRingStartColor,
standEndColor: .standRingEndColor,

exePercentage: ActivityData.weekdays[3].exercisePercentage,
exeBackgroundColor: .exerciseRingWeekdayBackground,
exeStartColor: .exerciseRingStartColor,
exeEndColor: .exerciseRingEndColor,

movePercentage: ActivityData.weekdays[3].movePercentage,
moveBackgroundColor: .moveRingWeekdayBackground,
moveStartColor: .moveRingStartColor,
moveEndColor: .moveRingEndColor,
thickness: Constants.mainRingThickness
)
case 4:
createRings(
standPercentage: ActivityData.weekdays[4].standPercentage, standBackgroundColor: .standRingWeekdayBackground,
standStartColor: .standRingStartColor,
standEndColor: .standRingEndColor,

exePercentage: ActivityData.weekdays[4].exercisePercentage,
exeBackgroundColor: .exerciseRingWeekdayBackground,
exeStartColor: .exerciseRingStartColor,
exeEndColor: .exerciseRingEndColor,

movePercentage: ActivityData.weekdays[4].movePercentage,
moveBackgroundColor: .moveRingWeekdayBackground,
moveStartColor: .moveRingStartColor,
moveEndColor: .moveRingEndColor,
thickness: Constants.mainRingThickness
)
case 5:
createRings(
standPercentage: ActivityData.weekdays[5].standPercentage, standBackgroundColor: .standRingWeekdayBackground,
standStartColor: .standRingStartColor,
standEndColor: .standRingEndColor,

exePercentage: ActivityData.weekdays[5].exercisePercentage,
exeBackgroundColor: .exerciseRingWeekdayBackground,
exeStartColor: .exerciseRingStartColor,
exeEndColor: .exerciseRingEndColor,

movePercentage: ActivityData.weekdays[5].movePercentage,
moveBackgroundColor: .moveRingWeekdayBackground,
moveStartColor: .moveRingStartColor,
moveEndColor: .moveRingEndColor,
thickness: Constants.mainRingThickness
)
case 6:
createRings(
standPercentage: ActivityData.weekdays[6].standPercentage, standBackgroundColor: .standRingWeekdayBackground,
standStartColor: .standRingStartColor,
standEndColor: .standRingEndColor,

exePercentage: ActivityData.weekdays[6].exercisePercentage,
exeBackgroundColor: .exerciseRingWeekdayBackground,
exeStartColor: .exerciseRingStartColor,
exeEndColor: .exerciseRingEndColor,

movePercentage: ActivityData.weekdays[6].movePercentage,
moveBackgroundColor: .moveRingWeekdayBackground,
moveStartColor: .moveRingStartColor,
moveEndColor: .moveRingEndColor,
thickness: Constants.mainRingThickness
)
default:
createRings()
}


self.createCharts()
self.createFooter()
}
Expand All @@ -27,35 +159,55 @@ struct ContentView: View {
}
}

func createRings() -> some View {
// function of rings creation with default parameters
func createRings(
standPercentage: Double = ActivityData.ringsPercentage.standPercentage,
standBackgroundColor: Color = .standRingBackground,
standStartColor: Color = .standRingStartColor,
standEndColor: Color = .standRingEndColor,

exePercentage: Double = ActivityData.ringsPercentage.exercisePercentage,
exeBackgroundColor: Color = .exerciseRingBackground,
exeStartColor: Color = .exerciseRingStartColor,
exeEndColor: Color = .exerciseRingEndColor,

movePercentage: Double = ActivityData.ringsPercentage.movePercentage,
moveBackgroundColor: Color = .moveRingBackground,
moveStartColor: Color = .moveRingStartColor,
moveEndColor: Color = .moveRingEndColor,

thickness: CGFloat = Constants.mainRingThickness
) -> some View {
ZStack {
RingView(
percentage: ActivityData.ringsPercentage.standPercentage,
backgroundColor: Color.standRingBackground,
startColor: Color.standRingStartColor,
endColor: Color.standRingEndColor,
thickness: Constants.mainRingThickness
percentage: standPercentage,
backgroundColor: standBackgroundColor,
startColor: standStartColor,
endColor: standEndColor,
thickness: thickness
)
.frame(width: 150, height: 150)
.aspectRatio(contentMode: .fit)
.frame(width: 150, height: 150)
.aspectRatio(contentMode: .fit)

RingView(
percentage: ActivityData.ringsPercentage.exercisePercentage,
backgroundColor: Color.exerciseRingBackground,
startColor: Color.exerciseRingStartColor,
endColor: Color.exerciseRingEndColor,
thickness: Constants.mainRingThickness
percentage: exePercentage,
backgroundColor: exeBackgroundColor,
startColor: exeStartColor,
endColor: exeEndColor,
thickness: thickness
)
.frame(width: 215, height: 215)
.aspectRatio(contentMode: .fit)
.frame(width: 215, height: 215)
.aspectRatio(contentMode: .fit)

RingView(
percentage: ActivityData.ringsPercentage.movePercentage,
backgroundColor: Color.moveRingBackground,
startColor: Color.moveRingStartColor,
endColor: Color.moveRingEndColor,
thickness: Constants.mainRingThickness
percentage: movePercentage,
backgroundColor: moveBackgroundColor,
startColor: moveStartColor,
endColor: moveEndColor,
thickness: thickness
)
.frame(width: 280, height: 280)
.aspectRatio(contentMode: .fit)
.frame(width: 280, height: 280)
.aspectRatio(contentMode: .fit)
}
}

Expand Down Expand Up @@ -192,6 +344,12 @@ struct ContentView: View {
.frame(width: 40, height: 40)
.aspectRatio(contentMode: .fit)
}
// binding of weekDay property to selection of particulary day in navigation bar
.onTapGesture {
weekDay = item
}
// making ring diagram of weekday blured once selected
.blur(radius: weekDay == item ? 2 : 0)
}
}
}
Expand Down