mirror of
https://github.com/metabolist/metatext.git
synced 2024-06-02 13:21:41 +00:00
Refactoring
This commit is contained in:
parent
77a1c799f5
commit
948db9d274
|
@ -348,7 +348,6 @@
|
||||||
"status.visibility.unlisted.description" = "Visible for all, but not in public timelines";
|
"status.visibility.unlisted.description" = "Visible for all, but not in public timelines";
|
||||||
"status.visibility.private.description" = "Visible for followers only";
|
"status.visibility.private.description" = "Visible for followers only";
|
||||||
"status.visibility.direct.description" = "Visible for mentioned users only";
|
"status.visibility.direct.description" = "Visible for mentioned users only";
|
||||||
"system" = "System";
|
|
||||||
"tag.accessibility-recent-uses-%ld" = "%ld recent uses";
|
"tag.accessibility-recent-uses-%ld" = "%ld recent uses";
|
||||||
"tag.accessibility-hint.post" = "View posts associated with trend";
|
"tag.accessibility-hint.post" = "View posts associated with trend";
|
||||||
"tag.accessibility-hint.toot" = "View toots associated with trend";
|
"tag.accessibility-hint.toot" = "View toots associated with trend";
|
||||||
|
|
|
@ -6,7 +6,7 @@ import Mastodon
|
||||||
import ServiceLayer
|
import ServiceLayer
|
||||||
|
|
||||||
public final class NavigationViewModel: ObservableObject {
|
public final class NavigationViewModel: ObservableObject {
|
||||||
@Published public private(set) var identityContext: IdentityContext
|
public let identityContext: IdentityContext
|
||||||
public let navigations: AnyPublisher<Navigation, Never>
|
public let navigations: AnyPublisher<Navigation, Never>
|
||||||
|
|
||||||
@Published public private(set) var recentIdentities = [Identity]()
|
@Published public private(set) var recentIdentities = [Identity]()
|
||||||
|
|
|
@ -6,11 +6,6 @@ import ViewModels
|
||||||
|
|
||||||
struct RootView: View {
|
struct RootView: View {
|
||||||
@StateObject var viewModel: RootViewModel
|
@StateObject var viewModel: RootViewModel
|
||||||
@State private var previousColorScheme: AppPreferences.ColorScheme = .system
|
|
||||||
var appPreferencesPublisher: AnyPublisher<AppPreferences, Never> {
|
|
||||||
viewModel.navigationViewModel?.identityContext.$appPreferences.eraseToAnyPublisher()
|
|
||||||
?? Empty<AppPreferences, Never>().eraseToAnyPublisher()
|
|
||||||
}
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Group {
|
Group {
|
||||||
|
@ -20,6 +15,8 @@ struct RootView: View {
|
||||||
.environmentObject(viewModel)
|
.environmentObject(viewModel)
|
||||||
.transition(.opacity)
|
.transition(.opacity)
|
||||||
.edgesIgnoringSafeArea(.all)
|
.edgesIgnoringSafeArea(.all)
|
||||||
|
.onReceive(navigationViewModel.identityContext.$appPreferences.map(\.colorScheme),
|
||||||
|
perform: setColorScheme)
|
||||||
} else {
|
} else {
|
||||||
NavigationView {
|
NavigationView {
|
||||||
AddIdentityView(
|
AddIdentityView(
|
||||||
|
@ -33,20 +30,18 @@ struct RootView: View {
|
||||||
.transition(.opacity)
|
.transition(.opacity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onReceive(appPreferencesPublisher) { preferences in
|
|
||||||
if preferences.colorScheme != previousColorScheme {
|
}
|
||||||
self.previousColorScheme = preferences.colorScheme
|
}
|
||||||
setColorScheme(preferences.colorScheme)
|
|
||||||
|
private extension RootView {
|
||||||
|
func setColorScheme(_ colorScheme: AppPreferences.ColorScheme) {
|
||||||
|
for scene in UIApplication.shared.connectedScenes.compactMap({ $0 as? UIWindowScene }) {
|
||||||
|
for window in scene.windows {
|
||||||
|
window.overrideUserInterfaceStyle = colorScheme.uiKit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setColorScheme(_ colorScheme: AppPreferences.ColorScheme) {
|
|
||||||
let scenes = UIApplication.shared.connectedScenes
|
|
||||||
let windowScenes = scenes.first as? UIWindowScene
|
|
||||||
let window = windowScenes?.windows.first
|
|
||||||
window?.overrideUserInterfaceStyle = colorScheme.uiKit
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension AppPreferences.ColorScheme {
|
extension AppPreferences.ColorScheme {
|
||||||
|
|
Loading…
Reference in a new issue