mirror of
https://github.com/Matte23/circolapp.git
synced 2025-12-05 23:19:10 +00:00
Add onboarding screen iOS
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
954E68352574E3890034EBA8 /* iOSServerApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954E68342574E3890034EBA8 /* iOSServerApi.swift */; };
|
954E68352574E3890034EBA8 /* iOSServerApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954E68342574E3890034EBA8 /* iOSServerApi.swift */; };
|
||||||
954E683D2574ED9E0034EBA8 /* UserDefaultsExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954E683C2574ED9E0034EBA8 /* UserDefaultsExtensions.swift */; };
|
954E683D2574ED9E0034EBA8 /* UserDefaultsExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954E683C2574ED9E0034EBA8 /* UserDefaultsExtensions.swift */; };
|
||||||
9553DB09257173ED006AE167 /* iOSRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9553DB08257173ED006AE167 /* iOSRepository.swift */; };
|
9553DB09257173ED006AE167 /* iOSRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9553DB08257173ED006AE167 /* iOSRepository.swift */; };
|
||||||
|
9554BDB8257E498F00D8925B /* OnboardingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9554BDB7257E498F00D8925B /* OnboardingView.swift */; };
|
||||||
955B7A0E257D098C0091B1F9 /* SearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 955B7A0D257D098C0091B1F9 /* SearchBar.swift */; };
|
955B7A0E257D098C0091B1F9 /* SearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 955B7A0D257D098C0091B1F9 /* SearchBar.swift */; };
|
||||||
955B7A10257D10A70091B1F9 /* ViewControllerResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 955B7A0F257D10A70091B1F9 /* ViewControllerResolver.swift */; };
|
955B7A10257D10A70091B1F9 /* ViewControllerResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 955B7A0F257D10A70091B1F9 /* ViewControllerResolver.swift */; };
|
||||||
95906F48257508660060F5D0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 95906F47257506360060F5D0 /* Assets.xcassets */; };
|
95906F48257508660060F5D0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 95906F47257506360060F5D0 /* Assets.xcassets */; };
|
||||||
@@ -51,6 +52,7 @@
|
|||||||
954E68342574E3890034EBA8 /* iOSServerApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSServerApi.swift; sourceTree = "<group>"; };
|
954E68342574E3890034EBA8 /* iOSServerApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSServerApi.swift; sourceTree = "<group>"; };
|
||||||
954E683C2574ED9E0034EBA8 /* UserDefaultsExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsExtensions.swift; sourceTree = "<group>"; };
|
954E683C2574ED9E0034EBA8 /* UserDefaultsExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsExtensions.swift; sourceTree = "<group>"; };
|
||||||
9553DB08257173ED006AE167 /* iOSRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSRepository.swift; sourceTree = "<group>"; };
|
9553DB08257173ED006AE167 /* iOSRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSRepository.swift; sourceTree = "<group>"; };
|
||||||
|
9554BDB7257E498F00D8925B /* OnboardingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingView.swift; sourceTree = "<group>"; };
|
||||||
955B7A0D257D098C0091B1F9 /* SearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchBar.swift; sourceTree = "<group>"; };
|
955B7A0D257D098C0091B1F9 /* SearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchBar.swift; sourceTree = "<group>"; };
|
||||||
955B7A0F257D10A70091B1F9 /* ViewControllerResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewControllerResolver.swift; sourceTree = "<group>"; };
|
955B7A0F257D10A70091B1F9 /* ViewControllerResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewControllerResolver.swift; sourceTree = "<group>"; };
|
||||||
95906F47257506360060F5D0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
95906F47257506360060F5D0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
@@ -106,6 +108,7 @@
|
|||||||
9512D3C0257AB4F60023C3A1 /* NewReminderView.swift */,
|
9512D3C0257AB4F60023C3A1 /* NewReminderView.swift */,
|
||||||
955B7A0D257D098C0091B1F9 /* SearchBar.swift */,
|
955B7A0D257D098C0091B1F9 /* SearchBar.swift */,
|
||||||
955B7A0F257D10A70091B1F9 /* ViewControllerResolver.swift */,
|
955B7A0F257D10A70091B1F9 /* ViewControllerResolver.swift */,
|
||||||
|
9554BDB7257E498F00D8925B /* OnboardingView.swift */,
|
||||||
);
|
);
|
||||||
path = View;
|
path = View;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -291,6 +294,7 @@
|
|||||||
9512D3C1257AB4F60023C3A1 /* NewReminderView.swift in Sources */,
|
9512D3C1257AB4F60023C3A1 /* NewReminderView.swift in Sources */,
|
||||||
954E683D2574ED9E0034EBA8 /* UserDefaultsExtensions.swift in Sources */,
|
954E683D2574ED9E0034EBA8 /* UserDefaultsExtensions.swift in Sources */,
|
||||||
955B7A0E257D098C0091B1F9 /* SearchBar.swift in Sources */,
|
955B7A0E257D098C0091B1F9 /* SearchBar.swift in Sources */,
|
||||||
|
9554BDB8257E498F00D8925B /* OnboardingView.swift in Sources */,
|
||||||
95C46A51255D3A34007A75E5 /* CircularViewModel.swift in Sources */,
|
95C46A51255D3A34007A75E5 /* CircularViewModel.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import Shared
|
|||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
@ObservedObject var circularViewModel = CircularViewModel(repository: iOSRepository.getCircularRepository())
|
@ObservedObject var circularViewModel = CircularViewModel(repository: iOSRepository.getCircularRepository())
|
||||||
@ObservedObject var searchBar: SearchBar = SearchBar(placeholder: "Search circulars")
|
@ObservedObject var searchBar: SearchBar = SearchBar(placeholder: "Search circulars")
|
||||||
|
@State var showOnboarding = !UserDefaults.standard.bool(forKey: "skipOnboarding")
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationView {
|
NavigationView {
|
||||||
@@ -40,6 +41,10 @@ struct ContentView: View {
|
|||||||
.onDisappear(perform: {
|
.onDisappear(perform: {
|
||||||
self.circularViewModel.stopObserving()
|
self.circularViewModel.stopObserving()
|
||||||
})
|
})
|
||||||
|
}.sheet(isPresented: self.$showOnboarding, onDismiss: {
|
||||||
|
UserDefaults.standard.set(true, forKey: "skipOnboarding")
|
||||||
|
}) {
|
||||||
|
OnboardingView()
|
||||||
}
|
}
|
||||||
|
|
||||||
Divider()
|
Divider()
|
||||||
|
|||||||
60
ios/circolapp/circolapp/View/OnboardingView.swift
Normal file
60
ios/circolapp/circolapp/View/OnboardingView.swift
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Circolapp
|
||||||
|
* Copyright (C) 2019-2020 Matteo Schiff
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
import Combine
|
||||||
|
import Shared
|
||||||
|
|
||||||
|
struct OnboardingView: View {
|
||||||
|
@State private var school = 0
|
||||||
|
@Environment(\.presentationMode) var presentationMode
|
||||||
|
private let serverCompanion = ServerAPI.Companion()
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
NavigationView {
|
||||||
|
VStack {
|
||||||
|
Text("Choose your school")
|
||||||
|
.font(.headline)
|
||||||
|
.padding()
|
||||||
|
Form {
|
||||||
|
Picker("School", selection: $school) {
|
||||||
|
ForEach(0..<Int(serverCompanion.numberOfServers)) { serverID in
|
||||||
|
let server = serverCompanion.getServer(serverID: Int32(serverID))
|
||||||
|
Text(serverCompanion.getServerName(server: server))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.onReceive([self.school].publisher.first()) { value in
|
||||||
|
UserDefaults.standard.set(value, forKey: "school")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.navigationBarTitle("Welcome to CircolApp")
|
||||||
|
.navigationBarItems(trailing: Button(action: {
|
||||||
|
self.presentationMode.wrappedValue.dismiss()
|
||||||
|
}) {
|
||||||
|
Text("Done")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct OnboardingView_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
OnboardingView()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -60,6 +60,8 @@ class ServerAPI(serverName: Servers) {
|
|||||||
SUCCESS, ERROR
|
SUCCESS, ERROR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val numberOfServers = Servers.values().size
|
||||||
|
|
||||||
fun getServer(serverID: Int): Servers {
|
fun getServer(serverID: Int): Servers {
|
||||||
return Servers.values()[serverID]
|
return Servers.values()[serverID]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user