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 */; };
|
7A971F1E26AD8AEB007E527B /* Merging.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A971F1426AD8AEB007E527B /* Merging.swift */; };
|
||||||
7A971F2026ADC351007E527B /* ApiError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A971F1F26ADC351007E527B /* ApiError.swift */; };
|
7A971F2026ADC351007E527B /* ApiError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A971F1F26ADC351007E527B /* ApiError.swift */; };
|
||||||
7A971F2126ADC351007E527B /* 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 */; };
|
7ACD05D72695C08A00557667 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ACD05D62695C08A00557667 /* Constants.swift */; };
|
||||||
7ACD05D82695C08A00557667 /* 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 */; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
7AF552D82696E5C100578083 /* ApiTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApiTests.swift; sourceTree = "<group>"; };
|
||||||
@ -187,6 +191,7 @@
|
|||||||
7A40D5732691C6D6009B0BC4 = {
|
7A40D5732691C6D6009B0BC4 = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
7A971F2526ADFD35007E527B /* AutoCat2 (macOS).entitlements */,
|
||||||
7A40D5782691C6D7009B0BC4 /* Shared */,
|
7A40D5782691C6D7009B0BC4 /* Shared */,
|
||||||
7A40D5912691C6D8009B0BC4 /* Tests iOS */,
|
7A40D5912691C6D8009B0BC4 /* Tests iOS */,
|
||||||
7A40D59B2691C6D8009B0BC4 /* Tests macOS */,
|
7A40D59B2691C6D8009B0BC4 /* Tests macOS */,
|
||||||
@ -207,7 +212,6 @@
|
|||||||
7A40D5E626924BAA009B0BC4 /* Property Wrappers */,
|
7A40D5E626924BAA009B0BC4 /* Property Wrappers */,
|
||||||
7A40D5DF26924ADE009B0BC4 /* Models */,
|
7A40D5DF26924ADE009B0BC4 /* Models */,
|
||||||
7A40D57B2691C6D7009B0BC4 /* AutoCat2App.swift */,
|
7A40D57B2691C6D7009B0BC4 /* AutoCat2App.swift */,
|
||||||
7A40D57C2691C6D7009B0BC4 /* ContentView.swift */,
|
|
||||||
7A40D57D2691C6D7009B0BC4 /* Persistence.swift */,
|
7A40D57D2691C6D7009B0BC4 /* Persistence.swift */,
|
||||||
7A40D57E2691C6D7009B0BC4 /* Assets.xcassets */,
|
7A40D57E2691C6D7009B0BC4 /* Assets.xcassets */,
|
||||||
7A40D5792691C6D7009B0BC4 /* AutoCat2.xcdatamodeld */,
|
7A40D5792691C6D7009B0BC4 /* AutoCat2.xcdatamodeld */,
|
||||||
@ -270,8 +274,10 @@
|
|||||||
7A40D5E726938BC8009B0BC4 /* Views */ = {
|
7A40D5E726938BC8009B0BC4 /* Views */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
7A40D5E826938BEC009B0BC4 /* AuthView.swift */,
|
|
||||||
7AEFAEEC26985A3400ED2C85 /* ACProgressView.swift */,
|
7AEFAEEC26985A3400ED2C85 /* ACProgressView.swift */,
|
||||||
|
7A40D57C2691C6D7009B0BC4 /* ContentView.swift */,
|
||||||
|
7A40D5E826938BEC009B0BC4 /* AuthView.swift */,
|
||||||
|
7A971F2226ADF74B007E527B /* MainView.swift */,
|
||||||
);
|
);
|
||||||
path = Views;
|
path = Views;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -323,19 +329,11 @@
|
|||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
7A503C00269F370A002C1A0D /* Responses */ = {
|
7A503C00269F370A002C1A0D /* Responses */ = {
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
7A503C01269F3797002C1A0D /* Login */,
|
|
||||||
);
|
|
||||||
path = Responses;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
7A503C01269F3797002C1A0D /* Login */ = {
|
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
7A503C02269F382F002C1A0D /* login_success.json */,
|
7A503C02269F382F002C1A0D /* login_success.json */,
|
||||||
);
|
);
|
||||||
path = Login;
|
path = Responses;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
7A971F0326AD6EA1007E527B /* Api */ = {
|
7A971F0326AD6EA1007E527B /* Api */ = {
|
||||||
@ -569,6 +567,7 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
7A40D5E926938BEC009B0BC4 /* AuthView.swift in Sources */,
|
7A40D5E926938BEC009B0BC4 /* AuthView.swift in Sources */,
|
||||||
|
7A971F2326ADF74B007E527B /* MainView.swift in Sources */,
|
||||||
7A971F0D26AD7D4C007E527B /* AnyEncodable.swift in Sources */,
|
7A971F0D26AD7D4C007E527B /* AnyEncodable.swift in Sources */,
|
||||||
7ACD05D72695C08A00557667 /* Constants.swift in Sources */,
|
7ACD05D72695C08A00557667 /* Constants.swift in Sources */,
|
||||||
7A971F1926AD8AEB007E527B /* JSON.swift in Sources */,
|
7A971F1926AD8AEB007E527B /* JSON.swift in Sources */,
|
||||||
@ -596,6 +595,7 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
7A40D5EA26938BEC009B0BC4 /* AuthView.swift in Sources */,
|
7A40D5EA26938BEC009B0BC4 /* AuthView.swift in Sources */,
|
||||||
|
7A971F2426ADF74B007E527B /* MainView.swift in Sources */,
|
||||||
7A971F0E26AD7D4C007E527B /* AnyEncodable.swift in Sources */,
|
7A971F0E26AD7D4C007E527B /* AnyEncodable.swift in Sources */,
|
||||||
7ACD05D82695C08A00557667 /* Constants.swift in Sources */,
|
7ACD05D82695C08A00557667 /* Constants.swift in Sources */,
|
||||||
7A971F1A26AD8AEB007E527B /* JSON.swift in Sources */,
|
7A971F1A26AD8AEB007E527B /* JSON.swift in Sources */,
|
||||||
@ -849,6 +849,7 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = "AutoCat2 (macOS).entitlements";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
@ -878,6 +879,7 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = "AutoCat2 (macOS).entitlements";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public class Settings {
|
public class Settings: ObservableObject {
|
||||||
private var defaults: UserDefaults
|
private var defaults: UserDefaults
|
||||||
public static let shared = Settings()
|
public static let shared = Settings()
|
||||||
|
|
||||||
|
@Published
|
||||||
public var user: User {
|
public var user: User {
|
||||||
didSet {
|
didSet {
|
||||||
if let json = try? JSONEncoder().encode(self.user) {
|
if let json = try? JSONEncoder().encode(self.user) {
|
||||||
|
|||||||
@ -1,22 +1,39 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct AuthView: View {
|
struct AuthView: View {
|
||||||
|
|
||||||
|
enum Field {
|
||||||
|
case email
|
||||||
|
case password
|
||||||
|
}
|
||||||
|
|
||||||
@ObservedObject var viewModel = AuthVM()
|
@ObservedObject var viewModel = AuthVM()
|
||||||
|
|
||||||
@State private var login: String = ""
|
@State private var login: String = ""
|
||||||
@State private var password: String = ""
|
@State private var password: String = ""
|
||||||
@State private var showProgress: Bool = false
|
@State private var showProgress: Bool = false
|
||||||
@State private var alert: AlertMessage? = nil
|
@State private var alert: AlertMessage? = nil
|
||||||
|
@FocusState private var focus: Field?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
VStack(alignment: .center, spacing: 16) {
|
VStack(alignment: .center, spacing: 16) {
|
||||||
Spacer()
|
Spacer()
|
||||||
|
#if os(iOS)
|
||||||
TextField("Login", text: $login)
|
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)
|
SecureField("Password", text: $password)
|
||||||
|
.focused($focus, equals: .password)
|
||||||
Button("Login") {
|
Button("Login") {
|
||||||
async {
|
Task.init {
|
||||||
do {
|
do {
|
||||||
|
self.focus = nil
|
||||||
self.showProgress = true
|
self.showProgress = true
|
||||||
try await self.viewModel.login(user: self.login, password: self.password)
|
try await self.viewModel.login(user: self.login, password: self.password)
|
||||||
self.showProgress = false
|
self.showProgress = false
|
||||||
|
|||||||
@ -2,11 +2,13 @@ import SwiftUI
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
|
@StateObject var settings = Settings.shared
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if Settings.shared.user.token.isEmpty {
|
if settings.user.token.isEmpty {
|
||||||
AuthView()
|
AuthView()
|
||||||
} else {
|
} 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