Onboarding screens
OnboardingData object that will hold onboarding answers
This commit is contained in:
@@ -13,12 +13,18 @@
|
||||
1C26190727960DC900FDC148 /* ChartViewItemBuildable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C26190627960DC900FDC148 /* ChartViewItemBuildable.swift */; };
|
||||
1C412082278F2B8800D9153A /* FilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C412081278F2B8800D9153A /* FilterView.swift */; };
|
||||
1C412083278F2B8800D9153A /* FilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C412081278F2B8800D9153A /* FilterView.swift */; };
|
||||
1C5F4976279C84090092F1B4 /* OnboardingData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C5F4975279C84090092F1B4 /* OnboardingData.swift */; };
|
||||
1C683FCA2792281400745862 /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C683FC92792281400745862 /* Stats.swift */; };
|
||||
1C683FCB2792281400745862 /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C683FC92792281400745862 /* Stats.swift */; };
|
||||
1C683FCC2792281400745862 /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C683FC92792281400745862 /* Stats.swift */; };
|
||||
1C6B377A2799B78A001EF820 /* BGView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C6B37792799B78A001EF820 /* BGView.swift */; };
|
||||
1C744F2C278CE15600953A57 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C744F2B278CE15600953A57 /* AppDelegate.swift */; };
|
||||
1CA037702799FFA600D26164 /* ContentModeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA0376F2799FFA600D26164 /* ContentModeViewModel.swift */; };
|
||||
1CA03773279A293D00D26164 /* OnboardingTime.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA03772279A293D00D26164 /* OnboardingTime.swift */; };
|
||||
1CA03775279A294800D26164 /* OnboardingDay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA03774279A294800D26164 /* OnboardingDay.swift */; };
|
||||
1CA03777279A295600D26164 /* OnboardingTitle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA03776279A295600D26164 /* OnboardingTitle.swift */; };
|
||||
1CA0377A279A296E00D26164 /* OnboardingMain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA03779279A296E00D26164 /* OnboardingMain.swift */; };
|
||||
1CA0377C279B605000D26164 /* OnboardingWrapup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA0377B279B605000D26164 /* OnboardingWrapup.swift */; };
|
||||
1CA2662D2793908700C0E12C /* Persistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CD90AEF278C7DDF001C4FEA /* Persistence.swift */; };
|
||||
1CC469AA278F30A0003E0C6E /* BGTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC469A9278F30A0003E0C6E /* BGTask.swift */; };
|
||||
1CC469AC27907D48003E0C6E /* DayChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC469AB27907D48003E0C6E /* DayChartView.swift */; };
|
||||
@@ -109,10 +115,16 @@
|
||||
1C26190227960CE500FDC148 /* ChartDataBuildable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChartDataBuildable.swift; sourceTree = "<group>"; };
|
||||
1C26190627960DC900FDC148 /* ChartViewItemBuildable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChartViewItemBuildable.swift; sourceTree = "<group>"; };
|
||||
1C412081278F2B8800D9153A /* FilterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterView.swift; sourceTree = "<group>"; };
|
||||
1C5F4975279C84090092F1B4 /* OnboardingData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingData.swift; sourceTree = "<group>"; };
|
||||
1C683FC92792281400745862 /* Stats.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Stats.swift; sourceTree = "<group>"; };
|
||||
1C6B37792799B78A001EF820 /* BGView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGView.swift; sourceTree = "<group>"; };
|
||||
1C744F2B278CE15600953A57 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
1CA0376F2799FFA600D26164 /* ContentModeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentModeViewModel.swift; sourceTree = "<group>"; };
|
||||
1CA03772279A293D00D26164 /* OnboardingTime.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingTime.swift; sourceTree = "<group>"; };
|
||||
1CA03774279A294800D26164 /* OnboardingDay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingDay.swift; sourceTree = "<group>"; };
|
||||
1CA03776279A295600D26164 /* OnboardingTitle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingTitle.swift; sourceTree = "<group>"; };
|
||||
1CA03779279A296E00D26164 /* OnboardingMain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingMain.swift; sourceTree = "<group>"; };
|
||||
1CA0377B279B605000D26164 /* OnboardingWrapup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingWrapup.swift; sourceTree = "<group>"; };
|
||||
1CC469A9278F30A0003E0C6E /* BGTask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGTask.swift; sourceTree = "<group>"; };
|
||||
1CC469AB27907D48003E0C6E /* DayChartView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DayChartView.swift; sourceTree = "<group>"; };
|
||||
1CD90AEC278C7DDF001C4FEA /* Shared.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Shared.xcdatamodel; sourceTree = "<group>"; };
|
||||
@@ -205,6 +217,26 @@
|
||||
path = Protocol;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1CA03771279A291F00D26164 /* Onboarding */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1CA03778279A295F00D26164 /* views */,
|
||||
);
|
||||
path = Onboarding;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1CA03778279A295F00D26164 /* views */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1CA03779279A296E00D26164 /* OnboardingMain.swift */,
|
||||
1CA03772279A293D00D26164 /* OnboardingTime.swift */,
|
||||
1CA03774279A294800D26164 /* OnboardingDay.swift */,
|
||||
1CA03776279A295600D26164 /* OnboardingTitle.swift */,
|
||||
1CA0377B279B605000D26164 /* OnboardingWrapup.swift */,
|
||||
);
|
||||
path = views;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1CD90AE5278C7DDF001C4FEA = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -226,6 +258,7 @@
|
||||
1CD90AEA278C7DDF001C4FEA /* Shared */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1CA03771279A291F00D26164 /* Onboarding */,
|
||||
1C26190127960CDA00FDC148 /* Protocol */,
|
||||
1CD90AED278C7DDF001C4FEA /* FeelsApp.swift */,
|
||||
1C744F2B278CE15600953A57 /* AppDelegate.swift */,
|
||||
@@ -323,6 +356,7 @@
|
||||
1CD90B61278C7EBA001C4FEA /* Mood.swift */,
|
||||
1CD90B62278C7EBA001C4FEA /* MoodEntryExtension.swift */,
|
||||
1C2618FD27960A4F00FDC148 /* FilterViewModel.swift */,
|
||||
1C5F4975279C84090092F1B4 /* OnboardingData.swift */,
|
||||
);
|
||||
path = Models;
|
||||
sourceTree = "<group>";
|
||||
@@ -523,12 +557,16 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
1CA037702799FFA600D26164 /* ContentModeViewModel.swift in Sources */,
|
||||
1CA03773279A293D00D26164 /* OnboardingTime.swift in Sources */,
|
||||
1CD90B39278C7E38001C4FEA /* GraphView.swift in Sources */,
|
||||
1CA0377C279B605000D26164 /* OnboardingWrapup.swift in Sources */,
|
||||
1CA03775279A294800D26164 /* OnboardingDay.swift in Sources */,
|
||||
1C683FCA2792281400745862 /* Stats.swift in Sources */,
|
||||
1CD90B76278C8119001C4FEA /* LocalNotification.swift in Sources */,
|
||||
1CD90B16278C7DE0001C4FEA /* Feels.xcdatamodeld in Sources */,
|
||||
1CC469AA278F30A0003E0C6E /* BGTask.swift in Sources */,
|
||||
1C6B377A2799B78A001EF820 /* BGView.swift in Sources */,
|
||||
1C5F4976279C84090092F1B4 /* OnboardingData.swift in Sources */,
|
||||
1C26190727960DC900FDC148 /* ChartViewItemBuildable.swift in Sources */,
|
||||
1CD90B5D278C7EAD001C4FEA /* Random.swift in Sources */,
|
||||
1C2618FE27960A4F00FDC148 /* FilterViewModel.swift in Sources */,
|
||||
@@ -543,8 +581,10 @@
|
||||
1C26190327960CE500FDC148 /* ChartDataBuildable.swift in Sources */,
|
||||
1CD90B66278C7EBA001C4FEA /* MoodEntryExtension.swift in Sources */,
|
||||
1CD90B1C278C7DE0001C4FEA /* Persistence.swift in Sources */,
|
||||
1CA0377A279A296E00D26164 /* OnboardingMain.swift in Sources */,
|
||||
1C412082278F2B8800D9153A /* FilterView.swift in Sources */,
|
||||
1CD90B18278C7DE0001C4FEA /* FeelsApp.swift in Sources */,
|
||||
1CA03777279A295600D26164 /* OnboardingTitle.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
62
Shared/Models/OnboardingData.swift
Normal file
62
Shared/Models/OnboardingData.swift
Normal file
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// OnboardingData.swift
|
||||
// Feels (iOS)
|
||||
//
|
||||
// Created by Trey Tartt on 1/22/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
// this is getting passed around and filled out
|
||||
// class and vars
|
||||
final class OnboardingData: NSObject, ObservableObject, Codable {
|
||||
@Published var date: Date = Date()
|
||||
@Published var inputDay: DayOptions = .Today
|
||||
@Published var title: String = OnboardingTitle.titleOptions[0]
|
||||
|
||||
enum CodingKeys: CodingKey {
|
||||
case date, inputDay, title
|
||||
}
|
||||
|
||||
func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
|
||||
try container.encode(date, forKey: .date)
|
||||
try container.encode(inputDay, forKey: .inputDay)
|
||||
try container.encode(title, forKey: .title)
|
||||
}
|
||||
|
||||
required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
|
||||
date = try container.decode(Date.self, forKey: .date)
|
||||
inputDay = try container.decode(DayOptions.self, forKey: .inputDay)
|
||||
title = try container.decode(String.self, forKey: .title)
|
||||
}
|
||||
|
||||
override init() { }
|
||||
}
|
||||
|
||||
extension OnboardingData: RawRepresentable {
|
||||
convenience init?(rawValue: String) {
|
||||
guard let data = rawValue.data(using: .utf8),
|
||||
let result = try? JSONDecoder().decode(OnboardingData.self, from: data)
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
self.init()
|
||||
|
||||
self.date = result.date
|
||||
self.inputDay = result.inputDay
|
||||
self.title = result.title
|
||||
}
|
||||
|
||||
public var rawValue: String {
|
||||
guard let data = try? JSONEncoder().encode(self),
|
||||
let result = String(data: data, encoding: .utf8)
|
||||
else {
|
||||
return "[]"
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
86
Shared/Onboarding/views/OnboardingDay.swift
Normal file
86
Shared/Onboarding/views/OnboardingDay.swift
Normal file
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// OnboardingDay.swift
|
||||
// Feels (iOS)
|
||||
//
|
||||
// Created by Trey Tartt on 1/20/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
enum DayOptions: String, CaseIterable, RawRepresentable, Codable {
|
||||
case Today = "Same Day"
|
||||
case Previous = "Previous Day"
|
||||
}
|
||||
|
||||
struct OnboardingDay: View {
|
||||
@ObservedObject var onboardingData: OnboardingData
|
||||
|
||||
var previewText: String {
|
||||
switch onboardingData.inputDay {
|
||||
case .Today:
|
||||
return "Example: If you pick on a Tuesday, the value will be recorded for Tuesday"
|
||||
case .Previous:
|
||||
return "Example: If you pick on a Tuesday, the value will be recorded for Monday, the day before"
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
|
||||
Image("average", bundle: .main)
|
||||
.foregroundColor(Color(UIColor.darkText))
|
||||
.opacity(0.04)
|
||||
.scaleEffect(1.2)
|
||||
.padding(.bottom, 55)
|
||||
|
||||
ScrollView {
|
||||
VStack{
|
||||
Text("Will this rating be for current day or previous day")
|
||||
.font(.title)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
.padding([.trailing, .leading], 55)
|
||||
.padding([.top], 25)
|
||||
|
||||
Picker(selection: $onboardingData.inputDay,
|
||||
label: Text("")) {
|
||||
ForEach(DayOptions.allCases, id: \.self) { day in
|
||||
Text(day.rawValue)
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.colorScheme(.dark)
|
||||
.padding([.trailing, .leading], 55)
|
||||
.pickerStyle(SegmentedPickerStyle())
|
||||
|
||||
Text("When you vote your vote will be for the \(onboardingData.inputDay.rawValue)")
|
||||
.font(.body)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
.padding([.trailing, .leading], 75)
|
||||
.padding([.top], 15)
|
||||
|
||||
Text(previewText)
|
||||
.font(.body)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
.padding([.trailing, .leading], 75)
|
||||
.padding([.top], 15)
|
||||
|
||||
Spacer()
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
.background(.blue)
|
||||
}
|
||||
}
|
||||
|
||||
struct OnboardingDay_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Group{
|
||||
OnboardingDay(onboardingData: OnboardingData())
|
||||
|
||||
OnboardingDay(onboardingData: OnboardingData())
|
||||
.preferredColorScheme(.dark)
|
||||
}
|
||||
}
|
||||
}
|
||||
49
Shared/Onboarding/views/OnboardingMain.swift
Normal file
49
Shared/Onboarding/views/OnboardingMain.swift
Normal file
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// OnboardingMain.swift
|
||||
// Feels (iOS)
|
||||
//
|
||||
// Created by Trey Tartt on 1/20/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct OnboardingMain: View {
|
||||
@Environment(\.presentationMode) var presentationMode
|
||||
@State var onboardingData: OnboardingData
|
||||
|
||||
let completionClosure: ((OnboardingData) -> Void)
|
||||
|
||||
var body: some View {
|
||||
TabView {
|
||||
OnboardingTime(onboardingData: onboardingData)
|
||||
|
||||
OnboardingDay(onboardingData: onboardingData)
|
||||
|
||||
OnboardingTitle(onboardingData: onboardingData)
|
||||
|
||||
OnboardingWrapup(onboardingData: onboardingData, completionClosure: { _ in
|
||||
completionClosure(onboardingData)
|
||||
})
|
||||
}
|
||||
.ignoresSafeArea()
|
||||
.tabViewStyle(.page)
|
||||
.onAppear {
|
||||
setupAppearance()
|
||||
}
|
||||
.interactiveDismissDisabled()
|
||||
}
|
||||
|
||||
func setupAppearance() {
|
||||
UIPageControl.appearance().currentPageIndicatorTintColor = .white
|
||||
UIPageControl.appearance().pageIndicatorTintColor = UIColor.black.withAlphaComponent(0.2)
|
||||
}
|
||||
}
|
||||
|
||||
struct OnboardingMain_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
OnboardingMain(onboardingData: OnboardingData(),
|
||||
completionClosure: { _ in
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
67
Shared/Onboarding/views/OnboardingTime.swift
Normal file
67
Shared/Onboarding/views/OnboardingTime.swift
Normal file
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// OnboardingTime.swift
|
||||
// Feels (iOS)
|
||||
//
|
||||
// Created by Trey Tartt on 1/20/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct OnboardingTime: View {
|
||||
@ObservedObject var onboardingData: OnboardingData
|
||||
|
||||
var formatter: DateFormatter {
|
||||
let dateFormatter = DateFormatter()
|
||||
dateFormatter.timeStyle = .short
|
||||
return dateFormatter
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
|
||||
Image("great", bundle: .main)
|
||||
.foregroundColor(Color(UIColor.darkText))
|
||||
.opacity(0.04)
|
||||
.scaleEffect(1.2)
|
||||
|
||||
ScrollView {
|
||||
VStack {
|
||||
Text("What time do you want to unlock your rating")
|
||||
.font(.title)
|
||||
.padding([.trailing, .leading], 55)
|
||||
.padding([.top], 25)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
|
||||
DatePicker("", selection: $onboardingData.date,
|
||||
displayedComponents: .hourAndMinute)
|
||||
.scaleEffect(2)
|
||||
.labelsHidden()
|
||||
.frame(minWidth: 0, maxWidth: .infinity)
|
||||
.padding()
|
||||
.padding([.top, .bottom], 25)
|
||||
.colorScheme(.dark)
|
||||
|
||||
Text("Your shit will be unlocked at \(formatter.string(from: onboardingData.date)) daily")
|
||||
.font(.body)
|
||||
.padding([.top], 15)
|
||||
.padding([.trailing, .leading], 55)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
.background(.green)
|
||||
}
|
||||
}
|
||||
|
||||
struct OnboardingTime_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Group {
|
||||
OnboardingTime(onboardingData: OnboardingData())
|
||||
|
||||
OnboardingTime(onboardingData: OnboardingData())
|
||||
.preferredColorScheme(.dark)
|
||||
}
|
||||
}
|
||||
}
|
||||
84
Shared/Onboarding/views/OnboardingTitle.swift
Normal file
84
Shared/Onboarding/views/OnboardingTitle.swift
Normal file
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// OnboardingTitle.swift
|
||||
// Feels (iOS)
|
||||
//
|
||||
// Created by Trey Tartt on 1/20/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct OnboardingTitle: View {
|
||||
static let titleOptions = [
|
||||
"Its time to select.",
|
||||
"Pick your shit!",
|
||||
"How was your day?"]
|
||||
|
||||
@ObservedObject var onboardingData: OnboardingData
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
|
||||
Image("average", bundle: .main)
|
||||
.foregroundColor(Color(UIColor.darkText))
|
||||
.opacity(0.04)
|
||||
.scaleEffect(1.2)
|
||||
.padding(.bottom, 55)
|
||||
|
||||
ScrollView {
|
||||
VStack{
|
||||
Text("What would you like the reminder to say?")
|
||||
.font(.title)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
.padding([.trailing, .leading], 55)
|
||||
.padding([.top], 25)
|
||||
|
||||
ForEach(OnboardingTitle.titleOptions, id: \.self) { option in
|
||||
Button(action: {
|
||||
onboardingData.title = option
|
||||
}, label: {
|
||||
Text(option)
|
||||
.font(.system(size: 15))
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(.white)
|
||||
.padding(10)
|
||||
.background(RoundedRectangle(cornerRadius: 10).stroke().foregroundColor(Color.white))
|
||||
.cornerRadius(10)
|
||||
})
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
.padding([.top], 10)
|
||||
}
|
||||
|
||||
Text("-- or type your own--")
|
||||
.font(.body)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
.padding([.top], 25)
|
||||
.padding([.trailing, .leading], 55)
|
||||
|
||||
TextField("Notification", text: $onboardingData.title)
|
||||
.frame(height: 44)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
.textFieldStyle(PlainTextFieldStyle())
|
||||
.padding([.leading, .trailing], 4)
|
||||
.cornerRadius(16)
|
||||
.overlay(RoundedRectangle(cornerRadius: 16).stroke(Color.white))
|
||||
.padding([.leading, .trailing], 75)
|
||||
.padding([.top], 45)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
.background(.orange)
|
||||
}
|
||||
}
|
||||
|
||||
struct OnboardingTitle_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Group {
|
||||
OnboardingTitle(onboardingData: OnboardingData())
|
||||
|
||||
OnboardingTitle(onboardingData: OnboardingData())
|
||||
.preferredColorScheme(.dark)
|
||||
}
|
||||
}
|
||||
}
|
||||
107
Shared/Onboarding/views/OnboardingWrapup.swift
Normal file
107
Shared/Onboarding/views/OnboardingWrapup.swift
Normal file
@@ -0,0 +1,107 @@
|
||||
//
|
||||
// OnboardingWrapup.swift
|
||||
// Feels (iOS)
|
||||
//
|
||||
// Created by Trey Tartt on 1/21/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct OnboardingWrapup: View {
|
||||
@ObservedObject var onboardingData: OnboardingData
|
||||
|
||||
let completionClosure: ((OnboardingData) -> Void)
|
||||
|
||||
var formatter: DateFormatter {
|
||||
let dateFormatter = DateFormatter()
|
||||
dateFormatter.timeStyle = .short
|
||||
return dateFormatter
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
|
||||
Image("good", bundle: .main)
|
||||
.foregroundColor(Color(UIColor.darkText))
|
||||
.opacity(0.04)
|
||||
.scaleEffect(1.2)
|
||||
.padding(.bottom, 55)
|
||||
|
||||
ScrollView {
|
||||
VStack {
|
||||
Spacer()
|
||||
|
||||
Text("At")
|
||||
.font(.title)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
.padding([.trailing, .leading], 55)
|
||||
.padding([.top], 15)
|
||||
|
||||
Text(formatter.string(from: onboardingData.date))
|
||||
.font(.title)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
.padding([.trailing, .leading], 55)
|
||||
.padding([.top], 15)
|
||||
|
||||
Text("aou will get notified that")
|
||||
.font(.title)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
.padding([.trailing, .leading], 55)
|
||||
.padding([.top], 15)
|
||||
|
||||
Text(onboardingData.title)
|
||||
.font(.title)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
.padding([.trailing, .leading], 55)
|
||||
.padding([.top], 15)
|
||||
|
||||
Text("and when you vote it will be counted for the")
|
||||
.font(.title)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
.padding([.trailing, .leading], 55)
|
||||
.padding([.top], 15)
|
||||
|
||||
Text(onboardingData.inputDay.rawValue)
|
||||
.font(.title)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
.padding([.trailing, .leading], 55)
|
||||
.padding([.top], 15)
|
||||
|
||||
Button(action: {
|
||||
completionClosure(onboardingData)
|
||||
}, label: {
|
||||
Text("Complete")
|
||||
.font(.title)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(.yellow)
|
||||
.padding(10)
|
||||
.padding([.leading, .trailing], 25)
|
||||
.background(RoundedRectangle(cornerRadius: 10).fill().foregroundColor(Color.white))
|
||||
.cornerRadius(10)
|
||||
})
|
||||
.padding([.top], 65)
|
||||
}
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
}
|
||||
.background(.yellow)
|
||||
}
|
||||
}
|
||||
|
||||
struct OnboardingWrapup_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Group {
|
||||
OnboardingWrapup(onboardingData: OnboardingData(), completionClosure: { _ in
|
||||
|
||||
})
|
||||
|
||||
OnboardingWrapup(onboardingData: OnboardingData(), completionClosure: { _ in
|
||||
|
||||
})
|
||||
.preferredColorScheme(.dark)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,15 @@ import Charts
|
||||
|
||||
struct ContentView: View {
|
||||
@Environment(\.managedObjectContext) private var viewContext
|
||||
|
||||
@State private var needsOnboarding: Bool = true
|
||||
|
||||
@State private var showingSheet = false
|
||||
@State private var showTodayInput = true
|
||||
|
||||
@ObservedObject var viewModel = ContentModeViewModel()
|
||||
|
||||
@AppStorage("savedOnboardingData") private var savedOnboardingData = OnboardingData()
|
||||
|
||||
init(){
|
||||
UITabBar.appearance().backgroundColor = UIColor.systemBackground
|
||||
}
|
||||
@@ -37,7 +40,15 @@ struct ContentView: View {
|
||||
.tabItem {
|
||||
Label("Stats", systemImage: "chart.line.uptrend.xyaxis")
|
||||
}
|
||||
}
|
||||
}.sheet(isPresented: $needsOnboarding, onDismiss: {
|
||||
|
||||
}, content: {
|
||||
OnboardingMain(onboardingData: savedOnboardingData,
|
||||
completionClosure: { onboardingData in
|
||||
needsOnboarding = false
|
||||
savedOnboardingData = onboardingData
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
private var settingsButtonView: some View {
|
||||
|
||||
@@ -11,15 +11,9 @@ struct SettingsView: View {
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
let editedDataClosure: (() -> Void)
|
||||
@State private var showOnboarding = false
|
||||
|
||||
@AppStorage("notificationDate") private var notificationDate = Date() {
|
||||
didSet {
|
||||
if self.showReminder {
|
||||
LocalNotification.scheduleReminder(atTime: self.notificationDate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@AppStorage("savedOnboardingData") private var savedOnboardingData = OnboardingData()
|
||||
@AppStorage("showReminder") private var showReminder: Bool = false
|
||||
|
||||
var body: some View {
|
||||
@@ -29,15 +23,21 @@ struct SettingsView: View {
|
||||
VStack {
|
||||
closeButtonView
|
||||
.padding()
|
||||
notificationCell
|
||||
randomShitCell
|
||||
addTestDataCell
|
||||
clearDB
|
||||
whyBackgroundMode
|
||||
changeIcon
|
||||
showOnboardingButton
|
||||
Spacer()
|
||||
}
|
||||
.padding()
|
||||
}.sheet(isPresented: $showOnboarding) {
|
||||
OnboardingMain(onboardingData: savedOnboardingData,
|
||||
completionClosure: { onboardingData in
|
||||
showOnboarding = false
|
||||
savedOnboardingData = onboardingData
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,27 +54,6 @@ struct SettingsView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var notificationCell: some View {
|
||||
ZStack {
|
||||
Color(UIColor.systemBackground)
|
||||
VStack {
|
||||
Toggle("Would you like to be reminded?", isOn: $showReminder)
|
||||
.onChange(of: showReminder, perform: { value in
|
||||
self.maybeNotificaiotns(areEnabled: value)
|
||||
})
|
||||
.padding()
|
||||
DatePicker("", selection: $notificationDate, displayedComponents: .hourAndMinute)
|
||||
.onChange(of: notificationDate, perform: { value in
|
||||
self.updateNotificationTimes(toDate: value)
|
||||
})
|
||||
.disabled(showReminder == false)
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
|
||||
}
|
||||
|
||||
private var randomShitCell: some View {
|
||||
ZStack {
|
||||
Color(UIColor.systemBackground)
|
||||
@@ -179,21 +158,18 @@ struct SettingsView: View {
|
||||
LocalNotification.scheduleReminder(atTime: date)
|
||||
}
|
||||
|
||||
private func maybeNotificaiotns(areEnabled: Bool) {
|
||||
if areEnabled {
|
||||
LocalNotification.testIfEnabled(completion: { result in
|
||||
switch result{
|
||||
case .success(_):
|
||||
LocalNotification.scheduleReminder(atTime: self.notificationDate)
|
||||
case .failure(let error):
|
||||
print(error)
|
||||
// show error
|
||||
break
|
||||
}
|
||||
private var showOnboardingButton: some View {
|
||||
ZStack {
|
||||
Color(UIColor.systemBackground)
|
||||
Button(action: {
|
||||
showOnboarding.toggle()
|
||||
}, label: {
|
||||
Text("Show Onboarding")
|
||||
})
|
||||
} else {
|
||||
LocalNotification.removeNotificaiton()
|
||||
.padding()
|
||||
}
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user