This PR contains the work done to open the *Settings* view and also, implemented the rendering of its tab items. Reviewed-on: #5 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
75 lines
1.8 KiB
Swift
75 lines
1.8 KiB
Swift
//
|
|
// SettingsView.swift
|
|
// Piper ~ App
|
|
//
|
|
// Created by Javier Cicchelli on 13/10/2024.
|
|
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct SettingsView: View {
|
|
|
|
// MARK: Properties
|
|
|
|
@State private var viewModel: SettingsViewModel = .init()
|
|
|
|
// MARK: Body
|
|
|
|
var body: some View {
|
|
Group {
|
|
if #available(macOS 15.0, *) {
|
|
TabView(selection: $viewModel.tabSelected) {
|
|
ForEach(viewModel.tabs) { tabItem in
|
|
Tab(
|
|
tabItem.title,
|
|
systemImage: tabItem.icon,
|
|
value: tabItem
|
|
) {
|
|
switch tabItem {
|
|
case .repositories:
|
|
Text(tabItem.title)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
TabView(selection: $viewModel.tabSelected) {
|
|
ForEach(viewModel.tabs) { tabItem in
|
|
Group {
|
|
switch tabItem {
|
|
case .repositories:
|
|
Text(tabItem.title)
|
|
}
|
|
}
|
|
.tabItem {
|
|
Text(tabItem.title)
|
|
}
|
|
.tag(tabItem)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.scenePadding()
|
|
.frame(
|
|
width: Layout.sizeView.width,
|
|
height: Layout.sizeView.height
|
|
)
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - Layout
|
|
|
|
private extension SettingsView {
|
|
enum Layout {
|
|
static let sizeView = CGSize(width: 350, height: 250)
|
|
}
|
|
}
|
|
|
|
// MARK: - Previews
|
|
|
|
#Preview {
|
|
SettingsView()
|
|
}
|