This commit is contained in:
Justin Mazzocchi 2020-08-07 21:08:57 -07:00
parent e30f526a15
commit 47c7d4c164
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C
4 changed files with 10 additions and 14 deletions

View File

@ -92,20 +92,16 @@ extension AppEnvironment {
webAuthSessionType: SuccessfulStubbingWebAuthSession.self) webAuthSessionType: SuccessfulStubbingWebAuthSession.self)
} }
extension IdentityRepository {
static let development = try! IdentityRepository(identityID: devIdentityID, appEnvironment: .development)
}
extension RootViewModel { extension RootViewModel {
static let development = RootViewModel(environment: .development) static let development = RootViewModel(environment: .development)
} }
extension MainNavigationViewModel { extension MainNavigationViewModel {
static let development = MainNavigationViewModel(identityRepository: .development) static let development = RootViewModel.development.mainNavigationViewModel(identityID: devIdentityID)!
} }
extension SecondaryNavigationViewModel { extension SecondaryNavigationViewModel {
static let development = MainNavigationViewModel.development.settingsViewModel() static let development = MainNavigationViewModel.development.secondaryNavigationViewModel()
} }
extension IdentitiesViewModel { extension IdentitiesViewModel {

View File

@ -6,7 +6,7 @@ import Combine
class MainNavigationViewModel: ObservableObject { class MainNavigationViewModel: ObservableObject {
@Published private(set) var identity: Identity @Published private(set) var identity: Identity
@Published private(set) var recentIdentities = [Identity]() @Published private(set) var recentIdentities = [Identity]()
@Published var presentingSettings = false @Published var presentingSecondaryNavigation = false
@Published var alertItem: AlertItem? @Published var alertItem: AlertItem?
var selectedTab: Tab? = .timelines var selectedTab: Tab? = .timelines
@ -46,7 +46,7 @@ extension MainNavigationViewModel {
.store(in: &cancellables) .store(in: &cancellables)
} }
func settingsViewModel() -> SecondaryNavigationViewModel { func secondaryNavigationViewModel() -> SecondaryNavigationViewModel {
SecondaryNavigationViewModel(identityRepository: identityRepository) SecondaryNavigationViewModel(identityRepository: identityRepository)
} }
} }

View File

@ -22,8 +22,8 @@ struct TabNavigation: View {
.tag(tab) .tag(tab)
} }
} }
.sheet(isPresented: $viewModel.presentingSettings) { .sheet(isPresented: $viewModel.presentingSecondaryNavigation) {
SecondaryNavigationView(viewModel: viewModel.settingsViewModel()) SecondaryNavigationView(viewModel: viewModel.secondaryNavigationViewModel())
.environmentObject(rootViewModel) .environmentObject(rootViewModel)
} }
.alertItem($viewModel.alertItem) .alertItem($viewModel.alertItem)
@ -44,7 +44,7 @@ private extension TabNavigation {
.navigationBarTitle(viewModel.identity.handle, displayMode: .inline) .navigationBarTitle(viewModel.identity.handle, displayMode: .inline)
.navigationBarItems( .navigationBarItems(
leading: Button { leading: Button {
viewModel.presentingSettings.toggle() viewModel.presentingSecondaryNavigation.toggle()
} label: { } label: {
KFImage(viewModel.identity.image, KFImage(viewModel.identity.image,
options: .downsampled(dimension: 28, scaleFactor: displayScale)) options: .downsampled(dimension: 28, scaleFactor: displayScale))

View File

@ -61,7 +61,7 @@ private extension SidebarNavigation {
var body: some View { var body: some View {
VStack(alignment: .leading, spacing: 0) { VStack(alignment: .leading, spacing: 0) {
Divider() Divider()
Button(action: { viewModel.presentingSettings.toggle() }) { Button(action: { viewModel.presentingSecondaryNavigation.toggle() }) {
KFImage(viewModel.identity.image, KFImage(viewModel.identity.image,
options: .downsampled(dimension: 28, scaleFactor: displayScale)) options: .downsampled(dimension: 28, scaleFactor: displayScale))
.placeholder { Image(systemName: "gear") } .placeholder { Image(systemName: "gear") }
@ -76,8 +76,8 @@ private extension SidebarNavigation {
.padding(.horizontal, 16) .padding(.horizontal, 16)
.buttonStyle(PlainButtonStyle()) .buttonStyle(PlainButtonStyle())
} }
.sheet(isPresented: $viewModel.presentingSettings) { .sheet(isPresented: $viewModel.presentingSecondaryNavigation) {
SecondaryNavigationView(viewModel: viewModel.settingsViewModel()) SecondaryNavigationView(viewModel: viewModel.secondaryNavigationViewModel())
.environmentObject(viewModel) .environmentObject(viewModel)
.environmentObject(rootViewModel) .environmentObject(rootViewModel)
} }