Add editinfo to share extension
This commit is contained in:
@ -48,7 +48,7 @@ public struct AddNoteSheet: View {
|
||||
.task {
|
||||
self.focusedField = .noteEditor
|
||||
}
|
||||
.background(Color.extensionPanelBackground)
|
||||
.background(Color.extensionBackground)
|
||||
.navigationTitle("Add Note")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.navigationBarItems(leading: Button(action: {
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
//
|
||||
// EditInfoSheet.swift
|
||||
//
|
||||
//
|
||||
// Created by Jackson Harper on 10/30/23.
|
||||
//
|
||||
|
||||
import Models
|
||||
import Services
|
||||
import SwiftUI
|
||||
import Utils
|
||||
import Views
|
||||
|
||||
public struct EditInfoSheet: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
@StateObject var viewModel: ShareExtensionViewModel
|
||||
let highlightId = UUID().uuidString.lowercased()
|
||||
let shortId = NanoID.generate(alphabet: NanoID.Alphabet.urlSafe.rawValue, size: 8)
|
||||
|
||||
enum FocusField: Hashable {
|
||||
case noteEditor
|
||||
}
|
||||
|
||||
@FocusState private var focusedField: FocusField?
|
||||
|
||||
public init(viewModel: ShareExtensionViewModel) {
|
||||
_viewModel = StateObject(wrappedValue: viewModel)
|
||||
UITextView.appearance().textContainerInset = UIEdgeInsets(top: 8, left: 4, bottom: 10, right: 4)
|
||||
}
|
||||
|
||||
// func saveInfo() {
|
||||
// if let linkedItem = viewModel.linkedItem {
|
||||
// _ = viewModel.services.dataService.updateLinkedItemTitleAndDescription(itemID: linkedItem.unwrappedID, title: title, description: description, author: author)
|
||||
// } else {
|
||||
// // Maybe we shouldn't even allow this UI without linkeditem existing
|
||||
// }
|
||||
// }
|
||||
|
||||
public var body: some View {
|
||||
if let item = viewModel.linkedItem {
|
||||
LinkedItemMetadataEditView(item: item) { title, _ in
|
||||
viewModel.title = title
|
||||
}
|
||||
.environmentObject(viewModel.services.dataService)
|
||||
} else {
|
||||
ProgressView()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -159,7 +159,9 @@ public struct ShareExtensionView: View {
|
||||
|
||||
var moreMenuButton: some View {
|
||||
Menu {
|
||||
Button(action: {}, label: {
|
||||
Button(action: {
|
||||
NotificationCenter.default.post(name: Notification.Name("ShowEditInfoSheet"), object: nil)
|
||||
}, label: {
|
||||
Label(
|
||||
"Edit Info",
|
||||
systemImage: "info.circle"
|
||||
|
||||
@ -95,13 +95,13 @@ struct LinkedItemMetadataEditView: View {
|
||||
var iOSBody: some View {
|
||||
NavigationView {
|
||||
editForm
|
||||
.navigationTitle("Edit Title and Description")
|
||||
.navigationTitle("Edit Info")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .barLeading) {
|
||||
Button(
|
||||
action: { presentationMode.wrappedValue.dismiss() },
|
||||
label: { Text(LocalText.cancelGeneric).foregroundColor(.appGrayTextContrast) }
|
||||
label: { Text(LocalText.cancelGeneric) }
|
||||
)
|
||||
}
|
||||
ToolbarItem(placement: .barTrailing) {
|
||||
@ -113,7 +113,7 @@ struct LinkedItemMetadataEditView: View {
|
||||
}
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
},
|
||||
label: { Text(LocalText.genericSave).foregroundColor(.appGrayTextContrast) }
|
||||
label: { Text(LocalText.genericSave).bold() }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,14 @@ import Views
|
||||
self.openSheet(AnyView(EditLabelsSheet(viewModel: self.viewModel, labelsViewModel: self.labelsViewModel)))
|
||||
}
|
||||
|
||||
NotificationCenter.default.addObserver(
|
||||
forName: Notification.Name("ShowEditInfoSheet"),
|
||||
object: nil,
|
||||
queue: OperationQueue.main
|
||||
) { _ in
|
||||
self.openSheet(AnyView(EditInfoSheet(viewModel: self.viewModel)))
|
||||
}
|
||||
|
||||
embed(
|
||||
childViewController: UIViewController.makeShareExtensionController(
|
||||
viewModel: viewModel,
|
||||
|
||||
Reference in New Issue
Block a user