Mac stuff

This commit is contained in:
Justin Mazzocchi 2020-08-02 22:54:47 -07:00
parent 0755e81ed9
commit 350bf29b49
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C
3 changed files with 83 additions and 16 deletions

View File

@ -7,6 +7,7 @@ struct AddIdentityView: View {
var body: some View { var body: some View {
Form { Form {
Spacer()
#if os(iOS) #if os(iOS)
urlTextField urlTextField
.autocapitalization(.none) .autocapitalization(.none)
@ -25,7 +26,9 @@ struct AddIdentityView: View {
} }
} }
.frame(maxWidth: .infinity, alignment: .center) .frame(maxWidth: .infinity, alignment: .center)
Spacer()
} }
.padding()
.alertItem($viewModel.alertItem) .alertItem($viewModel.alertItem)
} }
} }

View File

@ -10,6 +10,7 @@ struct SettingsView: View {
@EnvironmentObject var sceneViewModel: SceneViewModel @EnvironmentObject var sceneViewModel: SceneViewModel
var body: some View { var body: some View {
VStack(spacing: 0) {
NavigationView { NavigationView {
Form { Form {
HStack { HStack {
@ -29,6 +30,20 @@ struct SettingsView: View {
.navigationBarTitleAndItems(sceneViewModel: sceneViewModel) .navigationBarTitleAndItems(sceneViewModel: sceneViewModel)
} }
.navigationViewStyle .navigationViewStyle
#if os(macOS)
Divider()
HStack {
Spacer()
Button(action: { sceneViewModel.presentingSettings.toggle() }) {
Text("Done")
}
.keyboardShortcut(.defaultAction)
}
.padding()
#endif
}
.frame
} }
} }
@ -54,6 +69,14 @@ private extension View {
return self return self
#endif #endif
} }
var frame: some View {
#if os(macOS)
return frame(minWidth: 400, maxWidth: 600, minHeight: 350, maxHeight: 500)
#else
return self
#endif
}
} }
#if DEBUG #if DEBUG

View File

@ -1,6 +1,9 @@
// Copyright © 2020 Metabolist. All rights reserved. // Copyright © 2020 Metabolist. All rights reserved.
import SwiftUI import SwiftUI
import KingfisherSwiftUI
import struct Kingfisher.DownsamplingImageProcessor
import struct Kingfisher.RoundCornerImageProcessor
struct SidebarNavigation: View { struct SidebarNavigation: View {
let identity: Identity let identity: Identity
@ -16,6 +19,7 @@ struct SidebarNavigation: View {
.tag(topLevelNavigation) .tag(topLevelNavigation)
} }
} }
.overlay(Pocket(identity: identity), alignment: .bottom)
.listStyle(SidebarListStyle()) .listStyle(SidebarListStyle())
} }
@ -39,6 +43,43 @@ private extension SidebarNavigation {
} }
} }
} }
struct Pocket: View {
let identity: Identity
@EnvironmentObject var sceneViewModel: SceneViewModel
var body: some View {
VStack(alignment: .leading, spacing: 0) {
Divider()
Button(action: { sceneViewModel.presentingSettings.toggle() }) {
KFImage(identity.account?.avatar
?? identity.instance?.thumbnail,
options: [
.processor(
DownsamplingImageProcessor(size: CGSize(width: 50, height: 50))
.append(another: RoundCornerImageProcessor(radius: .widthFraction(0.5)))
),
.scaleFactor(Screen.scale),
.cacheOriginalImage
])
.placeholder { Image(systemName: "gear") }
.renderingMode(.original)
.resizable()
.padding(6)
.contentShape(Rectangle())
}
.frame(width: 50, height: 50)
.accessibility(label: Text("Rewards"))
.padding(.vertical, 8)
.padding(.horizontal, 16)
.buttonStyle(PlainButtonStyle())
}
.sheet(isPresented: $sceneViewModel.presentingSettings) {
SettingsView(viewModel: SettingsViewModel(identity: identity))
.environmentObject(sceneViewModel)
}
}
}
} }
#if DEBUG #if DEBUG