use toolbarGroup for create label modal on macOS
This commit is contained in:
@ -153,15 +153,6 @@
|
||||
"version" : "2.1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "pspdfkit-sp",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/PSPDFKit/PSPDFKit-SP",
|
||||
"state" : {
|
||||
"branch" : "master",
|
||||
"revision" : "b7e5465ab62f5b48735145756e371502fa2a24f0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "sovran-swift",
|
||||
"kind" : "remoteSourceControl",
|
||||
|
||||
@ -55,9 +55,9 @@ let package = Package(
|
||||
|
||||
var appPackageDependencies: [Target.Dependency] {
|
||||
var deps: [Target.Dependency] = ["Views", "Services", "Models", "Utils"]
|
||||
// #if canImport(UIKit)
|
||||
deps.append(.product(name: "PSPDFKit", package: "PSPDFKit-SP"))
|
||||
// #endif
|
||||
#if canImport(UIKit)
|
||||
deps.append(.product(name: "PSPDFKit", package: "PSPDFKit-SP"))
|
||||
#endif
|
||||
return deps
|
||||
}
|
||||
|
||||
@ -69,8 +69,8 @@ var dependencies: [Package.Dependency] {
|
||||
.package(url: "git@github.com:segmentio/analytics-swift.git", .upToNextMajor(from: "1.0.0")),
|
||||
.package(url: "https://github.com/google/GoogleSignIn-iOS", from: "6.2.2")
|
||||
]
|
||||
// #if canImport(UIKit)
|
||||
deps.append(.package(url: "https://github.com/PSPDFKit/PSPDFKit-SP", branch: "master"))
|
||||
// #endif
|
||||
#if canImport(UIKit)
|
||||
deps.append(.package(url: "https://github.com/PSPDFKit/PSPDFKit-SP", branch: "master"))
|
||||
#endif
|
||||
return deps
|
||||
}
|
||||
|
||||
@ -37,7 +37,6 @@ struct LabelsView: View {
|
||||
List {
|
||||
innerBody
|
||||
}
|
||||
.listStyle(InsetListStyle())
|
||||
#endif
|
||||
}
|
||||
.task { await viewModel.loadLabels(dataService: dataService, item: nil) }
|
||||
@ -108,81 +107,105 @@ struct CreateLabelView: View {
|
||||
return [firstSwatch] + webSwatches + additionalSwatches
|
||||
}()
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
VStack {
|
||||
HStack {
|
||||
if !newLabelName.isEmpty, newLabelColor != .clear {
|
||||
TextChip(text: newLabelName, color: newLabelColor)
|
||||
} else {
|
||||
Text("Assign a name and color.").font(.appBody)
|
||||
}
|
||||
Spacer()
|
||||
var innerBody: some View {
|
||||
VStack {
|
||||
HStack {
|
||||
if !newLabelName.isEmpty, newLabelColor != .clear {
|
||||
TextChip(text: newLabelName, color: newLabelColor)
|
||||
} else {
|
||||
Text("Assign a name and color.").font(.appBody)
|
||||
}
|
||||
.padding(.bottom, 8)
|
||||
Spacer()
|
||||
}
|
||||
.padding(.bottom, 8)
|
||||
|
||||
TextField("Label Name", text: $newLabelName)
|
||||
#if os(iOS)
|
||||
.keyboardType(.alphabet)
|
||||
#endif
|
||||
.textFieldStyle(StandardTextFieldStyle())
|
||||
TextField("Label Name", text: $newLabelName)
|
||||
#if os(iOS)
|
||||
.keyboardType(.alphabet)
|
||||
#endif
|
||||
.textFieldStyle(StandardTextFieldStyle())
|
||||
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
LazyHGrid(rows: rows, alignment: .top, spacing: 20) {
|
||||
ForEach(swatches, id: \.self) { swatch in
|
||||
ZStack {
|
||||
Circle()
|
||||
.fill(swatch)
|
||||
.frame(width: 50, height: 50)
|
||||
.onTapGesture {
|
||||
newLabelColor = swatch
|
||||
}
|
||||
.padding(10)
|
||||
|
||||
if newLabelColor == swatch {
|
||||
Circle()
|
||||
.stroke(swatch, lineWidth: 5)
|
||||
.frame(width: 60, height: 60)
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
LazyHGrid(rows: rows, alignment: .top, spacing: 20) {
|
||||
ForEach(swatches, id: \.self) { swatch in
|
||||
ZStack {
|
||||
Circle()
|
||||
.fill(swatch)
|
||||
.frame(width: 50, height: 50)
|
||||
.onTapGesture {
|
||||
newLabelColor = swatch
|
||||
}
|
||||
.padding(10)
|
||||
|
||||
if newLabelColor == swatch {
|
||||
Circle()
|
||||
.stroke(swatch, lineWidth: 5)
|
||||
.frame(width: 60, height: 60)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
.padding()
|
||||
.toolbar {
|
||||
Spacer()
|
||||
}
|
||||
.padding()
|
||||
.toolbar {
|
||||
#if os(iOS)
|
||||
ToolbarItem(placement: .barLeading) {
|
||||
Button(
|
||||
action: { viewModel.showCreateEmailModal = false },
|
||||
label: { Text("Cancel").foregroundColor(.appGrayTextContrast) }
|
||||
)
|
||||
cancelCreateLabelButton
|
||||
}
|
||||
ToolbarItem(placement: .barTrailing) {
|
||||
Button(
|
||||
action: {
|
||||
viewModel.createLabel(
|
||||
dataService: dataService,
|
||||
name: newLabelName,
|
||||
color: newLabelColor,
|
||||
description: nil
|
||||
)
|
||||
},
|
||||
label: { Text("Create").foregroundColor(.appGrayTextContrast) }
|
||||
)
|
||||
.opacity(shouldDisableCreateButton ? 0.2 : 1)
|
||||
.disabled(shouldDisableCreateButton)
|
||||
createLabelButton
|
||||
}
|
||||
#else
|
||||
ToolbarItemGroup {
|
||||
createLabelButton
|
||||
cancelCreateLabelButton
|
||||
}
|
||||
}
|
||||
.navigationTitle("Create New Label")
|
||||
#if os(iOS)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
#endif
|
||||
.onAppear {
|
||||
newLabelColor = swatches.first ?? .clear
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var cancelCreateLabelButton: some View {
|
||||
Button(
|
||||
action: { viewModel.showCreateEmailModal = false },
|
||||
label: { Text("Cancel").foregroundColor(.appGrayTextContrast) }
|
||||
)
|
||||
}
|
||||
|
||||
var createLabelButton: some View {
|
||||
Button(
|
||||
action: {
|
||||
viewModel.createLabel(
|
||||
dataService: dataService,
|
||||
name: newLabelName,
|
||||
color: newLabelColor,
|
||||
description: nil
|
||||
)
|
||||
},
|
||||
label: { Text("Create").foregroundColor(.appGrayTextContrast) }
|
||||
)
|
||||
.opacity(shouldDisableCreateButton ? 0.2 : 1)
|
||||
.disabled(shouldDisableCreateButton)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
#if os(iOS)
|
||||
NavigationView {
|
||||
innerBody
|
||||
.navigationTitle("Create New Label")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.task {
|
||||
newLabelColor = swatches.first ?? .clear
|
||||
}
|
||||
}
|
||||
#else
|
||||
innerBody
|
||||
.task {
|
||||
newLabelColor = swatches.first ?? .clear
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private let webSwatchHexes = [
|
||||
|
||||
Reference in New Issue
Block a user