Implemented the list layout for the repositories for the MenuBarView view in the app target.
This commit is contained in:
parent
b4a6491db7
commit
3ed1cc92f7
@ -361,6 +361,7 @@
|
|||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
@ -417,6 +418,7 @@
|
|||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
SWIFT_COMPILATION_MODE = wholemodule;
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
56
Piper/Resources/Catalogs/Localizable.xcstrings
Normal file
56
Piper/Resources/Catalogs/Localizable.xcstrings
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"sourceLanguage" : "en",
|
||||||
|
"strings" : {
|
||||||
|
"Add Item" : {
|
||||||
|
|
||||||
|
},
|
||||||
|
"Item at %@" : {
|
||||||
|
|
||||||
|
},
|
||||||
|
"menu-bar.item.empty.button.text" : {
|
||||||
|
"localizations" : {
|
||||||
|
"en" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Add a repository to the list"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"menu-bar.item.empty.title.text" : {
|
||||||
|
"localizations" : {
|
||||||
|
"en" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "No repositories have been defined yet."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"menu-bar.section.repositories.button.text" : {
|
||||||
|
"localizations" : {
|
||||||
|
"en" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Add"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"menu-bar.section.repositories.title.text" : {
|
||||||
|
"extractionState" : "manual",
|
||||||
|
"localizations" : {
|
||||||
|
"en" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Repositories"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Select an item" : {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"version" : "1.0"
|
||||||
|
}
|
20
Piper/Sources/Logic/ViewModels/MenuBarViewModel.swift
Normal file
20
Piper/Sources/Logic/ViewModels/MenuBarViewModel.swift
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// MenuBarViewModel.swift
|
||||||
|
// Piper ~ App
|
||||||
|
//
|
||||||
|
// Created by Javier Cicchelli on 06/10/2024.
|
||||||
|
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Observation
|
||||||
|
|
||||||
|
@Observable
|
||||||
|
final class MenuBarViewModel {
|
||||||
|
|
||||||
|
// MARK: Initialisers
|
||||||
|
|
||||||
|
init () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
81
Piper/Sources/UI/Views/MenuBarView.swift
Normal file
81
Piper/Sources/UI/Views/MenuBarView.swift
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
//
|
||||||
|
// MenuBarView.swift
|
||||||
|
// Piper ~ App
|
||||||
|
//
|
||||||
|
// Created by Javier Cicchelli on 06/10/2024.
|
||||||
|
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
import SwiftData
|
||||||
|
|
||||||
|
struct MenuBarView: View {
|
||||||
|
|
||||||
|
// MARK: Properties
|
||||||
|
|
||||||
|
@Query(sort: \Repository.sortOrder)
|
||||||
|
private var repositories: [Repository]
|
||||||
|
|
||||||
|
@State private var viewMode = MenuBarViewModel()
|
||||||
|
|
||||||
|
// MARK: Body
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
List {
|
||||||
|
Section {
|
||||||
|
if repositories.isEmpty {
|
||||||
|
ListItemEmpty(
|
||||||
|
title: "menu-bar.item.empty.title.text",
|
||||||
|
button: "menu-bar.item.empty.button.text"
|
||||||
|
) {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
.frame(height: Layout.heightEmpty)
|
||||||
|
} else {
|
||||||
|
ForEach(repositories) {
|
||||||
|
ListItem(repository: $0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} header: {
|
||||||
|
ListHeader(
|
||||||
|
title: "menu-bar.section.repositories.title.text",
|
||||||
|
button: "menu-bar.section.repositories.button.text",
|
||||||
|
showButton: !repositories.isEmpty
|
||||||
|
) {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.frame(
|
||||||
|
width: Layout.widthView,
|
||||||
|
height: Layout.heightView
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Layout
|
||||||
|
|
||||||
|
private extension MenuBarView {
|
||||||
|
enum Layout {
|
||||||
|
static let heightEmpty = CGFloat(200)
|
||||||
|
static let heightView = CGFloat(260)
|
||||||
|
static let widthView = CGFloat(400)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Previews
|
||||||
|
|
||||||
|
#Preview("Menu Bar view when no repositories found") {
|
||||||
|
MenuBarView()
|
||||||
|
.modelContainer(.preview)
|
||||||
|
}
|
||||||
|
|
||||||
|
#Preview("Menu Bar view when some repositories found") {
|
||||||
|
let container = ModelContainer.preview
|
||||||
|
|
||||||
|
Repository.samples(in: container)
|
||||||
|
|
||||||
|
return MenuBarView()
|
||||||
|
.modelContainer(container)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user