adding credential checking on login screen, big playlist title

This commit is contained in:
andy 2022-04-22 18:10:14 +01:00
parent bbeae5b432
commit 8834823d30
5 changed files with 56 additions and 3 deletions

View File

@ -7,6 +7,7 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
A10C8D29281302050018AE12 /* ToastUI in Frameworks */ = {isa = PBXBuildFile; productRef = A10C8D28281302050018AE12 /* ToastUI */; };
E906F7F42414019C004E1E31 /* NetworkPersister.swift in Sources */ = {isa = PBXBuildFile; fileRef = E906F7F32414019C004E1E31 /* NetworkPersister.swift */; }; E906F7F42414019C004E1E31 /* NetworkPersister.swift in Sources */ = {isa = PBXBuildFile; fileRef = E906F7F32414019C004E1E31 /* NetworkPersister.swift */; };
E906F7F724143AA7004E1E31 /* SwiftUICharts in Frameworks */ = {isa = PBXBuildFile; productRef = E906F7F624143AA7004E1E31 /* SwiftUICharts */; }; E906F7F724143AA7004E1E31 /* SwiftUICharts in Frameworks */ = {isa = PBXBuildFile; productRef = E906F7F624143AA7004E1E31 /* SwiftUICharts */; };
E934AC99240DD0E4009869F4 /* AddTagSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = E934AC98240DD0E4009869F4 /* AddTagSheet.swift */; }; E934AC99240DD0E4009869F4 /* AddTagSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = E934AC98240DD0E4009869F4 /* AddTagSheet.swift */; };
@ -108,6 +109,7 @@
E97AF45923FC50EC00635494 /* SwiftyJSON in Frameworks */, E97AF45923FC50EC00635494 /* SwiftyJSON in Frameworks */,
E98254D923FB53780056D9D3 /* Alamofire in Frameworks */, E98254D923FB53780056D9D3 /* Alamofire in Frameworks */,
E97AF45E23FC83AF00635494 /* KeychainAccess in Frameworks */, E97AF45E23FC83AF00635494 /* KeychainAccess in Frameworks */,
A10C8D29281302050018AE12 /* ToastUI in Frameworks */,
E906F7F724143AA7004E1E31 /* SwiftUICharts in Frameworks */, E906F7F724143AA7004E1E31 /* SwiftUICharts in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
@ -289,6 +291,7 @@
E97AF45823FC50EC00635494 /* SwiftyJSON */, E97AF45823FC50EC00635494 /* SwiftyJSON */,
E97AF45D23FC83AF00635494 /* KeychainAccess */, E97AF45D23FC83AF00635494 /* KeychainAccess */,
E906F7F624143AA7004E1E31 /* SwiftUICharts */, E906F7F624143AA7004E1E31 /* SwiftUICharts */,
A10C8D28281302050018AE12 /* ToastUI */,
); );
productName = "Music Tools"; productName = "Music Tools";
productReference = E9EA690723F9A5430012C3E8 /* Music Tools.app */; productReference = E9EA690723F9A5430012C3E8 /* Music Tools.app */;
@ -367,6 +370,7 @@
E97AF45723FC50EC00635494 /* XCRemoteSwiftPackageReference "swiftyjson" */, E97AF45723FC50EC00635494 /* XCRemoteSwiftPackageReference "swiftyjson" */,
E97AF45C23FC83AF00635494 /* XCRemoteSwiftPackageReference "keychainaccess" */, E97AF45C23FC83AF00635494 /* XCRemoteSwiftPackageReference "keychainaccess" */,
E906F7F524143AA7004E1E31 /* XCRemoteSwiftPackageReference "chartview" */, E906F7F524143AA7004E1E31 /* XCRemoteSwiftPackageReference "chartview" */,
A10C8D27281302050018AE12 /* XCRemoteSwiftPackageReference "ToastUI" */,
); );
productRefGroup = E9EA690823F9A5430012C3E8 /* Products */; productRefGroup = E9EA690823F9A5430012C3E8 /* Products */;
projectDirPath = ""; projectDirPath = "";
@ -768,6 +772,14 @@
/* End XCConfigurationList section */ /* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */ /* Begin XCRemoteSwiftPackageReference section */
A10C8D27281302050018AE12 /* XCRemoteSwiftPackageReference "ToastUI" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/quanshousio/ToastUI";
requirement = {
branch = main;
kind = branch;
};
};
E906F7F524143AA7004E1E31 /* XCRemoteSwiftPackageReference "chartview" */ = { E906F7F524143AA7004E1E31 /* XCRemoteSwiftPackageReference "chartview" */ = {
isa = XCRemoteSwiftPackageReference; isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/apppear/chartview"; repositoryURL = "https://github.com/apppear/chartview";
@ -803,6 +815,11 @@
/* End XCRemoteSwiftPackageReference section */ /* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */ /* Begin XCSwiftPackageProductDependency section */
A10C8D28281302050018AE12 /* ToastUI */ = {
isa = XCSwiftPackageProductDependency;
package = A10C8D27281302050018AE12 /* XCRemoteSwiftPackageReference "ToastUI" */;
productName = ToastUI;
};
E906F7F624143AA7004E1E31 /* SwiftUICharts */ = { E906F7F624143AA7004E1E31 /* SwiftUICharts */ = {
isa = XCSwiftPackageProductDependency; isa = XCSwiftPackageProductDependency;
package = E906F7F524143AA7004E1E31 /* XCRemoteSwiftPackageReference "chartview" */; package = E906F7F524143AA7004E1E31 /* XCRemoteSwiftPackageReference "chartview" */;

View File

@ -35,6 +35,15 @@
"revision" : "2b6054efa051565954e1d2b9da831680026cd768", "revision" : "2b6054efa051565954e1d2b9da831680026cd768",
"version" : "5.0.0" "version" : "5.0.0"
} }
},
{
"identity" : "toastui",
"kind" : "remoteSourceControl",
"location" : "https://github.com/quanshousio/ToastUI",
"state" : {
"branch" : "main",
"revision" : "b064788dd92a64fbd01208a65af10beded99062c"
}
} }
], ],
"version" : 2 "version" : 2

