|
19 | 19 |
|
20 | 20 | import FactoryKit |
21 | 21 | import SwiftUI |
22 | | -import UtilsLib |
23 | 22 |
|
24 | 23 | struct ContentView: View { |
25 | | - @Environment(\.scenePhase) private var scenePhase |
26 | | - @AppTheme private var theme |
27 | | - @AppTypography private var typography |
28 | | - @Environment(LanguageSettings.self) private var languageSettings |
29 | | - |
30 | | - @Environment(NavigationPathManager.self) private var pathManager |
31 | | - |
32 | | - @State private var viewModel: ContentViewModel |
33 | | - |
34 | | - @State private var openedUrls: [URL] = [] |
35 | | - @State private var showHomeMenuBottomSheetFromButton = false |
36 | | - @State private var showSettingsBottomSheetFromButton = false |
37 | | - |
38 | | - @State private var navigateToAccessibility = false |
39 | | - @State private var navigateToInfo = false |
40 | | - @State private var navigateToDiagnostics = false |
41 | | - |
42 | | - @State private var sharedFilesLoadingTask: Task<Void, Never>? |
43 | | - |
44 | | - private var homeMenuBottomSheetActions: [BottomSheetButton] { |
45 | | - HomeMenuBottomSheetActions.actions( |
46 | | - onInfoClick: { |
47 | | - pathManager.navigate(to: .infoView) |
48 | | - }, |
49 | | - onAccessibilityClick: { |
50 | | - pathManager.navigate(to: .accessibilityView) |
51 | | - }, |
52 | | - onDiagnosticsClick: { |
53 | | - pathManager.navigate(to: .diagnosticsView) |
54 | | - } |
55 | | - ) |
56 | | - } |
57 | | - |
58 | | - init() { |
59 | | - _viewModel = State(wrappedValue: Container.shared.contentViewModel()) |
60 | | - } |
61 | | - |
62 | 24 | var body: some View { |
63 | | - TopBarContainer( |
64 | | - leftIcon: "ic_m3_menu_48pt_wght400", |
65 | | - leftIconAccessibility: "Menu", |
66 | | - onLeftClick: { |
67 | | - showHomeMenuBottomSheetFromButton = true |
68 | | - }, |
69 | | - content: { |
70 | | - ScrollView { |
71 | | - VStack { |
72 | | - HomeView(externalFiles: $openedUrls) |
73 | | - Spacer() |
74 | | - } |
75 | | - } |
76 | | - .background(theme.surface) |
77 | | - .onOpenURL { url in |
78 | | - openedUrls = [url] |
79 | | - } |
80 | | - .onAppear { |
81 | | - if scenePhase == .active { |
82 | | - sharedFilesLoadingTask = Task { |
83 | | - let sharedFiles = await viewModel.getSharedFiles() |
84 | | - if !sharedFiles.isEmpty { |
85 | | - openedUrls = sharedFiles |
86 | | - } |
87 | | - } |
88 | | - } |
89 | | - } |
90 | | - .onChange(of: scenePhase) { _, newPhase in |
91 | | - if newPhase == .active { |
92 | | - sharedFilesLoadingTask?.cancel() |
93 | | - |
94 | | - sharedFilesLoadingTask = Task { |
95 | | - let sharedFiles = await viewModel.getSharedFiles() |
96 | | - if !sharedFiles.isEmpty { |
97 | | - openedUrls = sharedFiles |
98 | | - } |
99 | | - } |
100 | | - } |
101 | | - } |
102 | | - .onDisappear { |
103 | | - sharedFilesLoadingTask?.cancel() |
104 | | - } |
105 | | - } |
106 | | - ) |
107 | | - .bottomSheet(isPresented: $showHomeMenuBottomSheetFromButton, actions: homeMenuBottomSheetActions) |
| 25 | + HomeView() |
108 | 26 | } |
109 | 27 | } |
110 | 28 |
|
|
0 commit comments