From 11c4c1a87be8252dc020928236bd4462e098a232 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Fri, 3 Jun 2022 18:39:20 -0700 Subject: [PATCH] embed reder pref popover in a nav view --- .../Views/FontSizeAdjustmentPopoverView.swift | 139 ++++++++++-------- 1 file changed, 76 insertions(+), 63 deletions(-) diff --git a/apple/OmnivoreKit/Sources/Views/FontSizeAdjustmentPopoverView.swift b/apple/OmnivoreKit/Sources/Views/FontSizeAdjustmentPopoverView.swift index e27e03035..24643deaa 100644 --- a/apple/OmnivoreKit/Sources/Views/FontSizeAdjustmentPopoverView.swift +++ b/apple/OmnivoreKit/Sources/Views/FontSizeAdjustmentPopoverView.swift @@ -41,74 +41,87 @@ public struct WebPreferencesPopoverView: View { self.dismissAction = dismissAction } - public var body: some View { - VStack(alignment: .center) { - Text("Reader Preferences") - .foregroundColor(.appGrayText) - .font(Font.system(size: 17, weight: .semibold)) - - List { - Section("Sizing") { - LabelledStepper( - labelText: "Font Size:", - onIncrement: { - storedFontSize = min(storedFontSize + 2, 28) - updateFontAction() - }, - onDecrement: { - storedFontSize = max(storedFontSize - 2, 10) - updateFontAction() - } - ) - - if UIDevice.isIPad { - LabelledStepper( - labelText: "Margin:", - onIncrement: { - storedMargin = min(storedMargin + 45, 560) - updateMarginAction() - }, - onDecrement: { - storedMargin = max(storedMargin - 45, 200) - updateMarginAction() + var fontList: some View { + List { + ForEach(WebFont.allCases, id: \.self) { font in + Button( + action: { + preferredFont = font.rawValue + updateFontFamilyAction() + }, + label: { + HStack { + Text(font.rawValue).foregroundColor(.appGrayTextContrast) + Spacer() + if font.rawValue == preferredFont { + Image(systemName: "checkmark").foregroundColor(.appGrayTextContrast) } - ) - } - - LabelledStepper( - labelText: "Line Spacing:", - onIncrement: { - storedLineSpacing = min(storedLineSpacing + 25, 300) - updateLineHeightAction() - }, - onDecrement: { - storedLineSpacing = max(storedLineSpacing - 25, 100) - updateLineHeightAction() } - ) - } - Section("Font Family") { - ForEach(WebFont.allCases, id: \.self) { font in - Button( - action: { - preferredFont = font.rawValue - updateFontFamilyAction() - }, - label: { - HStack { - Text(font.rawValue).foregroundColor(.appGrayTextContrast) - Spacer() - if font.rawValue == preferredFont { - Image(systemName: "checkmark").foregroundColor(.appGrayTextContrast) - } - } - } - ) } - } + ) } } - .padding() + } + + public var body: some View { + NavigationView { + VStack(alignment: .center) { + Text("Reader Preferences") + .foregroundColor(.appGrayText) + .font(Font.system(size: 17, weight: .semibold)) + + LabelledStepper( + labelText: "Font Size:", + onIncrement: { + storedFontSize = min(storedFontSize + 2, 28) + updateFontAction() + }, + onDecrement: { + storedFontSize = max(storedFontSize - 2, 10) + updateFontAction() + } + ) + + if UIDevice.isIPad { + LabelledStepper( + labelText: "Margin:", + onIncrement: { + storedMargin = min(storedMargin + 45, 560) + updateMarginAction() + }, + onDecrement: { + storedMargin = max(storedMargin - 45, 200) + updateMarginAction() + } + ) + } + + LabelledStepper( + labelText: "Line Spacing:", + onIncrement: { + storedLineSpacing = min(storedLineSpacing + 25, 300) + updateLineHeightAction() + }, + onDecrement: { + storedLineSpacing = max(storedLineSpacing - 25, 100) + updateLineHeightAction() + } + ) + + HStack { + NavigationLink(destination: fontList) { + Text("Change Reader Font") + } + Image(systemName: "chevron.right") + Spacer() + } + .frame(height: 40) + + Spacer() + } + .padding() + } + .accentColor(.appGrayTextContrast) } }