Opening main screen after login. MacOS adjustments
This commit is contained in:
parent
0d261b3452
commit
20558430ea
10
AutoCat2 (macOS).entitlements
Normal file
10
AutoCat2 (macOS).entitlements
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@ -53,6 +53,8 @@
|
||||
7A971F1E26AD8AEB007E527B /* Merging.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A971F1426AD8AEB007E527B /* Merging.swift */; };
|
||||
7A971F2026ADC351007E527B /* ApiError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A971F1F26ADC351007E527B /* ApiError.swift */; };
|
||||
7A971F2126ADC351007E527B /* ApiError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A971F1F26ADC351007E527B /* ApiError.swift */; };
|
||||
7A971F2326ADF74B007E527B /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A971F2226ADF74B007E527B /* MainView.swift */; };
|
||||
7A971F2426ADF74B007E527B /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A971F2226ADF74B007E527B /* MainView.swift */; };
|
||||
7ACD05D72695C08A00557667 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ACD05D62695C08A00557667 /* Constants.swift */; };
|
||||
7ACD05D82695C08A00557667 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ACD05D62695C08A00557667 /* Constants.swift */; };
|
||||
7AEFAEED26985A3400ED2C85 /* ACProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AEFAEEC26985A3400ED2C85 /* ACProgressView.swift */; };
|
||||
@ -140,6 +142,8 @@
|
||||
7A971F1226AD8AEB007E527B /* JSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSON.swift; sourceTree = "<group>"; };
|
||||
7A971F1426AD8AEB007E527B /* Merging.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Merging.swift; sourceTree = "<group>"; };
|
||||
7A971F1F26ADC351007E527B /* ApiError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApiError.swift; sourceTree = "<group>"; };
|
||||
7A971F2226ADF74B007E527B /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
|
||||
7A971F2526ADFD35007E527B /* AutoCat2 (macOS).entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "AutoCat2 (macOS).entitlements"; sourceTree = "<group>"; };
|
||||
7ACD05D62695C08A00557667 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
|
||||
7AEFAEEC26985A3400ED2C85 /* ACProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ACProgressView.swift; sourceTree = "<group>"; };
|
||||
7AF552D82696E5C100578083 /* ApiTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApiTests.swift; sourceTree = "<group>"; };
|
||||
@ -187,6 +191,7 @@
|
||||
7A40D5732691C6D6009B0BC4 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7A971F2526ADFD35007E527B /* AutoCat2 (macOS).entitlements */,
|
||||
7A40D5782691C6D7009B0BC4 /* Shared */,
|
||||
7A40D5912691C6D8009B0BC4 /* Tests iOS */,
|
||||
7A40D59B2691C6D8009B0BC4 /* Tests macOS */,
|
||||
@ -207,7 +212,6 @@
|
||||
7A40D5E626924BAA009B0BC4 /* Property Wrappers */,
|
||||
7A40D5DF26924ADE009B0BC4 /* Models */,
|
||||
7A40D57B2691C6D7009B0BC4 /* AutoCat2App.swift */,
|
||||
7A40D57C2691C6D7009B0BC4 /* ContentView.swift */,
|
||||
7A40D57D2691C6D7009B0BC4 /* Persistence.swift */,
|
||||
7A40D57E2691C6D7009B0BC4 /* Assets.xcassets */,
|
||||
7A40D5792691C6D7009B0BC4 /* AutoCat2.xcdatamodeld */,
|
||||
@ -270,8 +274,10 @@
|
||||
7A40D5E726938BC8009B0BC4 /* Views */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7A40D5E826938BEC009B0BC4 /* AuthView.swift */,
|
||||
7AEFAEEC26985A3400ED2C85 /* ACProgressView.swift */,
|
||||
7A40D57C2691C6D7009B0BC4 /* ContentView.swift */,
|
||||
7A40D5E826938BEC009B0BC4 /* AuthView.swift */,
|
||||
7A971F2226ADF74B007E527B /* MainView.swift */,
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
@ -323,19 +329,11 @@
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7A503C00269F370A002C1A0D /* Responses */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7A503C01269F3797002C1A0D /* Login */,
|
||||
);
|
||||
path = Responses;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7A503C01269F3797002C1A0D /* Login */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7A503C02269F382F002C1A0D /* login_success.json */,
|
||||
);
|
||||
path = Login;
|
||||
path = Responses;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7A971F0326AD6EA1007E527B /* Api */ = {
|
||||
@ -569,6 +567,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7A40D5E926938BEC009B0BC4 /* AuthView.swift in Sources */,
|
||||
7A971F2326ADF74B007E527B /* MainView.swift in Sources */,
|
||||
7A971F0D26AD7D4C007E527B /* AnyEncodable.swift in Sources */,
|
||||
7ACD05D72695C08A00557667 /* Constants.swift in Sources */,
|
||||
7A971F1926AD8AEB007E527B /* JSON.swift in Sources */,
|
||||
@ -596,6 +595,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7A40D5EA26938BEC009B0BC4 /* AuthView.swift in Sources */,
|
||||
7A971F2426ADF74B007E527B /* MainView.swift in Sources */,
|
||||
7A971F0E26AD7D4C007E527B /* AnyEncodable.swift in Sources */,
|
||||
7ACD05D82695C08A00557667 /* Constants.swift in Sources */,
|
||||
7A971F1A26AD8AEB007E527B /* JSON.swift in Sources */,
|
||||
@ -849,6 +849,7 @@
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = "AutoCat2 (macOS).entitlements";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
@ -878,6 +879,7 @@
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = "AutoCat2 (macOS).entitlements";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
import Foundation
|
||||
|
||||
public class Settings {
|
||||
public class Settings: ObservableObject {
|
||||
private var defaults: UserDefaults
|
||||
public static let shared = Settings()
|
||||
|
||||
@Published
|
||||
public var user: User {
|
||||
didSet {
|
||||
if let json = try? JSONEncoder().encode(self.user) {
|
||||
|
||||
@ -1,22 +1,39 @@
|
||||
import SwiftUI
|
||||
|
||||
struct AuthView: View {
|
||||
|
||||
enum Field {
|
||||
case email
|
||||
case password
|
||||
}
|
||||
|
||||
@ObservedObject var viewModel = AuthVM()
|
||||
|
||||
@State private var login: String = ""
|
||||
@State private var password: String = ""
|
||||
@State private var showProgress: Bool = false
|
||||
@State private var alert: AlertMessage? = nil
|
||||
@FocusState private var focus: Field?
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
VStack(alignment: .center, spacing: 16) {
|
||||
Spacer()
|
||||
#if os(iOS)
|
||||
TextField("Login", text: $login)
|
||||
.focused($focus, equals: .email)
|
||||
.textContentType(.emailAddress)
|
||||
.keyboardType(.emailAddress)
|
||||
#else
|
||||
TextField("Login", text: $login)
|
||||
.focused($focus, equals: .email)
|
||||
#endif
|
||||
SecureField("Password", text: $password)
|
||||
.focused($focus, equals: .password)
|
||||
Button("Login") {
|
||||
async {
|
||||
Task.init {
|
||||
do {
|
||||
self.focus = nil
|
||||
self.showProgress = true
|
||||
try await self.viewModel.login(user: self.login, password: self.password)
|
||||
self.showProgress = false
|
||||
|
||||
@ -2,11 +2,13 @@ import SwiftUI
|
||||
import CoreData
|
||||
|
||||
struct ContentView: View {
|
||||
@StateObject var settings = Settings.shared
|
||||
|
||||
var body: some View {
|
||||
if Settings.shared.user.token.isEmpty {
|
||||
if settings.user.token.isEmpty {
|
||||
AuthView()
|
||||
} else {
|
||||
EmptyView()
|
||||
MainView()
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Shared/Views/MainView.swift
Normal file
13
Shared/Views/MainView.swift
Normal file
@ -0,0 +1,13 @@
|
||||
import SwiftUI
|
||||
|
||||
struct MainView: View {
|
||||
var body: some View {
|
||||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
}
|
||||
|
||||
struct MainView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
MainView()
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user