-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve animation issues with Date picker #75
Open
disc0infern0
wants to merge
6
commits into
peterfriese:develop
Choose a base branch
from
disc0infern0:andrew
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7443a6f
Convert viewModel instantiation from ObservedObject to StateObject in…
disc0infern0 2c59e13
Refactored Toggle and Date Time pickers from ReminderDetailsView into…
disc0infern0 f689317
ReminderDetailsViewModel: Bug fix for setPickerState. Added withOpti…
disc0infern0 c4d9ede
Refactored date/time pickers to new view and updated control of state…
disc0infern0 cfa4c7b
Updated code in ReminderDetailsViewModel.swift to satisfy Egyptian ty…
disc0infern0 8a59be3
ReminderListViewModel.
disc0infern0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
code/frontend/MakeItSo/Shared/Features/ReminderList/Views/ReminderDateTimeView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// | ||
// ReminderDateTimeView.swift | ||
disc0infern0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// MakeItSo | ||
// | ||
// Created by Andrew Cowley on 08/12/2021. | ||
// Copyright © 2021 Google LLC. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
import SwiftUI | ||
|
||
// Make the date time toggle section in the ReminderDetailsView | ||
struct ReminderDateTimeView: View { | ||
@EnvironmentObject var viewModel: ReminderDetailsViewModel | ||
|
||
var body: some View { | ||
Toggle(isOn: $viewModel.hasDueDate) { | ||
dateToggleLabel | ||
} | ||
.animation(.none, value: viewModel.pickerState ) | ||
|
||
if viewModel.pickerState == .date { | ||
DatePicker("Date", selection: $viewModel.dueDate, displayedComponents: .date) | ||
.datePickerStyle(.graphical) | ||
} | ||
|
||
Toggle(isOn: $viewModel.hasDueTime) { | ||
timeToggleLabel | ||
} | ||
if viewModel.pickerState == .time { | ||
DatePicker("Time", selection: $viewModel.dueDate, displayedComponents: .hourAndMinute) | ||
.datePickerStyle(.wheel) | ||
} | ||
} | ||
|
||
// Toggle label subviews for body | ||
var dateToggleLabel: some View { | ||
disc0infern0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
HStack { | ||
Image(systemName: "calendar") | ||
.frame(width: 26, height: 26) | ||
.background(.red) | ||
.foregroundColor(.white) | ||
.cornerRadius(4) | ||
VStack(alignment: .leading) { | ||
Text("Date") | ||
if let dueDate = viewModel.dueDate { | ||
Button( action: viewModel.datePressed) { | ||
Text(dueDate.formattedRelativeToday()) | ||
.font(.caption2) | ||
.foregroundColor(Color.accentColor) // Accent Color, which currently defaults to blue | ||
} | ||
} | ||
} | ||
} | ||
} | ||
var timeToggleLabel: some View { | ||
HStack { | ||
Image(systemName: "clock") | ||
.frame(width: 26, height: 26) //, alignment: .center) | ||
.background(.blue) | ||
.foregroundColor(.white) | ||
.cornerRadius(4) | ||
VStack(alignment: .leading) { | ||
Text("Time") | ||
if viewModel.hasDueTime { | ||
Button(action: viewModel.timePressed) { | ||
Text(viewModel.dueDate, style: .time) | ||
.font(.caption2) | ||
.foregroundColor(Color.accentColor) // Accent Color, which will default to blue | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct DateTimeSection_Previews: PreviewProvider { | ||
static var previews: some View { | ||
NavigationView { | ||
Form { | ||
Section { | ||
Text("Header") | ||
} | ||
Section { | ||
ReminderDateTimeView() | ||
.environmentObject(ReminderDetailsViewModel(reminder: Reminder.samples[0])) | ||
} | ||
Section { | ||
Text("Footer") | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Duplicate entries, might be a result of manually merging this file.
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.
agreed.
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.
On closer inspection, the two lines are not duplicates: line 10 starts: 49281E99 vs line 11 starting: 49281E9A
The last character is different. Just to be sure, I ran 'uniq -d project.pbxproj' from the command line, and there was no output - indicating no duplicates.
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.
agreed