-
Notifications
You must be signed in to change notification settings - Fork 28
remove default data from RelationView #154
base: develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,11 @@ struct Relation: View { | |
var endDate: Date { | ||
return Date(timeIntervalSince1970: relationViewModel.currentRelation.endDate ?? 0) | ||
} | ||
|
||
var hasRelation: Bool { | ||
return relationViewModel.currentRelation.id != nil && | ||
relationViewModel.currentRelation.id != 0 | ||
Comment on lines
+20
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: Why are you checking for both nil and 0? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. currentRelation inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright..thanks for clarifying! |
||
} | ||
|
||
// use service to fetch relation and tasks | ||
func fetchRelationAndTasks() { | ||
|
@@ -69,49 +74,51 @@ struct Relation: View { | |
var body: some View { | ||
NavigationView { | ||
ZStack { | ||
Form { | ||
//Top detail view | ||
VStack(alignment: .leading, spacing: DesignConstants.Form.Spacing.minimalSpacing) { | ||
//mentor/mentee name and end date | ||
HStack { | ||
Text(relationViewModel.personName).font(.title).fontWeight(.heavy) | ||
Spacer() | ||
Text(relationViewModel.personType).font(.title) | ||
} | ||
.foregroundColor(DesignConstants.Colors.subtitleText) | ||
|
||
Text("Ends On: \(DesignConstants.DateFormat.mediumDate.string(from: endDate))") | ||
.font(.callout) | ||
|
||
//divider, adds a line below name and date | ||
Divider() | ||
.background(DesignConstants.Colors.defaultIndigoColor) | ||
} | ||
.listRowBackground(DesignConstants.Colors.formBackgroundColor) | ||
|
||
//Tasks To Do List section | ||
TasksSection(tasks: relationViewModel.toDoTasks, isToDoSection: true, navToTaskComments: true) { task in | ||
//set tapped task | ||
RelationViewModel.taskTapped = task | ||
//show alert for marking as complete confirmation | ||
self.showAlert.toggle() | ||
} | ||
.alert(isPresented: $showAlert) { | ||
Alert( | ||
title: Text(LocalizableStringConstants.markComplete), | ||
primaryButton: .cancel(), | ||
secondaryButton: .default(Text(LocalizableStringConstants.confirm)) { | ||
self.markAsComplete() | ||
}) | ||
} | ||
|
||
//Tasks Done List section | ||
TasksSection(tasks: relationViewModel.doneTasks, navToTaskComments: true) | ||
} | ||
|
||
//show activity spinner if in activity | ||
if relationViewModel.inActivity { | ||
ActivityIndicator(isAnimating: $relationViewModel.inActivity, style: .medium) | ||
} else if hasRelation { | ||
Form { | ||
//Top detail view | ||
VStack(alignment: .leading, spacing: DesignConstants.Form.Spacing.minimalSpacing) { | ||
//mentor/mentee name and end date | ||
HStack { | ||
Text(relationViewModel.personName).font(.title).fontWeight(.heavy) | ||
Spacer() | ||
Text(relationViewModel.personType).font(.title) | ||
} | ||
.foregroundColor(DesignConstants.Colors.subtitleText) | ||
|
||
Text("Ends On: \(DesignConstants.DateFormat.mediumDate.string(from: endDate))") | ||
.font(.callout) | ||
|
||
//divider, adds a line below name and date | ||
Divider() | ||
.background(DesignConstants.Colors.defaultIndigoColor) | ||
} | ||
.listRowBackground(DesignConstants.Colors.formBackgroundColor) | ||
|
||
//Tasks To Do List section | ||
TasksSection(tasks: relationViewModel.toDoTasks, isToDoSection: true, navToTaskComments: true) { task in | ||
//set tapped task | ||
RelationViewModel.taskTapped = task | ||
//show alert for marking as complete confirmation | ||
self.showAlert.toggle() | ||
} | ||
.alert(isPresented: $showAlert) { | ||
Alert( | ||
title: Text(LocalizableStringConstants.markComplete), | ||
primaryButton: .cancel(), | ||
secondaryButton: .default(Text(LocalizableStringConstants.confirm)) { | ||
self.markAsComplete() | ||
}) | ||
} | ||
|
||
//Tasks Done List section | ||
TasksSection(tasks: relationViewModel.doneTasks, navToTaskComments: true) | ||
} | ||
} else { | ||
Text(LocalizableStringConstants.noRelationText) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possibly overkill but something to consider: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a good idea. I have seen some other screens where an empty view can be re-used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a background color here in this view. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want a background color for the empty view? If yes then should I add a background color for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes sure, lets add background color to both. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the confirmation. I will update my PR in a few days. |
||
} | ||
} | ||
.environment(\.horizontalSizeClass, .regular) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could change to "No active relations"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will rename the variable.