From d5d820e1e0482b0ea8352cb4d1ed692c087cdd24 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Sun, 12 May 2024 22:35:26 +0200 Subject: [PATCH] New settings screen --- .../AndroidTools.xcodeproj/project.pbxproj | 24 ++-- .../AndroidTools/AndroidToolsApp.swift | 6 +- .../AndroidTools/Commons/AdbHelper.swift | 4 +- .../AndroidTools/Commons/Constants.swift | 12 ++ .../UseCases/GetAdbVersionUseCase.swift | 15 ++- .../Components/LargeButtonStyle.swift | 22 --- .../Presentation/Menu/MenuView.swift | 22 --- .../Settings/AppearanceSettingsView.swift | 58 ++++++++ .../Settings/ApplicationSettingsView.swift | 91 +++++++++++++ ...ift => ApplicationSettingsViewModel.swift} | 9 +- .../Presentation/Settings/SettingsView.swift | 125 ++---------------- 11 files changed, 211 insertions(+), 177 deletions(-) create mode 100644 AndroidTools/AndroidTools/Commons/Constants.swift delete mode 100644 AndroidTools/AndroidTools/Presentation/Components/LargeButtonStyle.swift create mode 100644 AndroidTools/AndroidTools/Presentation/Settings/AppearanceSettingsView.swift create mode 100644 AndroidTools/AndroidTools/Presentation/Settings/ApplicationSettingsView.swift rename AndroidTools/AndroidTools/Presentation/Settings/{SettingsViewModel.swift => ApplicationSettingsViewModel.swift} (77%) diff --git a/AndroidTools/AndroidTools.xcodeproj/project.pbxproj b/AndroidTools/AndroidTools.xcodeproj/project.pbxproj index e7efb30..1dd8b85 100644 --- a/AndroidTools/AndroidTools.xcodeproj/project.pbxproj +++ b/AndroidTools/AndroidTools.xcodeproj/project.pbxproj @@ -7,14 +7,16 @@ objects = { /* Begin PBXBuildFile section */ + 8109D3602BF12575001A4B5E /* ApplicationSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8109D35F2BF12575001A4B5E /* ApplicationSettingsView.swift */; }; + 8109D3622BF1263C001A4B5E /* AppearanceSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8109D3612BF1263C001A4B5E /* AppearanceSettingsView.swift */; }; + 8109D3642BF128A8001A4B5E /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8109D3632BF128A8001A4B5E /* Constants.swift */; }; + 8109D3662BF141B0001A4B5E /* ApplicationSettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8109D3652BF141B0001A4B5E /* ApplicationSettingsViewModel.swift */; }; 810E8E1A2BE9196500ED561A /* GetConnectedDeviceListUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 810E8E192BE9196500ED561A /* GetConnectedDeviceListUseCase.swift */; }; 810E8E1C2BE92EA800ED561A /* ListFilesUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 810E8E1B2BE92EA800ED561A /* ListFilesUseCase.swift */; }; 810E8E1E2BE92EE600ED561A /* FileExplorerResultModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 810E8E1D2BE92EE600ED561A /* FileExplorerResultModel.swift */; }; 810E8E202BE9311100ED561A /* FileRepositoryImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 810E8E1F2BE9311100ED561A /* FileRepositoryImpl.swift */; }; 810E8E222BE9312B00ED561A /* FileRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 810E8E212BE9312B00ED561A /* FileRepository.swift */; }; 811E65042BDE8C16003528B7 /* SideBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 811E65032BDE8C16003528B7 /* SideBarItem.swift */; }; - 811E65062BDEAAE2003528B7 /* SettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 811E65052BDEAAE2003528B7 /* SettingsViewModel.swift */; }; - 811E650A2BDEAEBC003528B7 /* LargeButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 811E65092BDEAEBC003528B7 /* LargeButtonStyle.swift */; }; 812399C42BDC3C92004219C9 /* Toast.swift in Sources */ = {isa = PBXBuildFile; fileRef = 812399C32BDC3C92004219C9 /* Toast.swift */; }; 812399C62BDC3CA9004219C9 /* ToastStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 812399C52BDC3CA9004219C9 /* ToastStyle.swift */; }; 812399C82BDC3CC7004219C9 /* ToastView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 812399C72BDC3CC7004219C9 /* ToastView.swift */; }; @@ -72,14 +74,16 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 8109D35F2BF12575001A4B5E /* ApplicationSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationSettingsView.swift; sourceTree = ""; }; + 8109D3612BF1263C001A4B5E /* AppearanceSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppearanceSettingsView.swift; sourceTree = ""; }; + 8109D3632BF128A8001A4B5E /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; + 8109D3652BF141B0001A4B5E /* ApplicationSettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationSettingsViewModel.swift; sourceTree = ""; }; 810E8E192BE9196500ED561A /* GetConnectedDeviceListUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetConnectedDeviceListUseCase.swift; sourceTree = ""; }; 810E8E1B2BE92EA800ED561A /* ListFilesUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListFilesUseCase.swift; sourceTree = ""; }; 810E8E1D2BE92EE600ED561A /* FileExplorerResultModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileExplorerResultModel.swift; sourceTree = ""; }; 810E8E1F2BE9311100ED561A /* FileRepositoryImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileRepositoryImpl.swift; sourceTree = ""; }; 810E8E212BE9312B00ED561A /* FileRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileRepository.swift; sourceTree = ""; }; 811E65032BDE8C16003528B7 /* SideBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SideBarItem.swift; sourceTree = ""; }; - 811E65052BDEAAE2003528B7 /* SettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewModel.swift; sourceTree = ""; }; - 811E65092BDEAEBC003528B7 /* LargeButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LargeButtonStyle.swift; sourceTree = ""; }; 812399C32BDC3C92004219C9 /* Toast.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toast.swift; sourceTree = ""; }; 812399C52BDC3CA9004219C9 /* ToastStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToastStyle.swift; sourceTree = ""; }; 812399C72BDC3CC7004219C9 /* ToastView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToastView.swift; sourceTree = ""; }; @@ -155,6 +159,7 @@ children = ( 81E6A7642BC5D7020034EBFB /* AdbHelper.swift */, 814319542BC6B3B100044934 /* Extensions */, + 8109D3632BF128A8001A4B5E /* Constants.swift */, ); path = Commons; sourceTree = ""; @@ -247,7 +252,9 @@ children = ( 816A1D362BE8C7AF00E7DA71 /* Updater */, 81C3FEE02BD2E76000E18035 /* SettingsView.swift */, - 811E65052BDEAAE2003528B7 /* SettingsViewModel.swift */, + 8109D35F2BF12575001A4B5E /* ApplicationSettingsView.swift */, + 8109D3612BF1263C001A4B5E /* AppearanceSettingsView.swift */, + 8109D3652BF141B0001A4B5E /* ApplicationSettingsViewModel.swift */, ); path = Settings; sourceTree = ""; @@ -355,7 +362,6 @@ 81600C8E2BC98F65008D471C /* FileRow.swift */, 812DC7872BDC047E009B2E87 /* TerminalWindow.swift */, 811E65032BDE8C16003528B7 /* SideBarItem.swift */, - 811E65092BDEAEBC003528B7 /* LargeButtonStyle.swift */, ); path = Components; sourceTree = ""; @@ -476,11 +482,13 @@ 81E6A7592BC5CD9D0034EBFB /* DeviceInformationView.swift in Sources */, 81B7900D2BEBA7E5008E7359 /* LogcatViewModel.swift in Sources */, 814319522BC6715B00044934 /* InstallApplicationViewModel.swift in Sources */, + 8109D3662BF141B0001A4B5E /* ApplicationSettingsViewModel.swift in Sources */, 814319562BC6B3C000044934 /* UTTypeExtensions.swift in Sources */, 81E6A7512BC5CC260034EBFB /* MenuView.swift in Sources */, 816A1D452BE8D3A200E7DA71 /* CircleWavesAnimation.swift in Sources */, 81E6A75B2BC5CDC20034EBFB /* FileExplorerView.swift in Sources */, 81E9822F2BDD09E70004B154 /* GetDeviceInformationUseCase.swift in Sources */, + 8109D3642BF128A8001A4B5E /* Constants.swift in Sources */, 81E6A7652BC5D7020034EBFB /* AdbHelper.swift in Sources */, 812DC7882BDC047E009B2E87 /* TerminalWindow.swift in Sources */, 81F41C612BEA995D005F1730 /* ImportFileUseCase.swift in Sources */, @@ -492,10 +500,10 @@ 81D04F5A2BCA4B3400B04FAB /* FolderItem.swift in Sources */, 81F41C5B2BEA4DF4005F1730 /* TableView.swift in Sources */, 816A1D402BE8CDE000E7DA71 /* InstallApplicationError.swift in Sources */, + 8109D3602BF12575001A4B5E /* ApplicationSettingsView.swift in Sources */, 81E982392BDD3B480004B154 /* CheckForUpdateView.swift in Sources */, 810E8E202BE9311100ED561A /* FileRepositoryImpl.swift in Sources */, 81B790112BEBA9E8008E7359 /* LogEntryModel.swift in Sources */, - 811E65062BDEAAE2003528B7 /* SettingsViewModel.swift in Sources */, 81C3FEE12BD2E76000E18035 /* SettingsView.swift in Sources */, 81E6A75D2BC5CDFF0034EBFB /* MenuViewModel.swift in Sources */, 81B7900F2BEBA7F3008E7359 /* LogcatView.swift in Sources */, @@ -516,7 +524,6 @@ 817EE85D2BC8247F00740D4A /* FileItem.swift in Sources */, 811E65042BDE8C16003528B7 /* SideBarItem.swift in Sources */, 816A1D492BE8F67000E7DA71 /* DeviceRepository.swift in Sources */, - 811E650A2BDEAEBC003528B7 /* LargeButtonStyle.swift in Sources */, 81E982312BDD0F190004B154 /* RebootDeviceUseCase.swift in Sources */, 817EE8592BC81D4100740D4A /* FileExplorerViewModel.swift in Sources */, 81E982372BDD3A740004B154 /* CheckForUpdateViewModel.swift in Sources */, @@ -531,6 +538,7 @@ 81F41C5D2BEA7B3D005F1730 /* CreateFolderUseCase.swift in Sources */, 8164F8B02BDE40A70097422C /* UniversalFileDocument.swift in Sources */, 81E6A7682BC5D7200034EBFB /* DeviceListModel.swift in Sources */, + 8109D3622BF1263C001A4B5E /* AppearanceSettingsView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/AndroidTools/AndroidTools/AndroidToolsApp.swift b/AndroidTools/AndroidTools/AndroidToolsApp.swift index 15d60d6..0a74b24 100644 --- a/AndroidTools/AndroidTools/AndroidToolsApp.swift +++ b/AndroidTools/AndroidTools/AndroidToolsApp.swift @@ -11,7 +11,7 @@ import Sparkle @main struct AndroidToolsApp: App { - @AppStorage("mode") private var mode = "Automatic" + @AppStorage("mode") private var mode = Constants.appearanceModes.first! private let updaterController : SPUStandardUpdaterController init(){ @@ -20,9 +20,6 @@ struct AndroidToolsApp: App { var body: some Scene { - - - WindowGroup { SideBarView() .frame(minWidth: 600, minHeight: 400) @@ -36,6 +33,7 @@ struct AndroidToolsApp: App { Settings { SettingsView() + .frame(width: 500, height: 200) .padding() .preferredColorScheme(determineColorScheme(mode)) } diff --git a/AndroidTools/AndroidTools/Commons/AdbHelper.swift b/AndroidTools/AndroidTools/Commons/AdbHelper.swift index d5a16c3..c7ae19f 100644 --- a/AndroidTools/AndroidTools/Commons/AdbHelper.swift +++ b/AndroidTools/AndroidTools/Commons/AdbHelper.swift @@ -49,7 +49,7 @@ class AdbHelper { } func runAdbCommand(_ command: String) -> String { - print("Running command:\n adb \(command)") + print("Running command:\nadb \(command)") let task = Process() let pipe = Pipe() @@ -61,7 +61,7 @@ class AdbHelper { let data = pipe.fileHandleForReading.readDataToEndOfFile() let output = String(data: data, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines) ?? "" - print("Result:\n \(output)") + print("Result:\n\(output)") return output } diff --git a/AndroidTools/AndroidTools/Commons/Constants.swift b/AndroidTools/AndroidTools/Commons/Constants.swift new file mode 100644 index 0000000..96a1c13 --- /dev/null +++ b/AndroidTools/AndroidTools/Commons/Constants.swift @@ -0,0 +1,12 @@ +// +// Constants.swift +// AndroidTools +// +// Created by Thomas Bernard on 12/05/2024. +// + +import Foundation + +class Constants { + static let appearanceModes : [String] = ["Automatic", "Dark", "Light"] +} diff --git a/AndroidTools/AndroidTools/Domain/UseCases/GetAdbVersionUseCase.swift b/AndroidTools/AndroidTools/Domain/UseCases/GetAdbVersionUseCase.swift index 5d16f78..a41f24c 100644 --- a/AndroidTools/AndroidTools/Domain/UseCases/GetAdbVersionUseCase.swift +++ b/AndroidTools/AndroidTools/Domain/UseCases/GetAdbVersionUseCase.swift @@ -12,6 +12,19 @@ class GetAdbVersionUseCase { func execute() -> String { let result = adbHelper.runAdbCommand("version") - return result + + let lines = result.split(separator: "\n") + + // Find the line that starts with "Version" + if let versionLine = lines.first(where: { $0.starts(with: "Version") }) { + + let version = versionLine + .replacingOccurrences(of: "Version ", with: "") + .split(separator: " ") + .first ?? "" + return String(version) + } + + return "" } } diff --git a/AndroidTools/AndroidTools/Presentation/Components/LargeButtonStyle.swift b/AndroidTools/AndroidTools/Presentation/Components/LargeButtonStyle.swift deleted file mode 100644 index 2d72430..0000000 --- a/AndroidTools/AndroidTools/Presentation/Components/LargeButtonStyle.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// LargeButtonStyle.swift -// AndroidTools -// -// Created by Thomas Bernard on 28/04/2024. -// - -import Foundation -import SwiftUI - -struct LargeButtonStyle: ButtonStyle { - func makeBody(configuration: Configuration) -> some View { - configuration.label - .padding(.vertical, 10) - .padding(.horizontal, 20) - .foregroundColor(.white) - .background(configuration.isPressed ? Color.accentColor.opacity(0.5) : Color.accentColor) - .cornerRadius(8) - .scaleEffect(configuration.isPressed ? 0.97 : 1.0) - .animation(.easeOut(duration: 0.2), value: configuration.isPressed) - } -} diff --git a/AndroidTools/AndroidTools/Presentation/Menu/MenuView.swift b/AndroidTools/AndroidTools/Presentation/Menu/MenuView.swift index a0fd9af..b324f64 100644 --- a/AndroidTools/AndroidTools/Presentation/Menu/MenuView.swift +++ b/AndroidTools/AndroidTools/Presentation/Menu/MenuView.swift @@ -60,28 +60,6 @@ struct SideBarView: View { SideBarItem(label:"Files", systemImage: "folder") } .disabled(viewModel.devices.isEmpty) - - NavigationLink(destination: LogcatView(deviceId: viewModel.selectedDevice?.id ?? "")) { - Label { - Text("Logcat") - } icon: { - Image("logcat") - .resizable() - .scaledToFit() - .frame(width: 16, height: 16) - - } - .padding(.vertical, 4) - - } - .disabled(viewModel.devices.isEmpty) - - NavigationLink { - SettingsView() - } label: { - SideBarItem(label:"Settings", systemImage: "gearshape.circle") - } - } .listStyle(SidebarListStyle()) .safeAreaInset(edge: .bottom, spacing: 0) { diff --git a/AndroidTools/AndroidTools/Presentation/Settings/AppearanceSettingsView.swift b/AndroidTools/AndroidTools/Presentation/Settings/AppearanceSettingsView.swift new file mode 100644 index 0000000..a15a608 --- /dev/null +++ b/AndroidTools/AndroidTools/Presentation/Settings/AppearanceSettingsView.swift @@ -0,0 +1,58 @@ +// +// AppearanceSettingsView.swift +// AndroidTools +// +// Created by Thomas Bernard on 12/05/2024. +// + +import SwiftUI + +struct AppearanceSettingsView: View { + + @AppStorage("mode") private var mode = Constants.appearanceModes.first! + private let appIcons: [String] = ["AppIconDark", "AppIconLight", "AppIconAndroid"] + @AppStorage("appIconName") private var appIconName = "AppIconDark" + + var body: some View { + Form { + Picker("Appearance", selection: $mode) { + ForEach(Constants.appearanceModes, id: \.self) { mode in + Text(mode) + if mode == Constants.appearanceModes.first { + Divider() + } + + } + } + + Text("Change application icon ") + + HStack { + ForEach(appIcons, id: \.self) { name in + VStack { + Image(nsImage: NSImage(named: name)!) + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: 60, height: 60) // Highlight the selected icon + } + + .background(appIconName == name ? Color.accentColor : Color.clear) + .cornerRadius(13) + + .onTapGesture { + NSApplication.shared.applicationIconImage = NSImage(named: name) + appIconName = name // Update the selected icon + } + } + + Spacer() + } + + Spacer() + } + } +} + +#Preview { + AppearanceSettingsView() +} diff --git a/AndroidTools/AndroidTools/Presentation/Settings/ApplicationSettingsView.swift b/AndroidTools/AndroidTools/Presentation/Settings/ApplicationSettingsView.swift new file mode 100644 index 0000000..0b63599 --- /dev/null +++ b/AndroidTools/AndroidTools/Presentation/Settings/ApplicationSettingsView.swift @@ -0,0 +1,91 @@ +// +// ApplicationSettingsView.swift +// AndroidTools +// +// Created by Thomas Bernard on 12/05/2024. +// + +import SwiftUI + +struct ApplicationSettingsView: View { + + @StateObject private var viewModel = ApplicationSettingsViewModel() + + @AppStorage("adbPath") private var adbPath = "/usr/local/bin/adb" + + + private func openFinderToSelectADB() { + let panel = NSOpenPanel() + panel.canChooseFiles = true + panel.canChooseDirectories = false + panel.allowsMultipleSelection = false + panel.directoryURL = URL(fileURLWithPath: adbPath) + + panel.begin { response in + if response == .OK, let url = panel.url { + self.adbPath = url.path + viewModel.getAdbVersion() + } + } + } + + + var body: some View { + Form { + VStack(alignment:.center) { + HStack { + if !viewModel.adbVersion.isEmpty { + Image(systemName: "checkmark.circle.fill") + .foregroundColor(.green) + } + else { + Image(systemName: "xmark.circle.fill") + .foregroundColor(.red) + } + + Text("ADB version \(viewModel.adbVersion)") + Spacer() + Button("Check ADB version"){ + viewModel.getAdbVersion() + } + } + + HStack { + TextField("", text:$adbPath) + .disabled(true) + .padding(.leading, -10) + + Button("Change path"){ + openFinderToSelectADB() + } + } + + + + Spacer() + + Divider() + + + HStack { + let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "" + Text("Android Tools v\(appVersion)") + + Spacer() + + Button("Check for updates"){ + viewModel.checkForUpdates() + } + } + .padding(.top, 5) + } + } + .onAppear { + viewModel.getAdbVersion() + } + } +} + +#Preview { + ApplicationSettingsView() +} diff --git a/AndroidTools/AndroidTools/Presentation/Settings/SettingsViewModel.swift b/AndroidTools/AndroidTools/Presentation/Settings/ApplicationSettingsViewModel.swift similarity index 77% rename from AndroidTools/AndroidTools/Presentation/Settings/SettingsViewModel.swift rename to AndroidTools/AndroidTools/Presentation/Settings/ApplicationSettingsViewModel.swift index b0f7da5..8bbac20 100644 --- a/AndroidTools/AndroidTools/Presentation/Settings/SettingsViewModel.swift +++ b/AndroidTools/AndroidTools/Presentation/Settings/ApplicationSettingsViewModel.swift @@ -1,19 +1,18 @@ // -// SettingsViewModel.swift +// ApplicationSettingsViewModel.swift // AndroidTools // -// Created by Thomas Bernard on 28/04/2024. +// Created by Thomas Bernard on 12/05/2024. // import Foundation import Sparkle @Observable -class SettingsViewModel : ObservableObject { +class ApplicationSettingsViewModel : ObservableObject { let updaterController : SPUStandardUpdaterController private let getAdbVersionUseCase : GetAdbVersionUseCase = GetAdbVersionUseCase() - - var adbVersion : String = "" + var adbVersion = "" init(){ updaterController = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil) diff --git a/AndroidTools/AndroidTools/Presentation/Settings/SettingsView.swift b/AndroidTools/AndroidTools/Presentation/Settings/SettingsView.swift index 09d6a4d..59543a7 100644 --- a/AndroidTools/AndroidTools/Presentation/Settings/SettingsView.swift +++ b/AndroidTools/AndroidTools/Presentation/Settings/SettingsView.swift @@ -1,127 +1,26 @@ import SwiftUI struct SettingsView: View { - + private enum Tabs: Hashable { - case general, advanced - } - - @StateObject private var viewModel = SettingsViewModel() - - private let appIcons: [String] = ["AppIconDark", "AppIconLight", "AppIconAndroid"] - private let modes : [String] = ["Automatic", "Dark", "Light"] - - @AppStorage("mode") private var mode = "Automatic" - @AppStorage("appIconName") private var appIconName = "AppIconDark" - - @AppStorage("adbPath") private var adbPath = "/usr/local/bin/adb" - - - // State to track the currently selected icon - @State private var selectedIcon: String = (NSApplication.shared.applicationIconImage.name() ?? "") - - - private func openFinderToSelectADB() { - let panel = NSOpenPanel() - panel.canChooseFiles = true - panel.canChooseDirectories = false - panel.allowsMultipleSelection = false - panel.directoryURL = URL(fileURLWithPath: adbPath) - - panel.begin { response in - if response == .OK, let url = panel.url { - self.adbPath = url.path - viewModel.getAdbVersion() - } - } + case application, appearance } var body: some View { - Form { - Group { - Section(header: Text("Apparence")) { - VStack { - Picker("", selection: $mode) { - ForEach(modes, id: \.self) { mode in - Text(mode) - if mode == modes.first { - Divider() - } - - } - } - .padding(.horizontal) - - ScrollView(.horizontal, showsIndicators: false) { - HStack { - ForEach(appIcons, id: \.self) { name in - VStack { - Image(nsImage: NSImage(named: name)!) - .resizable() - .aspectRatio(contentMode: .fit) - .frame(width: 60, height: 60) // Highlight the selected icon - } - - .background(appIconName == name ? Color.accentColor : Color.clear) - .cornerRadius(13.4) - - .onTapGesture { - NSApplication.shared.applicationIconImage = NSImage(named: name) - appIconName = name // Update the selected icon - } - } - } - .padding() - } - - - } - } - - Section("Application"){ - Button { - viewModel.checkForUpdates() - } label: { - Text("Check for updates") - - }.buttonStyle(LargeButtonStyle()) - - - TextField("", text: $adbPath) - .disabled(true) - - - - HStack { - Button("Change location"){ - openFinderToSelectADB() - } - - Button("Check installation") { - viewModel.getAdbVersion() - } - } - - Text(viewModel.adbVersion) - - - - - + TabView { + ApplicationSettingsView() + .tabItem { + Label("Application", systemImage: "gear") } - } + .tag(Tabs.application) - Spacer() - } - .onAppear { - viewModel.getAdbVersion() + AppearanceSettingsView() + .tabItem { + Label("Appearance", systemImage: "sun.max") + } + .tag(Tabs.appearance) } - - - - } - } struct SettingsView_Previews: PreviewProvider {