Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Onboarding freeze #697

Merged
merged 2 commits into from
Apr 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions Mail/Views/Onboarding/SlideView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ struct SlideView: View {
@Environment(\.window) private var window
@Environment(\.colorScheme) private var colorScheme

@State private var segmentedControl: UISegmentedControl?
@State private var imageSize: CGSize = .zero

@State private var isVisible = false

var body: some View {
Expand Down Expand Up @@ -82,8 +79,7 @@ struct SlideView: View {
}
.pickerStyle(.segmented)
.introspectSegmentedControl { segmentedControl in
self.segmentedControl = segmentedControl
setSegmentedControlStyle()
setSegmentedControlStyle(segmentedControl)
}
.padding(.top, 32)
.frame(maxWidth: 256)
Expand All @@ -102,9 +98,7 @@ struct SlideView: View {
.padding(.horizontal, 32)
}
.onChange(of: accentColor) { _ in
// Handle accent color change
(window?.windowScene?.delegate as? SceneDelegate)?.updateWindowUI()
setSegmentedControlStyle()
}
.onAppear {
isVisible = true
Expand All @@ -115,12 +109,12 @@ struct SlideView: View {
}
}

private func setSegmentedControlStyle() {
segmentedControl?.selectedSegmentTintColor = .tintColor
segmentedControl?.setTitleTextAttributes([.foregroundColor: accentColor.onAccent.color], for: .selected)
private func setSegmentedControlStyle(_ segmentedControl: UISegmentedControl) {
segmentedControl.selectedSegmentTintColor = .tintColor
segmentedControl.setTitleTextAttributes([.foregroundColor: accentColor.onAccent.color], for: .selected)
let nonAccentColor: AccentColor = accentColor == .pink ? .blue : .pink
segmentedControl?.setTitleTextAttributes([.foregroundColor: nonAccentColor.primary.color], for: .normal)
segmentedControl?.backgroundColor = nonAccentColor.secondary.color
segmentedControl.setTitleTextAttributes([.foregroundColor: nonAccentColor.primary.color], for: .normal)
segmentedControl.backgroundColor = nonAccentColor.secondary.color
}
}

Expand Down