feat: Enhanced tag management with unified search and keyboard handling
- Added search functionality to BookmarkLabelsView with real-time filtering - Implemented custom tag creation with smart suggestions - Unified search and tag selection in ShareBookmarkView - Added keyboard toolbar with 'Done' button for extensions - Implemented notification-based keyboard dismissal for extensions - Added pagination logic to ShareBookmarkViewModel - Created selected tags section with remove functionality - Improved UX with consistent tag management across views - Added proper keyboard handling for iOS extensions
This commit is contained in:
parent
d036c2e658
commit
5b2d177f94
@ -3,6 +3,9 @@
|
|||||||
"strings" : {
|
"strings" : {
|
||||||
"" : {
|
"" : {
|
||||||
|
|
||||||
|
},
|
||||||
|
"(%lld found)" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"%" : {
|
"%" : {
|
||||||
|
|
||||||
@ -51,7 +54,7 @@
|
|||||||
"Add" : {
|
"Add" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Add new tag..." : {
|
"Add custom tag:" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"all" : {
|
"all" : {
|
||||||
@ -67,6 +70,9 @@
|
|||||||
},
|
},
|
||||||
"All available tags" : {
|
"All available tags" : {
|
||||||
|
|
||||||
|
},
|
||||||
|
"All labels selected" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Archive" : {
|
"Archive" : {
|
||||||
|
|
||||||
@ -85,6 +91,9 @@
|
|||||||
},
|
},
|
||||||
"Automatically mark articles as read" : {
|
"Automatically mark articles as read" : {
|
||||||
|
|
||||||
|
},
|
||||||
|
"Available labels" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Cancel" : {
|
"Cancel" : {
|
||||||
|
|
||||||
@ -118,9 +127,6 @@
|
|||||||
},
|
},
|
||||||
"Enter an optional title..." : {
|
"Enter an optional title..." : {
|
||||||
|
|
||||||
},
|
|
||||||
"Enter label..." : {
|
|
||||||
|
|
||||||
},
|
},
|
||||||
"Enter your Readeck server details to get started." : {
|
"Enter your Readeck server details to get started." : {
|
||||||
|
|
||||||
@ -133,6 +139,9 @@
|
|||||||
},
|
},
|
||||||
"Favorite" : {
|
"Favorite" : {
|
||||||
|
|
||||||
|
},
|
||||||
|
"Fertig" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Finished reading?" : {
|
"Finished reading?" : {
|
||||||
|
|
||||||
@ -214,6 +223,9 @@
|
|||||||
},
|
},
|
||||||
"No tags available" : {
|
"No tags available" : {
|
||||||
|
|
||||||
|
},
|
||||||
|
"No tags found" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"OK" : {
|
"OK" : {
|
||||||
|
|
||||||
@ -293,11 +305,17 @@
|
|||||||
},
|
},
|
||||||
"Saving..." : {
|
"Saving..." : {
|
||||||
|
|
||||||
|
},
|
||||||
|
"Search or add new tag..." : {
|
||||||
|
|
||||||
|
},
|
||||||
|
"Search results" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Select a bookmark or tag" : {
|
"Select a bookmark or tag" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Select labels" : {
|
"Selected tags" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Server Endpoint" : {
|
"Server Endpoint" : {
|
||||||
|
|||||||
@ -3,172 +3,298 @@ import SwiftUI
|
|||||||
struct ShareBookmarkView: View {
|
struct ShareBookmarkView: View {
|
||||||
@ObservedObject var viewModel: ShareBookmarkViewModel
|
@ObservedObject var viewModel: ShareBookmarkViewModel
|
||||||
|
|
||||||
|
private func dismissKeyboard() {
|
||||||
|
NotificationCenter.default.post(name: NSNotification.Name("DismissKeyboard"), object: nil)
|
||||||
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(spacing: 0) {
|
ScrollView {
|
||||||
// Logo
|
VStack(spacing: 0) {
|
||||||
Image("readeck")
|
// Logo
|
||||||
.resizable()
|
Image("readeck")
|
||||||
.scaledToFit()
|
.resizable()
|
||||||
.frame(height: 40)
|
.scaledToFit()
|
||||||
.padding(.top, 24)
|
.frame(height: 40)
|
||||||
.opacity(0.9)
|
.padding(.top, 24)
|
||||||
// URL
|
.opacity(0.9)
|
||||||
if let url = viewModel.url {
|
// URL
|
||||||
HStack(spacing: 8) {
|
if let url = viewModel.url {
|
||||||
Image(systemName: "link")
|
HStack(spacing: 8) {
|
||||||
.foregroundColor(.accentColor)
|
Image(systemName: "link")
|
||||||
Text(url)
|
.foregroundColor(.accentColor)
|
||||||
.font(.system(size: 15, weight: .bold, design: .default))
|
Text(url)
|
||||||
.foregroundColor(.accentColor)
|
.font(.system(size: 15, weight: .bold, design: .default))
|
||||||
.lineLimit(2)
|
.foregroundColor(.accentColor)
|
||||||
.truncationMode(.middle)
|
.lineLimit(2)
|
||||||
|
.truncationMode(.middle)
|
||||||
|
}
|
||||||
|
.padding(.top, 8)
|
||||||
|
.padding(.horizontal, 16)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
}
|
}
|
||||||
.padding(.top, 8)
|
// Title
|
||||||
.padding(.horizontal, 16)
|
TextField("Enter an optional title...", text: $viewModel.title)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.font(.system(size: 17, weight: .medium))
|
||||||
}
|
.padding(.horizontal, 10)
|
||||||
// Titel
|
.foregroundColor(.primary)
|
||||||
TextField("Enter an optional title...", text: $viewModel.title)
|
.frame(height: 38)
|
||||||
.font(.system(size: 17, weight: .medium))
|
.background(
|
||||||
.padding(.horizontal, 10)
|
RoundedRectangle(cornerRadius: 12, style: .continuous)
|
||||||
.foregroundColor(.primary)
|
.fill(Color(.secondarySystemGroupedBackground))
|
||||||
.frame(height: 38)
|
.shadow(color: Color.black.opacity(0.04), radius: 2, x: 0, y: 1)
|
||||||
.background(
|
)
|
||||||
RoundedRectangle(cornerRadius: 12, style: .continuous)
|
.overlay(
|
||||||
.fill(Color(.secondarySystemGroupedBackground))
|
RoundedRectangle(cornerRadius: 12, style: .continuous)
|
||||||
.shadow(color: Color.black.opacity(0.04), radius: 2, x: 0, y: 1)
|
.stroke(Color.accentColor.opacity(viewModel.title.isEmpty ? 0.12 : 0.7), lineWidth: viewModel.title.isEmpty ? 1 : 2)
|
||||||
)
|
)
|
||||||
.overlay(
|
.padding(.top, 20)
|
||||||
RoundedRectangle(cornerRadius: 12, style: .continuous)
|
.padding(.horizontal, 16)
|
||||||
.stroke(Color.accentColor.opacity(viewModel.title.isEmpty ? 0.12 : 0.7), lineWidth: viewModel.title.isEmpty ? 1 : 2)
|
.frame(maxWidth: 420)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.toolbar {
|
||||||
|
ToolbarItemGroup(placement: .keyboard) {
|
||||||
|
Spacer()
|
||||||
|
Button("Fertig") {
|
||||||
|
dismissKeyboard()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manual tag entry (always visible)
|
||||||
|
ManualTagEntryView(
|
||||||
|
labels: viewModel.labels,
|
||||||
|
selectedLabels: $viewModel.selectedLabels,
|
||||||
|
searchText: $viewModel.searchText
|
||||||
)
|
)
|
||||||
.padding(.top, 20)
|
.padding(.top, 20)
|
||||||
.padding(.horizontal, 16)
|
.padding(.horizontal, 16)
|
||||||
.frame(maxWidth: 420)
|
|
||||||
.frame(maxWidth: .infinity, alignment: .center)
|
// Unified Labels Section
|
||||||
|
if !viewModel.labels.isEmpty {
|
||||||
// Label Grid
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
if !viewModel.labels.isEmpty {
|
HStack {
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
Text("Available labels")
|
||||||
Text("Select labels")
|
.font(.headline)
|
||||||
.font(.headline)
|
if !viewModel.searchText.isEmpty {
|
||||||
|
Text("(\(viewModel.filteredLabels.count) found)")
|
||||||
|
.font(.caption)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
}
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
|
|
||||||
let pageSize = Constants.Labels.pageSize
|
if viewModel.availableLabels.isEmpty {
|
||||||
let pages = stride(from: 0, to: viewModel.labels.count, by: pageSize).map {
|
// All labels are selected
|
||||||
Array(viewModel.labels[$0..<min($0 + pageSize, viewModel.labels.count)])
|
VStack {
|
||||||
}
|
Image(systemName: "checkmark.circle.fill")
|
||||||
|
.font(.system(size: 40))
|
||||||
TabView {
|
.foregroundColor(.green)
|
||||||
ForEach(Array(pages.enumerated()), id: \.offset) { pageIndex, labelsPage in
|
.padding(.vertical, 20)
|
||||||
LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible())], alignment: .leading, spacing: 8) {
|
Text("All labels selected")
|
||||||
ForEach(labelsPage, id: \.name) { label in
|
.font(.caption)
|
||||||
UnifiedLabelChip(
|
.foregroundColor(.secondary)
|
||||||
label: label.name,
|
}
|
||||||
isSelected: viewModel.selectedLabels.contains(label.name),
|
.frame(maxWidth: .infinity)
|
||||||
isRemovable: false,
|
.frame(height: 180)
|
||||||
onTap: {
|
} else {
|
||||||
if viewModel.selectedLabels.contains(label.name) {
|
// Use pagination from ViewModel
|
||||||
viewModel.selectedLabels.remove(label.name)
|
TabView {
|
||||||
} else {
|
ForEach(Array(viewModel.availableLabelPages.enumerated()), id: \.offset) { pageIndex, labelsPage in
|
||||||
viewModel.selectedLabels.insert(label.name)
|
LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible())], alignment: .leading, spacing: 8) {
|
||||||
}
|
ForEach(labelsPage, id: \.name) { label in
|
||||||
|
UnifiedLabelChip(
|
||||||
|
label: label.name,
|
||||||
|
isSelected: viewModel.selectedLabels.contains(label.name),
|
||||||
|
isRemovable: false,
|
||||||
|
onTap: {
|
||||||
|
if viewModel.selectedLabels.contains(label.name) {
|
||||||
|
viewModel.selectedLabels.remove(label.name)
|
||||||
|
} else {
|
||||||
|
viewModel.selectedLabels.insert(label.name)
|
||||||
|
}
|
||||||
|
viewModel.searchText = ""
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
|
.frame(maxWidth: .infinity, alignment: .top)
|
||||||
|
.padding(.horizontal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, alignment: .top)
|
.tabViewStyle(PageTabViewStyle(indexDisplayMode: viewModel.availableLabelPages.count > 1 ? .automatic : .never))
|
||||||
.padding(.horizontal)
|
.frame(height: 180)
|
||||||
|
.padding(.top, -20)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .automatic))
|
|
||||||
.frame(height: 180)
|
|
||||||
.padding(.top, -20)
|
|
||||||
}
|
|
||||||
.padding(.top, 32)
|
.padding(.top, 32)
|
||||||
.frame(minHeight: 100)
|
.frame(minHeight: 100)
|
||||||
}
|
|
||||||
|
|
||||||
ManualTagEntryView(
|
|
||||||
labels: viewModel.labels,
|
|
||||||
selectedLabels: $viewModel.selectedLabels
|
|
||||||
)
|
|
||||||
.padding(.top, 12)
|
|
||||||
.padding(.horizontal, 16)
|
|
||||||
|
|
||||||
// Status
|
|
||||||
if let status = viewModel.statusMessage {
|
|
||||||
Text(status.emoji + " " + status.text)
|
|
||||||
.font(.system(size: 18, weight: .bold))
|
|
||||||
.foregroundColor(status.isError ? .red : .green)
|
|
||||||
.padding(.top, 32)
|
|
||||||
.padding(.horizontal, 16)
|
|
||||||
}
|
|
||||||
Spacer()
|
|
||||||
// Save Button
|
|
||||||
Button(action: { viewModel.save() }) {
|
|
||||||
if viewModel.isSaving {
|
|
||||||
ProgressView()
|
|
||||||
.progressViewStyle(CircularProgressViewStyle())
|
|
||||||
.frame(maxWidth: .infinity)
|
|
||||||
.padding()
|
|
||||||
} else {
|
|
||||||
Text("Save Bookmark")
|
|
||||||
.font(.system(size: 17, weight: .semibold))
|
|
||||||
.frame(maxWidth: .infinity)
|
|
||||||
.padding()
|
|
||||||
.background(Color.accentColor)
|
|
||||||
.foregroundColor(.white)
|
|
||||||
.cornerRadius(16)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Current selected labels
|
||||||
|
if !viewModel.selectedLabels.isEmpty {
|
||||||
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
|
Text("Selected tags")
|
||||||
|
.font(.headline)
|
||||||
|
.padding(.horizontal)
|
||||||
|
|
||||||
|
LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible())], alignment: .leading, spacing: 8) {
|
||||||
|
ForEach(Array(viewModel.selectedLabels), id: \.self) { label in
|
||||||
|
UnifiedLabelChip(
|
||||||
|
label: label,
|
||||||
|
isSelected: false,
|
||||||
|
isRemovable: true,
|
||||||
|
onTap: {
|
||||||
|
// No action for selected labels
|
||||||
|
},
|
||||||
|
onRemove: {
|
||||||
|
viewModel.selectedLabels.remove(label)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding(.horizontal)
|
||||||
|
}
|
||||||
|
.padding(.top, 20)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Status
|
||||||
|
if let status = viewModel.statusMessage {
|
||||||
|
Text(status.emoji + " " + status.text)
|
||||||
|
.font(.system(size: 18, weight: .bold))
|
||||||
|
.foregroundColor(status.isError ? .red : .green)
|
||||||
|
.padding(.top, 32)
|
||||||
|
.padding(.horizontal, 16)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save Button
|
||||||
|
Button(action: { viewModel.save() }) {
|
||||||
|
if viewModel.isSaving {
|
||||||
|
ProgressView()
|
||||||
|
.progressViewStyle(CircularProgressViewStyle())
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.padding()
|
||||||
|
} else {
|
||||||
|
Text("Save Bookmark")
|
||||||
|
.font(.system(size: 17, weight: .semibold))
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.padding()
|
||||||
|
.background(Color.accentColor)
|
||||||
|
.foregroundColor(.white)
|
||||||
|
.cornerRadius(16)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding(.horizontal, 16)
|
||||||
|
.padding(.top, 32)
|
||||||
|
.padding(.bottom, 32)
|
||||||
|
.disabled(viewModel.isSaving)
|
||||||
}
|
}
|
||||||
.padding(.horizontal, 16)
|
|
||||||
.padding(.bottom, 32)
|
|
||||||
.disabled(viewModel.isSaving)
|
|
||||||
}
|
}
|
||||||
.background(Color(.systemGroupedBackground))
|
.background(Color(.systemGroupedBackground))
|
||||||
.onAppear { viewModel.onAppear() }
|
.onAppear { viewModel.onAppear() }
|
||||||
|
.ignoresSafeArea(.keyboard, edges: .bottom)
|
||||||
|
.background(
|
||||||
|
Color.clear
|
||||||
|
.contentShape(Rectangle())
|
||||||
|
.onTapGesture {
|
||||||
|
// Fallback for extensions: tap anywhere to dismiss keyboard
|
||||||
|
dismissKeyboard()
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ManualTagEntryView: View {
|
struct ManualTagEntryView: View {
|
||||||
let labels: [BookmarkLabelDto]
|
let labels: [BookmarkLabelDto]
|
||||||
@Binding var selectedLabels: Set<String>
|
@Binding var selectedLabels: Set<String>
|
||||||
@State private var manualTag: String = ""
|
@Binding var searchText: String
|
||||||
@State private var error: String? = nil
|
@State private var error: String? = nil
|
||||||
|
|
||||||
|
private func dismissKeyboard() {
|
||||||
|
NotificationCenter.default.post(name: NSNotification.Name("DismissKeyboard"), object: nil)
|
||||||
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
HStack {
|
// Search field
|
||||||
TextField("Add new tag...", text: $manualTag)
|
TextField("Search or add new tag...", text: $searchText)
|
||||||
.textFieldStyle(RoundedBorderTextFieldStyle())
|
.textFieldStyle(RoundedBorderTextFieldStyle())
|
||||||
.autocapitalization(.none)
|
.autocapitalization(.none)
|
||||||
.disableAutocorrection(true)
|
.disableAutocorrection(true)
|
||||||
Button(action: addTag) {
|
.toolbar {
|
||||||
Text("Add")
|
ToolbarItemGroup(placement: .keyboard) {
|
||||||
.font(.system(size: 15, weight: .semibold))
|
Spacer()
|
||||||
|
Button("Fertig") {
|
||||||
|
dismissKeyboard()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.disabled(manualTag.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
|
.onSubmit {
|
||||||
|
addCustomTag()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show custom tag suggestion if search text doesn't match existing tags
|
||||||
|
if !searchText.isEmpty && !labels.contains(where: { $0.name.lowercased() == searchText.lowercased() }) {
|
||||||
|
HStack {
|
||||||
|
VStack(alignment: .leading, spacing: 4) {
|
||||||
|
Text("Add new tag:")
|
||||||
|
.font(.subheadline)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
Text(searchText)
|
||||||
|
.font(.headline)
|
||||||
|
.fontWeight(.medium)
|
||||||
|
}
|
||||||
|
Spacer()
|
||||||
|
Button(action: addCustomTag) {
|
||||||
|
HStack(spacing: 6) {
|
||||||
|
Image(systemName: "plus.circle.fill")
|
||||||
|
.font(.title3)
|
||||||
|
Text("Add")
|
||||||
|
.font(.subheadline)
|
||||||
|
.fontWeight(.medium)
|
||||||
|
}
|
||||||
|
.padding(.horizontal, 16)
|
||||||
|
.padding(.vertical, 8)
|
||||||
|
.background(Color.accentColor)
|
||||||
|
.foregroundColor(.white)
|
||||||
|
.cornerRadius(8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding(.horizontal, 12)
|
||||||
|
.padding(.vertical, 12)
|
||||||
|
.background(Color.accentColor.opacity(0.1))
|
||||||
|
.cornerRadius(10)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let error = error {
|
if let error = error {
|
||||||
Text(error)
|
Text(error)
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
.foregroundColor(.red)
|
.foregroundColor(.red)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.background(
|
||||||
|
Color.clear
|
||||||
|
.contentShape(Rectangle())
|
||||||
|
.onTapGesture {
|
||||||
|
// Fallback for extensions: tap anywhere to dismiss keyboard
|
||||||
|
dismissKeyboard()
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func addTag() {
|
private func addCustomTag() {
|
||||||
let trimmed = manualTag.trimmingCharacters(in: .whitespacesAndNewlines)
|
let trimmed = searchText.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
guard !trimmed.isEmpty else { return }
|
guard !trimmed.isEmpty else { return }
|
||||||
|
|
||||||
let lowercased = trimmed.lowercased()
|
let lowercased = trimmed.lowercased()
|
||||||
let allExisting = Set(labels.map { $0.name.lowercased() })
|
let allExisting = Set(labels.map { $0.name.lowercased() })
|
||||||
let allSelected = Set(selectedLabels.map { $0.lowercased() })
|
let allSelected = Set(selectedLabels.map { $0.lowercased() })
|
||||||
|
|
||||||
if allExisting.contains(lowercased) || allSelected.contains(lowercased) {
|
if allExisting.contains(lowercased) || allSelected.contains(lowercased) {
|
||||||
error = "Tag already exists."
|
error = "Tag already exists."
|
||||||
} else {
|
} else {
|
||||||
selectedLabels.insert(trimmed)
|
selectedLabels.insert(trimmed)
|
||||||
manualTag = ""
|
searchText = ""
|
||||||
error = nil
|
error = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,35 @@ class ShareBookmarkViewModel: ObservableObject {
|
|||||||
@Published var selectedLabels: Set<String> = []
|
@Published var selectedLabels: Set<String> = []
|
||||||
@Published var statusMessage: (text: String, isError: Bool, emoji: String)? = nil
|
@Published var statusMessage: (text: String, isError: Bool, emoji: String)? = nil
|
||||||
@Published var isSaving: Bool = false
|
@Published var isSaving: Bool = false
|
||||||
private weak var extensionContext: NSExtensionContext?
|
@Published var searchText: String = ""
|
||||||
|
let extensionContext: NSExtensionContext?
|
||||||
|
|
||||||
|
// Computed properties for pagination
|
||||||
|
var availableLabels: [BookmarkLabelDto] {
|
||||||
|
return labels.filter { !selectedLabels.contains($0.name) }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Computed property for filtered labels based on search text
|
||||||
|
var filteredLabels: [BookmarkLabelDto] {
|
||||||
|
if searchText.isEmpty {
|
||||||
|
return availableLabels
|
||||||
|
} else {
|
||||||
|
return availableLabels.filter { $0.name.localizedCaseInsensitiveContains(searchText) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var availableLabelPages: [[BookmarkLabelDto]] {
|
||||||
|
let pageSize = Constants.Labels.pageSize
|
||||||
|
let labelsToShow = searchText.isEmpty ? availableLabels : filteredLabels
|
||||||
|
|
||||||
|
if labelsToShow.count <= pageSize {
|
||||||
|
return [labelsToShow]
|
||||||
|
} else {
|
||||||
|
return stride(from: 0, to: labelsToShow.count, by: pageSize).map {
|
||||||
|
Array(labelsToShow[$0..<min($0 + pageSize, labelsToShow.count)])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
init(extensionContext: NSExtensionContext?) {
|
init(extensionContext: NSExtensionContext?) {
|
||||||
self.extensionContext = extensionContext
|
self.extensionContext = extensionContext
|
||||||
|
|||||||
@ -30,5 +30,20 @@ class ShareViewController: UIViewController {
|
|||||||
])
|
])
|
||||||
hostingController.didMove(toParent: self)
|
hostingController.didMove(toParent: self)
|
||||||
self.hostingController = hostingController
|
self.hostingController = hostingController
|
||||||
|
|
||||||
|
NotificationCenter.default.addObserver(
|
||||||
|
self,
|
||||||
|
selector: #selector(dismissKeyboard),
|
||||||
|
name: NSNotification.Name("DismissKeyboard"),
|
||||||
|
object: nil
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func dismissKeyboard() {
|
||||||
|
self.view.endEditing(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
NotificationCenter.default.removeObserver(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,7 @@ struct Settings {
|
|||||||
var fontSize: FontSize? = nil
|
var fontSize: FontSize? = nil
|
||||||
var hasFinishedSetup: Bool = false
|
var hasFinishedSetup: Bool = false
|
||||||
var enableTTS: Bool? = nil
|
var enableTTS: Bool? = nil
|
||||||
|
var theme: Theme? = nil
|
||||||
|
|
||||||
var isLoggedIn: Bool {
|
var isLoggedIn: Bool {
|
||||||
token != nil && !token!.isEmpty
|
token != nil && !token!.isEmpty
|
||||||
@ -74,6 +75,10 @@ class SettingsRepository: PSettingsRepository {
|
|||||||
existingSettings.enableTTS = enableTTS
|
existingSettings.enableTTS = enableTTS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let theme = settings.theme {
|
||||||
|
existingSettings.theme = theme.rawValue
|
||||||
|
}
|
||||||
|
|
||||||
try context.save()
|
try context.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +109,8 @@ class SettingsRepository: PSettingsRepository {
|
|||||||
token: settingEntity.token,
|
token: settingEntity.token,
|
||||||
fontFamily: FontFamily(rawValue: settingEntity.fontFamily ?? FontFamily.system.rawValue),
|
fontFamily: FontFamily(rawValue: settingEntity.fontFamily ?? FontFamily.system.rawValue),
|
||||||
fontSize: FontSize(rawValue: settingEntity.fontSize ?? FontSize.medium.rawValue),
|
fontSize: FontSize(rawValue: settingEntity.fontSize ?? FontSize.medium.rawValue),
|
||||||
enableTTS: settingEntity.enableTTS
|
enableTTS: settingEntity.enableTTS,
|
||||||
|
theme: Theme(rawValue: settingEntity.theme ?? Theme.system.rawValue)
|
||||||
)
|
)
|
||||||
continuation.resume(returning: settings)
|
continuation.resume(returning: settings)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -6,6 +6,8 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
enum Theme: String, CaseIterable {
|
enum Theme: String, CaseIterable {
|
||||||
case system = "system"
|
case system = "system"
|
||||||
case light = "light"
|
case light = "light"
|
||||||
@ -18,4 +20,12 @@ enum Theme: String, CaseIterable {
|
|||||||
case .dark: return "Dark"
|
case .dark: return "Dark"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var colorScheme: ColorScheme? {
|
||||||
|
switch self {
|
||||||
|
case .system: return nil
|
||||||
|
case .light: return .light
|
||||||
|
case .dark: return .dark
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -6,6 +6,7 @@ protocol PSaveSettingsUseCase {
|
|||||||
func execute(token: String) async throws
|
func execute(token: String) async throws
|
||||||
func execute(selectedFontFamily: FontFamily, selectedFontSize: FontSize) async throws
|
func execute(selectedFontFamily: FontFamily, selectedFontSize: FontSize) async throws
|
||||||
func execute(enableTTS: Bool) async throws
|
func execute(enableTTS: Bool) async throws
|
||||||
|
func execute(theme: Theme) async throws
|
||||||
}
|
}
|
||||||
|
|
||||||
class SaveSettingsUseCase: PSaveSettingsUseCase {
|
class SaveSettingsUseCase: PSaveSettingsUseCase {
|
||||||
@ -58,4 +59,10 @@ class SaveSettingsUseCase: PSaveSettingsUseCase {
|
|||||||
.init(enableTTS: enableTTS)
|
.init(enableTTS: enableTTS)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func execute(theme: Theme) async throws {
|
||||||
|
try await settingsRepository.saveSettings(
|
||||||
|
.init(theme: theme)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,6 +17,8 @@
|
|||||||
<dict>
|
<dict>
|
||||||
<key>NSAllowsLocalNetworking</key>
|
<key>NSAllowsLocalNetworking</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>NSExceptionRequiresForwardSecrecy</key>
|
||||||
|
<false/>
|
||||||
</dict>
|
</dict>
|
||||||
<key>UIBackgroundModes</key>
|
<key>UIBackgroundModes</key>
|
||||||
<array>
|
<array>
|
||||||
|
|||||||
@ -16,35 +16,69 @@ struct BookmarkLabelsView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationView {
|
NavigationView {
|
||||||
VStack(spacing: 12) {
|
VStack(spacing: 12) {
|
||||||
// Add new label
|
// Add new label with search functionality
|
||||||
HStack(spacing: 12) {
|
VStack(spacing: 8) {
|
||||||
TextField("Enter label...", text: $viewModel.newLabelText)
|
HStack(spacing: 12) {
|
||||||
.textFieldStyle(RoundedBorderTextFieldStyle())
|
TextField("Search or add new tag...", text: $viewModel.searchText)
|
||||||
.onSubmit {
|
.textFieldStyle(RoundedBorderTextFieldStyle())
|
||||||
Task {
|
.onSubmit {
|
||||||
await viewModel.addLabel(to: bookmarkId, label: viewModel.newLabelText)
|
Task {
|
||||||
|
await viewModel.addLabel(to: bookmarkId, label: viewModel.searchText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Button(action: {
|
||||||
|
Task {
|
||||||
|
await viewModel.addLabel(to: bookmarkId, label: viewModel.searchText)
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
Image(systemName: "plus.circle.fill")
|
||||||
|
.font(.title2)
|
||||||
|
.frame(width: 32, height: 32)
|
||||||
}
|
}
|
||||||
|
.disabled(viewModel.searchText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || viewModel.isLoading)
|
||||||
Button(action: {
|
.foregroundColor(.accentColor)
|
||||||
Task {
|
}
|
||||||
await viewModel.addLabel(to: bookmarkId, label: viewModel.newLabelText)
|
|
||||||
}
|
// Show custom tag suggestion if search text doesn't match existing tags
|
||||||
}) {
|
if !viewModel.searchText.isEmpty && !viewModel.filteredLabels.contains(where: { $0.name.lowercased() == viewModel.searchText.lowercased() }) {
|
||||||
Image(systemName: "plus.circle.fill")
|
HStack {
|
||||||
.font(.title2)
|
Text("Add new tag:")
|
||||||
.frame(width: 32, height: 32)
|
.font(.caption)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
Text(viewModel.searchText)
|
||||||
|
.font(.caption)
|
||||||
|
.fontWeight(.medium)
|
||||||
|
Spacer()
|
||||||
|
Button("Add") {
|
||||||
|
Task {
|
||||||
|
await viewModel.addLabel(to: bookmarkId, label: viewModel.searchText)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.font(.caption)
|
||||||
|
.foregroundColor(.accentColor)
|
||||||
|
}
|
||||||
|
.padding(.horizontal, 8)
|
||||||
|
.padding(.vertical, 4)
|
||||||
|
.background(Color.accentColor.opacity(0.1))
|
||||||
|
.cornerRadius(6)
|
||||||
}
|
}
|
||||||
.disabled(viewModel.newLabelText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || viewModel.isLoading)
|
|
||||||
.foregroundColor(.accentColor)
|
|
||||||
}
|
}
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
|
|
||||||
// All available labels
|
// All available labels
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
Text("All available tags")
|
HStack {
|
||||||
.font(.headline)
|
Text(viewModel.searchText.isEmpty ? "All available tags" : "Search results")
|
||||||
.padding(.horizontal)
|
.font(.headline)
|
||||||
|
if !viewModel.searchText.isEmpty {
|
||||||
|
Text("(\(viewModel.filteredLabels.count) found)")
|
||||||
|
.font(.caption)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
}
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
.padding(.horizontal)
|
||||||
|
|
||||||
if viewModel.isInitialLoading {
|
if viewModel.isInitialLoading {
|
||||||
// Loading state
|
// Loading state
|
||||||
@ -58,14 +92,14 @@ struct BookmarkLabelsView: View {
|
|||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity)
|
.frame(maxWidth: .infinity)
|
||||||
.frame(height: 180)
|
.frame(height: 180)
|
||||||
} else if viewModel.allLabels.isEmpty {
|
} else if viewModel.availableLabelPages.isEmpty {
|
||||||
// Empty state
|
// Empty state
|
||||||
VStack {
|
VStack {
|
||||||
Image(systemName: "tag")
|
Image(systemName: viewModel.searchText.isEmpty ? "tag" : "magnifyingglass")
|
||||||
.font(.system(size: 40))
|
.font(.system(size: 40))
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
.padding(.vertical, 20)
|
.padding(.vertical, 20)
|
||||||
Text("No tags available")
|
Text(viewModel.searchText.isEmpty ? "No tags available" : "No tags found")
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,11 @@ class BookmarkLabelsViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var newLabelText = ""
|
var newLabelText = ""
|
||||||
|
var searchText = "" {
|
||||||
|
didSet {
|
||||||
|
calculatePages()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var allLabels: [BookmarkLabel] = [] {
|
var allLabels: [BookmarkLabel] = [] {
|
||||||
didSet {
|
didSet {
|
||||||
@ -30,6 +35,15 @@ class BookmarkLabelsViewModel {
|
|||||||
return allLabels.filter { currentLabels.contains($0.name) == false }
|
return allLabels.filter { currentLabels.contains($0.name) == false }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Computed property for filtered labels based on search text
|
||||||
|
var filteredLabels: [BookmarkLabel] {
|
||||||
|
if searchText.isEmpty {
|
||||||
|
return availableLabels
|
||||||
|
} else {
|
||||||
|
return availableLabels.filter { $0.name.localizedCaseInsensitiveContains(searchText) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var availableLabelPages: [[BookmarkLabel]] = []
|
var availableLabelPages: [[BookmarkLabel]] = []
|
||||||
|
|
||||||
init(_ factory: UseCaseFactory = DefaultUseCaseFactory.shared, initialLabels: [String] = []) {
|
init(_ factory: UseCaseFactory = DefaultUseCaseFactory.shared, initialLabels: [String] = []) {
|
||||||
@ -85,6 +99,7 @@ class BookmarkLabelsViewModel {
|
|||||||
|
|
||||||
await addLabels(to: bookmarkId, labels: [trimmedLabel])
|
await addLabels(to: bookmarkId, labels: [trimmedLabel])
|
||||||
newLabelText = ""
|
newLabelText = ""
|
||||||
|
searchText = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
@ -142,13 +157,14 @@ class BookmarkLabelsViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate pages for available labels (excluding current labels)
|
// Calculate pages for filtered labels (search results or available labels)
|
||||||
if availableLabels.count <= pageSize {
|
let labelsToShow = searchText.isEmpty ? availableLabels : filteredLabels
|
||||||
availableLabelPages = [availableLabels]
|
if labelsToShow.count <= pageSize {
|
||||||
|
availableLabelPages = [labelsToShow]
|
||||||
} else {
|
} else {
|
||||||
// Normal pagination for larger datasets
|
// Normal pagination for larger datasets
|
||||||
availableLabelPages = stride(from: 0, to: availableLabels.count, by: pageSize).map {
|
availableLabelPages = stride(from: 0, to: labelsToShow.count, by: pageSize).map {
|
||||||
Array(availableLabels[$0..<min($0 + pageSize, availableLabels.count)])
|
Array(labelsToShow[$0..<min($0 + pageSize, labelsToShow.count)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -270,6 +270,7 @@ struct WebView: UIViewRepresentable {
|
|||||||
class WebViewCoordinator: NSObject, WKNavigationDelegate, WKScriptMessageHandler {
|
class WebViewCoordinator: NSObject, WKNavigationDelegate, WKScriptMessageHandler {
|
||||||
var onHeightChange: ((CGFloat) -> Void)?
|
var onHeightChange: ((CGFloat) -> Void)?
|
||||||
var onScroll: ((Double) -> Void)?
|
var onScroll: ((Double) -> Void)?
|
||||||
|
var hasHeightUpdate: Bool = false
|
||||||
|
|
||||||
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
||||||
if navigationAction.navigationType == .linkActivated {
|
if navigationAction.navigationType == .linkActivated {
|
||||||
@ -297,6 +298,4 @@ class WebViewCoordinator: NSObject, WKNavigationDelegate, WKScriptMessageHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasHeightUpdate: Bool = false
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -137,6 +137,7 @@ class MockSaveSettingsUseCase: PSaveSettingsUseCase {
|
|||||||
func execute(token: String) async throws {}
|
func execute(token: String) async throws {}
|
||||||
func execute(selectedFontFamily: FontFamily, selectedFontSize: FontSize) async throws {}
|
func execute(selectedFontFamily: FontFamily, selectedFontSize: FontSize) async throws {}
|
||||||
func execute(enableTTS: Bool) async throws {}
|
func execute(enableTTS: Bool) async throws {}
|
||||||
|
func execute(theme: Theme) async throws {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockGetBookmarkUseCase: PGetBookmarkUseCase {
|
class MockGetBookmarkUseCase: PGetBookmarkUseCase {
|
||||||
|
|||||||
@ -22,6 +22,10 @@ class AppSettings: ObservableObject {
|
|||||||
var enableTTS: Bool {
|
var enableTTS: Bool {
|
||||||
settings?.enableTTS ?? false
|
settings?.enableTTS ?? false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var theme: Theme {
|
||||||
|
settings?.theme ?? .system
|
||||||
|
}
|
||||||
|
|
||||||
init(settings: Settings? = nil) {
|
init(settings: Settings? = nil) {
|
||||||
self.settings = settings
|
self.settings = settings
|
||||||
|
|||||||
@ -18,19 +18,21 @@ struct SettingsContainerView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
LazyVStack(spacing: 20) {
|
LazyVStack(spacing: 20) {
|
||||||
SettingsServerView()
|
|
||||||
.cardStyle()
|
|
||||||
|
|
||||||
FontSettingsView()
|
FontSettingsView()
|
||||||
.cardStyle()
|
.cardStyle()
|
||||||
|
|
||||||
SettingsGeneralView()
|
SettingsGeneralView()
|
||||||
.cardStyle()
|
.cardStyle()
|
||||||
|
|
||||||
|
SettingsServerView()
|
||||||
|
.cardStyle()
|
||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
.background(Color(.systemGroupedBackground))
|
.background(Color(.systemGroupedBackground))
|
||||||
|
|
||||||
AppInfo()
|
AppInfo()
|
||||||
|
|
||||||
|
Spacer()
|
||||||
}
|
}
|
||||||
.background(Color(.systemGroupedBackground))
|
.background(Color(.systemGroupedBackground))
|
||||||
.navigationTitle("Settings")
|
.navigationTitle("Settings")
|
||||||
|
|||||||
@ -29,6 +29,11 @@ struct SettingsGeneralView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.pickerStyle(.segmented)
|
.pickerStyle(.segmented)
|
||||||
|
.onChange(of: viewModel.selectedTheme) {
|
||||||
|
Task {
|
||||||
|
await viewModel.saveGeneralSettings()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VStack(alignment: .leading, spacing: 12) {
|
VStack(alignment: .leading, spacing: 12) {
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class SettingsGeneralViewModel {
|
|||||||
do {
|
do {
|
||||||
if let settings = try await loadSettingsUseCase.execute() {
|
if let settings = try await loadSettingsUseCase.execute() {
|
||||||
enableTTS = settings.enableTTS ?? false
|
enableTTS = settings.enableTTS ?? false
|
||||||
selectedTheme = .system
|
selectedTheme = settings.theme ?? .system
|
||||||
autoSyncEnabled = false
|
autoSyncEnabled = false
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
@ -47,7 +47,12 @@ class SettingsGeneralViewModel {
|
|||||||
func saveGeneralSettings() async {
|
func saveGeneralSettings() async {
|
||||||
do {
|
do {
|
||||||
try await saveSettingsUseCase.execute(enableTTS: enableTTS)
|
try await saveSettingsUseCase.execute(enableTTS: enableTTS)
|
||||||
|
try await saveSettingsUseCase.execute(theme: selectedTheme)
|
||||||
|
|
||||||
successMessage = "Settings saved"
|
successMessage = "Settings saved"
|
||||||
|
|
||||||
|
// send notification to apply settings to the app
|
||||||
|
NotificationCenter.default.post(name: NSNotification.Name("SettingsChanged"), object: nil)
|
||||||
} catch {
|
} catch {
|
||||||
errorMessage = "Error saving settings"
|
errorMessage = "Error saving settings"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,43 +34,61 @@ struct SettingsServerView: View {
|
|||||||
VStack(alignment: .leading, spacing: 6) {
|
VStack(alignment: .leading, spacing: 6) {
|
||||||
Text("Server Endpoint")
|
Text("Server Endpoint")
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
TextField("https://readeck.example.com", text: $viewModel.endpoint)
|
if viewModel.isSetupMode {
|
||||||
.textFieldStyle(.roundedBorder)
|
TextField("https://readeck.example.com", text: $viewModel.endpoint)
|
||||||
.keyboardType(.URL)
|
.textFieldStyle(.roundedBorder)
|
||||||
.autocapitalization(.none)
|
.keyboardType(.URL)
|
||||||
.disableAutocorrection(true)
|
.autocapitalization(.none)
|
||||||
.disabled(!viewModel.isSetupMode)
|
.disableAutocorrection(true)
|
||||||
.onChange(of: viewModel.endpoint) {
|
.onChange(of: viewModel.endpoint) {
|
||||||
if viewModel.isSetupMode {
|
|
||||||
viewModel.clearMessages()
|
viewModel.clearMessages()
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
HStack {
|
||||||
|
Image(systemName: "server.rack")
|
||||||
|
.foregroundColor(.accentColor)
|
||||||
|
Text(viewModel.endpoint.isEmpty ? "Not set" : viewModel.endpoint)
|
||||||
|
.foregroundColor(viewModel.endpoint.isEmpty ? .secondary : .primary)
|
||||||
|
Spacer()
|
||||||
}
|
}
|
||||||
|
.padding(.horizontal, 12)
|
||||||
|
.padding(.vertical, 8)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
VStack(alignment: .leading, spacing: 6) {
|
VStack(alignment: .leading, spacing: 6) {
|
||||||
Text("Username")
|
Text("Username")
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
TextField("Your Username", text: $viewModel.username)
|
if viewModel.isSetupMode {
|
||||||
.textFieldStyle(.roundedBorder)
|
TextField("Your Username", text: $viewModel.username)
|
||||||
.autocapitalization(.none)
|
.textFieldStyle(.roundedBorder)
|
||||||
.disableAutocorrection(true)
|
.autocapitalization(.none)
|
||||||
.disabled(!viewModel.isSetupMode)
|
.disableAutocorrection(true)
|
||||||
.onChange(of: viewModel.username) {
|
.onChange(of: viewModel.username) {
|
||||||
if viewModel.isSetupMode {
|
|
||||||
viewModel.clearMessages()
|
viewModel.clearMessages()
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
HStack {
|
||||||
|
Image(systemName: "person.circle.fill")
|
||||||
|
.foregroundColor(.accentColor)
|
||||||
|
Text(viewModel.username.isEmpty ? "Not set" : viewModel.username)
|
||||||
|
.foregroundColor(viewModel.username.isEmpty ? .secondary : .primary)
|
||||||
|
Spacer()
|
||||||
}
|
}
|
||||||
|
.padding(.horizontal, 12)
|
||||||
|
.padding(.vertical, 8)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
VStack(alignment: .leading, spacing: 6) {
|
if viewModel.isSetupMode {
|
||||||
Text("Password")
|
VStack(alignment: .leading, spacing: 6) {
|
||||||
.font(.headline)
|
Text("Password")
|
||||||
SecureField("Your Password", text: $viewModel.password)
|
.font(.headline)
|
||||||
.textFieldStyle(.roundedBorder)
|
|
||||||
.disabled(!viewModel.isSetupMode)
|
SecureField("Your Password", text: $viewModel.password)
|
||||||
.onChange(of: viewModel.password) {
|
.textFieldStyle(.roundedBorder)
|
||||||
if viewModel.isSetupMode {
|
.onChange(of: viewModel.password) {
|
||||||
viewModel.clearMessages()
|
viewModel.clearMessages()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,7 @@ struct readeckApp: App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.environmentObject(appSettings)
|
.environmentObject(appSettings)
|
||||||
|
.preferredColorScheme(appSettings.theme.colorScheme)
|
||||||
.onAppear {
|
.onAppear {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
NFX.sharedInstance().start()
|
NFX.sharedInstance().start()
|
||||||
@ -37,6 +38,11 @@ struct readeckApp: App {
|
|||||||
await loadSetupStatus()
|
await loadSetupStatus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.onReceive(NotificationCenter.default.publisher(for: NSNotification.Name("SettingsChanged"))) { _ in
|
||||||
|
Task {
|
||||||
|
await loadSetupStatus()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
<attribute name="fontFamily" optional="YES" attributeType="String"/>
|
<attribute name="fontFamily" optional="YES" attributeType="String"/>
|
||||||
<attribute name="fontSize" optional="YES" attributeType="String"/>
|
<attribute name="fontSize" optional="YES" attributeType="String"/>
|
||||||
<attribute name="password" optional="YES" attributeType="String"/>
|
<attribute name="password" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="theme" optional="YES" attributeType="String"/>
|
||||||
<attribute name="token" optional="YES" attributeType="String"/>
|
<attribute name="token" optional="YES" attributeType="String"/>
|
||||||
<attribute name="username" optional="YES" attributeType="String"/>
|
<attribute name="username" optional="YES" attributeType="String"/>
|
||||||
</entity>
|
</entity>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user