View File

@ -74,7 +74,7 @@
<EnvironmentVariable <EnvironmentVariable
key = "MTOOLS_SERVER" key = "MTOOLS_SERVER"
value = "http://127.0.0.1:5000/" value = "http://127.0.0.1:5000/"
isEnabled = "YES"> isEnabled = "NO">
</EnvironmentVariable> </EnvironmentVariable>
</EnvironmentVariables> </EnvironmentVariables>
</LaunchAction> </LaunchAction>

View File

@ -7,6 +7,7 @@
// //
import SwiftUI import SwiftUI
import ToastUI
import KeychainAccess import KeychainAccess
struct LoginScreen: View { struct LoginScreen: View {
@ -16,6 +17,9 @@ struct LoginScreen: View {
@State private var username: String = "" @State private var username: String = ""
@State private var password: String = "" @State private var password: String = ""
@State private var showingToast = false
@State private var toastText = ""
var body: some View { var body: some View {
VStack { VStack {
Image("MusicToolsLogo") Image("MusicToolsLogo")
@ -36,7 +40,25 @@ struct LoginScreen: View {
keychain["username"] = username keychain["username"] = username
keychain["password"] = password keychain["password"] = password
let api = UserApi.getUser
RequestBuilder.buildRequest(apiRequest: api)
.validate()
.responseData { response in
switch response.result {
case .success:
makingRequest = false
self.liveUser.loggedIn = true self.liveUser.loggedIn = true
case .failure:
makingRequest = false
keychain["username"] = nil
keychain["password"] = nil
toastText = "Login Failed"
showingToast = true
}
}
}) { }) {
Text("Log In") Text("Log In")
} }
@ -45,6 +67,11 @@ struct LoginScreen: View {
Text("Register") Text("Register")
} }
} }
.toast(isPresented: $showingToast, dismissAfter: 3.0){
ToastView(toastText)
.toastViewStyle(.failure)
}
.toastDimmedBackground(false)
} }
.padding() .padding()
} }

View File

@ -199,7 +199,7 @@ struct PlaylistView: View {
} }
} }
.navigationBarTitle(Text(playlist.name), displayMode: .inline) .navigationBarTitle(Text(playlist.name))
.refreshable { .refreshable {
self.refreshPlaylist() self.refreshPlaylist()
} }