additional work on iOS sheets
This commit is contained in:
parent
ad678f2fc1
commit
762417e2ba
|
@ -19,6 +19,16 @@ class AddFeedlyViewModel: ObservableObject, OAuthAccountAuthorizationOperationDe
|
|||
@Published var username: String = ""
|
||||
@Published var password: String = ""
|
||||
|
||||
func authenticateFeedly() {
|
||||
isAuthenticating = true
|
||||
let addAccount = OAuthAccountAuthorizationOperation(accountType: .feedly)
|
||||
addAccount.delegate = self
|
||||
#if os(macOS)
|
||||
addAccount.presentationAnchor = NSApplication.shared.windows.last
|
||||
#endif
|
||||
MainThreadOperationQueue.shared.add(addAccount)
|
||||
}
|
||||
|
||||
func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didCreate account: Account) {
|
||||
|
||||
isAuthenticating = false
|
||||
|
|
|
@ -19,6 +19,41 @@ struct AddFeedWranglerAccountView: View {
|
|||
@StateObject private var model = AddFeedWranglerViewModel()
|
||||
|
||||
var body: some View {
|
||||
#if os(macOS)
|
||||
macBody
|
||||
#else
|
||||
iosBody
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if os(iOS)
|
||||
var iosBody: some View {
|
||||
List {
|
||||
Section(header: formHeader, footer: ProgressView()
|
||||
.scaleEffect(CGSize(width: 0.5, height: 0.5))
|
||||
.hidden(!model.isAuthenticating) , content: {
|
||||
TextField("me@email.com", text: $model.username)
|
||||
SecureField("•••••••••••", text: $model.password)
|
||||
})
|
||||
}.navigationBarItems(leading:
|
||||
Button(action: {
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
}, label: {
|
||||
Text("Dismiss")
|
||||
})
|
||||
, trailing:
|
||||
Button(action: {
|
||||
model.authenticateFeedWrangler()
|
||||
}, label: {
|
||||
Text("Add")
|
||||
}).disabled(model.username.isEmpty || model.password.isEmpty)
|
||||
)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(macOS)
|
||||
var macBody: some View {
|
||||
VStack {
|
||||
HStack(spacing: 16) {
|
||||
VStack(alignment: .leading) {
|
||||
|
@ -93,9 +128,26 @@ struct AddFeedWranglerAccountView: View {
|
|||
presentationMode.wrappedValue.dismiss()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
var formHeader: some View {
|
||||
HStack {
|
||||
VStack(alignment: .center) {
|
||||
AccountType.newsBlur.image()
|
||||
.resizable()
|
||||
.frame(width: 50, height: 50)
|
||||
Text("Sign in to your NewsBlur account.")
|
||||
.font(.headline)
|
||||
|
||||
Text("This account syncs across your subscriptions across devices.")
|
||||
.foregroundColor(.secondary)
|
||||
.font(.callout)
|
||||
.lineLimit(2)
|
||||
.padding(.top, 4)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,9 @@ struct AddFeedbinAccountView: View {
|
|||
#if os(macOS)
|
||||
macBody
|
||||
#else
|
||||
NavigationView {
|
||||
iosBody
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -29,24 +31,37 @@ struct AddFeedbinAccountView: View {
|
|||
var iosBody: some View {
|
||||
List {
|
||||
Section(header: formHeader, footer: ProgressView()
|
||||
.scaleEffect(CGSize(width: 0.5, height: 0.5))
|
||||
.hidden(!model.isAuthenticating) , content: {
|
||||
TextField("me@email.com", text: $model.username)
|
||||
SecureField("•••••••••••", text: $model.password)
|
||||
TextField("Email", text: $model.username)
|
||||
SecureField("Password", text: $model.password)
|
||||
})
|
||||
}.navigationBarItems(leading:
|
||||
|
||||
Section(footer: formFooter, content: {
|
||||
Button(action: {
|
||||
model.authenticateFeedbin()
|
||||
}, label: {
|
||||
Text("Sign In")
|
||||
}).disabled(model.username.isEmpty || model.password.isEmpty)
|
||||
})
|
||||
|
||||
}
|
||||
.navigationBarItems(leading:
|
||||
Button(action: {
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
}, label: {
|
||||
Text("Dismiss")
|
||||
})
|
||||
, trailing:
|
||||
Button(action: {
|
||||
model.authenticateFeedbin()
|
||||
}, label: {
|
||||
Text("Add")
|
||||
}).disabled(model.username.isEmpty || model.password.isEmpty)
|
||||
)
|
||||
}))
|
||||
.listStyle(InsetGroupedListStyle())
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.navigationTitle(Text("Feedbin"))
|
||||
.alert(isPresented: $model.showError, content: {
|
||||
Alert(title: Text("Sign In Error"), message: Text(model.accountUpdateError.description), dismissButton: .cancel(Text("Dismiss")))
|
||||
})
|
||||
.onReceive(model.$canDismiss, perform: { value in
|
||||
if value == true {
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
}
|
||||
})
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -130,14 +145,31 @@ struct AddFeedbinAccountView: View {
|
|||
|
||||
var formHeader: some View {
|
||||
HStack {
|
||||
Spacer()
|
||||
VStack(alignment: .center) {
|
||||
AccountType.feedbin.image()
|
||||
.resizable()
|
||||
.frame(width: 50, height: 50)
|
||||
Text("Sign in to your Feedbin account.")
|
||||
.font(.headline)
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
}.padding(.vertical)
|
||||
}
|
||||
|
||||
var formFooter: some View {
|
||||
HStack {
|
||||
Spacer()
|
||||
VStack(spacing: 8) {
|
||||
Text("Sign in to your Feedbin account and sync your subscriptions across your devices. Your username and password and password will be encrypted and stored in Keychain.")
|
||||
Text("Don't have a Feedbin account?")
|
||||
Button(action: {}, label: {
|
||||
Text("Sign Up Here").foregroundColor(.blue).multilineTextAlignment(.center)
|
||||
}).disabled(model.username.isEmpty || model.password.isEmpty)
|
||||
}
|
||||
.multilineTextAlignment(.center)
|
||||
.font(.caption2)
|
||||
Spacer()
|
||||
|
||||
}.padding(.vertical)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,26 @@ struct AddFeedlyAccountView: View {
|
|||
@StateObject private var model = AddFeedlyViewModel()
|
||||
|
||||
var body: some View {
|
||||
#if os(macOS)
|
||||
macBody
|
||||
#else
|
||||
NavigationView {
|
||||
iosBody
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if os(iOS)
|
||||
var iosBody: some View {
|
||||
Text("TBC")
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(macOS)
|
||||
var macBody: some View {
|
||||
VStack {
|
||||
HStack(spacing: 16) {
|
||||
VStack(alignment: .leading) {
|
||||
|
@ -67,17 +87,10 @@ struct AddFeedlyAccountView: View {
|
|||
.alert(isPresented: $model.showError, content: {
|
||||
Alert(title: Text("Sign In Error"), message: Text(model.accountUpdateError.description), dismissButton: .cancel())
|
||||
})
|
||||
}
|
||||
|
||||
private func authenticateFeedly() {
|
||||
model.isAuthenticating = true
|
||||
let addAccount = OAuthAccountAuthorizationOperation(accountType: .feedly)
|
||||
addAccount.delegate = model
|
||||
#if os(macOS)
|
||||
addAccount.presentationAnchor = NSApplication.shared.windows.last
|
||||
#endif
|
||||
MainThreadOperationQueue.shared.add(addAccount)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
struct AddFeedlyAccountView_Previews: PreviewProvider {
|
||||
|
|
|
@ -42,7 +42,7 @@ struct AddNewsBlurAccountView: View {
|
|||
})
|
||||
, trailing:
|
||||
Button(action: {
|
||||
authenticateNewsBlur()
|
||||
model.authenticateNewsBlur()
|
||||
}, label: {
|
||||
Text("Add")
|
||||
}).disabled(model.username.isEmpty || model.password.isEmpty)
|
||||
|
|
|
@ -19,6 +19,21 @@ struct AddReaderAPIAccountView: View {
|
|||
public var accountType: AccountType
|
||||
|
||||
var body: some View {
|
||||
#if os(macOS)
|
||||
macBody
|
||||
#else
|
||||
iosBody
|
||||
#endif
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
var iosBody: some View {
|
||||
Text("TBC")
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(macOS)
|
||||
var macBody: some View {
|
||||
VStack {
|
||||
HStack(spacing: 16) {
|
||||
VStack(alignment: .leading) {
|
||||
|
@ -107,6 +122,10 @@ struct AddReaderAPIAccountView: View {
|
|||
}
|
||||
})
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
func createDisabled() -> Bool {
|
||||
if accountType == .freshRSS {
|
||||
|
@ -122,6 +141,9 @@ struct AddReaderAPIAccountView: View {
|
|||
return 230
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private func signUp() {
|
||||
switch accountType {
|
||||
case .freshRSS:
|
||||
|
|
|
@ -27,15 +27,21 @@ struct SettingsAddAccountView: View {
|
|||
}
|
||||
.listStyle(InsetGroupedListStyle())
|
||||
.sheet(isPresented: $model.isAddPresented) {
|
||||
switch model.selectedAccountType {
|
||||
switch model.selectedAccountType! {
|
||||
case .onMyMac:
|
||||
AddLocalAccountView()
|
||||
case .feedbin, .feedWrangler, .newsBlur, .freshRSS:
|
||||
SettingsCredentialsAccountView(accountType: model.selectedAccountType!)
|
||||
case .feedbin:
|
||||
AddFeedbinAccountView()
|
||||
case .cloudKit:
|
||||
SettingsCloudKitAccountView()
|
||||
AddCloudKitAccountView()
|
||||
case .feedWrangler:
|
||||
AddFeedWranglerAccountView()
|
||||
case .newsBlur:
|
||||
AddNewsBlurAccountView()
|
||||
case .feedly:
|
||||
AddFeedlyAccountView()
|
||||
default:
|
||||
EmptyView()
|
||||
AddReaderAPIAccountView(accountType: model.selectedAccountType!)
|
||||
}
|
||||
}
|
||||
.navigationBarTitle(Text("Add Account"), displayMode: .inline)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17147" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina5_9" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17120"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17505"/>
|
||||
<capability name="Named colors" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
|
|
Loading…
Reference in New Issue