Skip to content

Commit

Permalink
feat: reset appearance of uikit elements
Browse files Browse the repository at this point in the history
  • Loading branch information
FranAlarza committed Sep 10, 2024
1 parent 346bebf commit f62711b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 29 deletions.
6 changes: 1 addition & 5 deletions AppliverySDK/Applivery/Applivery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ public class Applivery: NSObject, StartInteractorOutput, UpdateInteractorOutput
internal var updateInteractor: PUpdateInteractor
private let globalConfig: GlobalConfig
private let updateCoordinator: PUpdateCoordinator
private let feedbackCoordinator: PFeedbackCoordinator
private let loginInteractor: LoginInteractor
private var isUpdating = false
private var updateCallbackSuccess: (() -> Void)?
Expand All @@ -203,7 +202,6 @@ public class Applivery: NSObject, StartInteractorOutput, UpdateInteractorOutput
globalConfig: GlobalConfig.shared,
updateCoordinator: UpdateCoordinator(),
updateInteractor: Configurator.updateInteractor(),
feedbackCoordinator: FeedbackCoordinator(),
loginInteractor: Configurator.loginInteractor()
)
self.startInteractor.output = self
Expand All @@ -214,13 +212,11 @@ public class Applivery: NSObject, StartInteractorOutput, UpdateInteractorOutput
globalConfig: GlobalConfig,
updateCoordinator: PUpdateCoordinator,
updateInteractor: PUpdateInteractor,
feedbackCoordinator: PFeedbackCoordinator,
loginInteractor: LoginInteractor) {
self.startInteractor = startInteractor
self.globalConfig = globalConfig
self.updateCoordinator = updateCoordinator
self.updateInteractor = updateInteractor
self.feedbackCoordinator = feedbackCoordinator
self.loginInteractor = loginInteractor
self.logLevel = .info
self.palette = Palette()
Expand Down Expand Up @@ -363,7 +359,7 @@ public class Applivery: NSObject, StartInteractorOutput, UpdateInteractorOutput
*/
@objc public func feedbackEvent() {
logInfo("Presenting feedback formulary")
self.feedbackCoordinator.showFeedack()
ScreenRecorderManager.shared.presentPreviewWithScreenshoot()
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,6 @@ struct ScreenshootPreview: View {
@State var description: String = ""
@State var selectionType: Int = 0

init(screenshot: UIImage? = nil) {
let palette = GlobalConfig.shared.palette
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = palette.primaryColor
appearance.titleTextAttributes = [.foregroundColor: palette.primaryFontColor]
appearance.largeTitleTextAttributes = [.foregroundColor: palette.primaryFontColor]

UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
UINavigationBar.appearance().compactAppearance = appearance

UISegmentedControl.appearance().selectedSegmentTintColor = palette.primaryColor
UISegmentedControl.appearance().backgroundColor = palette.secondaryColor
let selectedTextColor = [NSAttributedString.Key.foregroundColor: palette.primaryFontColor]
let normalTextColor = [NSAttributedString.Key.foregroundColor: palette.secondaryFontColor]
UISegmentedControl.appearance().setTitleTextAttributes(normalTextColor, for: .normal)
UISegmentedControl.appearance().setTitleTextAttributes(selectedTextColor, for: .selected)


self.screenshot = screenshot
}

var body: some View {
NavigationView {
VStack {
Expand All @@ -50,7 +27,7 @@ struct ScreenshootPreview: View {
.scaledToFit()
.edgesIgnoringSafeArea(.all)
}
Picker("Select Type: ", selection: $selectionType) {
Picker("Select Type", selection: $selectionType) {
Text(literal(.feedbackTypeFeedback) ?? "").tag(0)
Text(literal(.feedbackTypeBug) ?? "").tag(1)
}
Expand Down Expand Up @@ -90,6 +67,41 @@ struct ScreenshootPreview: View {
}
})
}
.onAppear {
let palette = GlobalConfig.shared.palette
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = palette.primaryColor
appearance.titleTextAttributes = [.foregroundColor: palette.primaryFontColor]
appearance.largeTitleTextAttributes = [.foregroundColor: palette.primaryFontColor]

UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
UINavigationBar.appearance().compactAppearance = appearance

UISegmentedControl.appearance().selectedSegmentTintColor = palette.primaryColor
UISegmentedControl.appearance().backgroundColor = palette.secondaryColor
let selectedTextColor = [NSAttributedString.Key.foregroundColor: palette.primaryFontColor]
let normalTextColor = [NSAttributedString.Key.foregroundColor: palette.secondaryFontColor]
UISegmentedControl.appearance().setTitleTextAttributes(normalTextColor, for: .normal)
UISegmentedControl.appearance().setTitleTextAttributes(selectedTextColor, for: .selected)
}
.onDisappear {
let defaultAppearance = UINavigationBarAppearance()
defaultAppearance.configureWithOpaqueBackground()
defaultAppearance.backgroundColor = .systemBackground
defaultAppearance.titleTextAttributes = [.foregroundColor: UIColor.label]
defaultAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor.label]

UINavigationBar.appearance().standardAppearance = defaultAppearance
UINavigationBar.appearance().scrollEdgeAppearance = defaultAppearance
UINavigationBar.appearance().compactAppearance = defaultAppearance

UISegmentedControl.appearance().selectedSegmentTintColor = nil
UISegmentedControl.appearance().backgroundColor = nil
UISegmentedControl.appearance().setTitleTextAttributes(nil, for: .normal)
UISegmentedControl.appearance().setTitleTextAttributes(nil, for: .selected)
}
}
}

Expand Down

0 comments on commit f62711b

Please sign in to comment.