Fixes to build on Macos

This commit is contained in:
Jackson Harper 2023-05-30 22:25:50 +08:00
parent 9278a938d7
commit 1fbd0a5e64
5 changed files with 57 additions and 48 deletions

View file

@ -116,13 +116,15 @@ struct WebReader: PlatformViewRepresentable {
(webView as? OmnivoreWebView)?.updateTitle(title: item.title ?? "")
(webView as? OmnivoreWebView)?.updateJustifyText()
webView.backgroundColor = UIColor(ThemeManager.currentBgColor)
webView.tintColor = UIColor(ThemeManager.currentHighlightColor)
webView.underPageBackgroundColor = UIColor(ThemeManager.currentBgColor)
webView.scrollView.backgroundColor = UIColor(ThemeManager.currentBgColor)
webView.scrollView.indicatorStyle = ThemeManager.currentTheme.isDark ?
UIScrollView.IndicatorStyle.white :
UIScrollView.IndicatorStyle.black
#if os(iOS)
webView.backgroundColor = UIColor(ThemeManager.currentBgColor)
webView.tintColor = UIColor(ThemeManager.currentHighlightColor)
webView.underPageBackgroundColor = UIColor(ThemeManager.currentBgColor)
webView.scrollView.backgroundColor = UIColor(ThemeManager.currentBgColor)
webView.scrollView.indicatorStyle = ThemeManager.currentTheme.isDark ?
UIScrollView.IndicatorStyle.white :
UIScrollView.IndicatorStyle.black
#endif
}
if showNavBarActionID != context.coordinator.previousShowNavBarActionID {

View file

@ -288,30 +288,30 @@ struct WebReaderContainerView: View {
#if os(iOS)
audioNavbarItem
#endif
Button(
action: {
if UIDevice.current.userInterfaceIdiom == .phone {
showPreferencesFormsheet.toggle()
} else {
showPreferencesPopover.toggle()
Button(
action: {
if UIDevice.current.userInterfaceIdiom == .phone {
showPreferencesFormsheet.toggle()
} else {
showPreferencesPopover.toggle()
}
},
label: {
Image(systemName: "textformat.size")
.font(.appNavbarIcon)
}
},
label: {
Image(systemName: "textformat.size")
.font(.appNavbarIcon)
)
.padding(.horizontal, 5)
.scaleEffect(navBarVisibilityRatio)
.popover(isPresented: $showPreferencesPopover) {
webPreferencesPopoverView
.frame(maxWidth: 400, maxHeight: 475)
}
)
.padding(.horizontal, 5)
.scaleEffect(navBarVisibilityRatio)
.popover(isPresented: $showPreferencesPopover) {
webPreferencesPopoverView
.frame(maxWidth: 400, maxHeight: 475)
}
.formSheet(isPresented: $showPreferencesFormsheet, modalSize: CGSize(width: 400, height: 475)) {
webPreferencesPopoverView
}
.formSheet(isPresented: $showPreferencesFormsheet, modalSize: CGSize(width: 400, height: 475)) {
webPreferencesPopoverView
}
#endif
#if os(macOS)
Spacer()
@ -596,7 +596,9 @@ struct WebReaderContainerView: View {
#if os(iOS)
UIPasteboard.general.string = deepLink.absoluteString
#else
Pasteboard.general.string = deepLink.absoluteString
let pasteBoard = NSPasteboard.general
pasteBoard.clearContents()
pasteBoard.writeObjects([deepLink.absoluteString as NSString])
#endif
showInSnackbar("Deeplink Copied")
} else {

View file

@ -50,19 +50,22 @@ public struct HighlightAnnotationSheet: View {
}
.padding()
.navigationTitle("Note")
.navigationBarTitleDisplayMode(.inline)
.navigationBarItems(leading: Button(action: onCancel, label: {
Text("Cancel")
}))
.navigationBarItems(trailing: Button(action: onSave, label: {
Text("Save").bold()
}))
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
.navigationBarItems(leading: Button(action: onCancel, label: {
Text("Cancel")
}))
.navigationBarItems(trailing: Button(action: onSave, label: {
Text("Save").bold()
}))
#endif
.listStyle(PlainListStyle())
.alert(errorAlertMessage ?? LocalText.readerError, isPresented: $showErrorAlertMessage) {
Button(LocalText.genericOk, role: .cancel, action: {
errorAlertMessage = nil
showErrorAlertMessage = false
})
}
.alert(errorAlertMessage ?? LocalText.readerError, isPresented: $showErrorAlertMessage) {
Button(LocalText.genericOk, role: .cancel, action: {
errorAlertMessage = nil
showErrorAlertMessage = false
})
}
}
}

View file

@ -187,7 +187,7 @@ public final class OmnivoreWebView: WKWebView {
override public func viewDidChangeEffectiveAppearance() {
super.viewDidChangeEffectiveAppearance()
if ThemeManager.currentTheme == .system {
try dispatchEvent(.updateTheme(themeName: ThemeManager.currentTheme.themeKey))
try? dispatchEvent(.updateTheme(themeName: ThemeManager.currentTheme.themeKey))
}
}
#endif

View file

@ -4,11 +4,13 @@ import Utils
public extension View {
func draggableItem(item: LinkedItem) -> some View {
if #available(iOS 16.0, *), let url = item.deepLink {
return AnyView(self.draggable(url) {
Label(item.unwrappedTitle, systemImage: "link")
})
}
#if os(iOS)
if #available(iOS 16.0, *), let url = item.deepLink {
return AnyView(self.draggable(url) {
Label(item.unwrappedTitle, systemImage: "link")
})
}
#endif
return AnyView(self)
}
}