Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions RsyncUI/Views/InspectorViews/Add/AddTaskContentView.swift

This file was deleted.

21 changes: 0 additions & 21 deletions RsyncUI/Views/InspectorViews/Add/AddTaskSectionHeader.swift

This file was deleted.

50 changes: 32 additions & 18 deletions RsyncUI/Views/InspectorViews/Add/AddTaskView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,39 @@ struct AddTaskView: View {

@State var presentglobaltaskview: Bool = false

var showSnapshot: Bool {
selectedconfig?.task == SharedReference.shared.snapshot
}

var body: some View {
AddTaskContentView(updateButton: { updateButton },
trailingslash: { trailingslash },
synchronizeID: { synchronizeID },
catalogSectionView: { catalogSectionView },
remoteuserandserver: { remoteuserandserver },
snapshotView: { snapshotnum },
saveURLSection: { saveURLSection },
showSnapshot: selectedconfig?.task == SharedReference.shared.snapshot)
.onAppear { handleSelectionChange() }
.onSubmit { handleSubmit() }
.onChange(of: rsyncUIdata.profile) { handleProfileChange() }
.onChange(of: selecteduuids) { handleSelectionChange() }
.onChange(of: showAddPopover) { _, isPresented in
if isPresented {
newdata.resetForm()
selectedconfig = nil
}
Form {
trailingslash

synchronizeID
catalogSectionView

remoteuserandserver

if showSnapshot {
snapshotnum
}

saveURLSection

updateButton
}
.formStyle(.grouped)
.padding()
.onAppear { handleSelectionChange() }
.onSubmit { handleSubmit() }
.onChange(of: rsyncUIdata.profile) { handleProfileChange() }
.onChange(of: selecteduuids) { handleSelectionChange() }
.onChange(of: showAddPopover) { _, isPresented in
if isPresented {
newdata.resetForm()
selectedconfig = nil
}
.sheet(isPresented: $showAddPopover) { addTaskSheetView }
}
.sheet(isPresented: $showAddPopover) { addTaskSheetView }
}
}
2 changes: 0 additions & 2 deletions RsyncUI/Views/InspectorViews/Add/OpencatalogView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ struct OpencatalogView: View {
} label: {
Label("Browse", systemImage: catalogs ? "folder" : "doc")
.labelStyle(.iconOnly)
.font(.system(size: 12))
.frame(width: 28, height: 22)
}
.buttonStyle(.bordered)
.help("Browse...")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import SwiftUI

extension AddTaskView {
var synchronizeID: some View {
Section(header: AddTaskSectionHeader(title: "Synchronize ID")) {
Section("Synchronize ID") {
if newdata.selectedconfig == nil {
EditValueScheme(400, "Add synchronize ID", $newdata.backupID)
TextField("Synchronize ID", text: $newdata.backupID)
.focused($focusField, equals: .synchronizeIDField)
.textContentType(.none).submitLabel(.continue)
} else {
EditValueScheme(400, nil, $newdata.backupID)
TextField("Synchronize ID", text: $newdata.backupID)
.focused($focusField, equals: .synchronizeIDField)
.textContentType(.none).submitLabel(.continue)
.onAppear { if let id = newdata.selectedconfig?.backupID { newdata.backupID = id } }
Expand All @@ -26,7 +26,7 @@ extension AddTaskView {
}

var snapshotnum: some View {
Section(header: Text("Snapshot Number").modifier(FixedTag(200, .leading))) {
Section("Snapshot Number") {
EditValueScheme(400, nil, $newdata.snapshotnum)
.focused($focusField, equals: .snapshotnumField)
.textContentType(.none).submitLabel(.return)
Expand All @@ -36,13 +36,13 @@ extension AddTaskView {
}

var localandremotecatalog: some View {
Section(header: AddTaskSectionHeader(title: "Folders")) {
Section("Folders") {
catalogField(catalog: $newdata.localcatalog,
placeholder: "Add Source folder - required",
placeholder: "Source folder (required)",
focus: .localcatalogField,
selectedValue: newdata.selectedconfig?.localCatalog)
catalogField(catalog: $newdata.remotecatalog,
placeholder: "Add Destination folder - required",
placeholder: "Destination folder (required)",
focus: .remotecatalogField,
selectedValue: newdata.selectedconfig?.offsiteCatalog,
showErrorBorder: !newdata.localcatalog.isEmpty && newdata.remotecatalog.isEmpty ||
Expand All @@ -51,13 +51,13 @@ extension AddTaskView {
}

var localandremotecatalogsyncremote: some View {
Section(header: AddTaskSectionHeader(title: "Folders")) {
Section("Folders") {
catalogField(catalog: $newdata.remotecatalog,
placeholder: "Add Source folder - required",
placeholder: "Source Folder (required)",
focus: .remotecatalogField,
selectedValue: newdata.selectedconfig?.offsiteCatalog)
catalogField(catalog: $newdata.localcatalog,
placeholder: "Add Remote folder - required",
placeholder: "Remote Folder (required)",
focus: .localcatalogField,
selectedValue: newdata.selectedconfig?.localCatalog,
showErrorBorder: !newdata.localcatalog.isEmpty && newdata.remotecatalog.isEmpty ||
Expand All @@ -70,12 +70,12 @@ extension AddTaskView {
showErrorBorder: Bool = false) -> some View {
HStack {
if newdata.selectedconfig == nil {
EditValueScheme(400, placeholder, catalog)
TextField(placeholder, text: catalog)
.focused($focusField, equals: focus)
.textContentType(.none).submitLabel(.continue)
.border(showErrorBorder ? Color.red : Color.clear, width: 2)
} else {
EditValueScheme(400, nil, catalog)
TextField(placeholder, text: catalog)
.focused($focusField, equals: focus)
.textContentType(.none).submitLabel(.continue)
.onAppear { if let value = selectedValue { catalog.wrappedValue = value } }
Expand All @@ -86,17 +86,17 @@ extension AddTaskView {
}

var remoteuserandserver: some View {
Section(header: AddTaskSectionHeader(title: "Remote")) {
Section("Remote") {
remoteField(
value: $newdata.remoteuser,
placeholder: "Add remote user",
placeholder: "Remote user",
focus: .remoteuserField,
selectedValue: newdata.selectedconfig?.offsiteUsername,
showErrorBorder: newdata.remoteuser.isEmpty && !newdata.remoteserver.isEmpty
)
remoteField(
value: $newdata.remoteserver,
placeholder: "Add remote server",
placeholder: "Remote server",
focus: .remoteserverField,
selectedValue: newdata.selectedconfig?.offsiteServer,
submitLabel: .return,
Expand All @@ -110,12 +110,12 @@ extension AddTaskView {
showErrorBorder: Bool = false) -> some View {
Group {
if newdata.selectedconfig == nil {
EditValueScheme(400, placeholder, value)
TextField(placeholder, text: value)
.focused($focusField, equals: focus)
.textContentType(.none).submitLabel(submitLabel)
.border(showErrorBorder ? Color.red : Color.clear, width: 2)
} else {
EditValueScheme(400, nil, value)
TextField(placeholder, text: value)
.focused($focusField, equals: focus)
.textContentType(.none).submitLabel(submitLabel)
.onAppear { if let val = selectedValue { value.wrappedValue = val } }
Expand All @@ -128,7 +128,7 @@ extension AddTaskView {
Picker("Trailing /", selection: $newdata.trailingslashoptions) {
ForEach(TrailingSlash.allCases) { Text($0.description).tag($0) }
}
.pickerStyle(DefaultPickerStyle()).frame(width: 180)
.pickerStyle(.menu)
.onChange(of: newdata.trailingslashoptions) {
UserDefaults.standard.set(newdata.trailingslashoptions.rawValue, forKey: "trailingslashoptions")
}
Expand All @@ -139,7 +139,7 @@ extension AddTaskView {
Picker("Action", selection: $newdata.selectedrsynccommand) {
ForEach(TypeofTask.allCases) { Text($0.description).tag($0) }
}
.pickerStyle(DefaultPickerStyle()).frame(width: 180)
.pickerStyle(.menu)
.onChange(of: newdata.selectedrsynccommand) {
UserDefaults.standard.set(newdata.selectedrsynccommand.rawValue, forKey: "selectedrsynccommand")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ extension AddTaskView {
var catalogSectionView: some View {
Group {
if newdata.selectedrsynccommand == .syncremote {
VStack(alignment: .leading) { localandremotecatalogsyncremote }
localandremotecatalogsyncremote
} else {
VStack(alignment: .leading) { localandremotecatalog }
localandremotecatalog
.disabled(selectedconfig?.task == SharedReference.shared.snapshot)
}
}
Expand All @@ -26,17 +26,14 @@ extension AddTaskView {
Text("Add Task")
.font(.title2)

VStack(alignment: .leading, spacing: 12) {

HStack {
pickerselecttypeoftask
trailingslash
}

Form {
pickerselecttypeoftask
trailingslash
synchronizeID
catalogSectionView
remoteuserandserver
}
.formStyle(.grouped)
}
.padding()
.frame(minWidth: 600)
Expand Down
23 changes: 11 additions & 12 deletions RsyncUI/Views/InspectorViews/Add/extensionAddTaskView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,24 @@ extension AddTaskView {

extension AddTaskView {
var updateButton: some View {
ConditionalGlassButton(systemImage: "arrow.down", text: "Update", helpText: "Update task") {
Button("Update", systemImage: "arrow.down") {
Task { @MainActor in
_ = await validateAndUpdate()
}
}
.help("Update task")
}

var saveURLSection: some View {
Section(header: Text("Show save URL").font(.title3).fontWeight(.bold)) {
HStack {
Toggle("", isOn: $newdata.showsaveurls).toggleStyle(.switch)
if newdata.showsaveurls {
ConditionalGlassButton(systemImage: "square.and.arrow.down",
text: "URL Estimate",
helpText: "URL Estimate & Synchronize") {
let data = WidgetURLstrings(urletimate: stringestimate)
Task { @MainActor in
await WriteWidgetsURLStringsJSON.write(data)
}
Group {
Toggle("Show save URL", isOn: $newdata.showsaveurls).toggleStyle(.switch)
if newdata.showsaveurls {
ConditionalGlassButton(systemImage: "square.and.arrow.down",
text: "URL Estimate",
helpText: "URL Estimate & Synchronize") {
let data = WidgetURLstrings(urletimate: stringestimate)
Task { @MainActor in
await WriteWidgetsURLStringsJSON.write(data)
}
}
}
Expand Down