notifications mode button style

This commit is contained in:
spaced4ndy
2024-10-31 20:48:11 +04:00
parent 66430d7fbd
commit c9aa3fe61b
2 changed files with 41 additions and 33 deletions
@@ -10,12 +10,14 @@ import SwiftUI
import SimpleXChat
struct OnboardingButtonStyle: ButtonStyle {
@EnvironmentObject var theme: AppTheme
func makeBody(configuration: Configuration) -> some View {
configuration.label
.font(.system(size: 17, weight: .semibold))
.padding()
.frame(maxWidth: .infinity) // Makes button stretch horizontally
.background(Color.blue) // Apple blue color
.background(theme.colors.primary) // Apple blue color
.foregroundColor(.white) // White text color
.cornerRadius(10) // Rounded corners
.scaleEffect(configuration.isPressed ? 0.95 : 1.0) // Slight scale effect on press
@@ -30,6 +32,7 @@ struct ChooseServerOperators: View {
@State private var selectedOperators = Set<Int64>()
@State private var customServersNavLinkActive = false
@State private var reviewConditionsNavLinkActive = false
@State private var justOpened = true
var body: some View {
NavigationView {
@@ -62,8 +65,11 @@ struct ChooseServerOperators: View {
.frame(maxHeight: .infinity)
.padding()
.onAppear {
serverOperators = ChatModel.shared.serverOperators
selectedOperators = Set(serverOperators.filter { $0.enabled }.map { $0.operatorId })
if justOpened {
serverOperators = ChatModel.shared.serverOperators
selectedOperators = Set(serverOperators.filter { $0.enabled }.map { $0.operatorId })
justOpened = false
}
}
.sheet(isPresented: $showInfoSheet) {
ChooseServerOperatorsInfoView()
@@ -15,41 +15,43 @@ struct SetNotificationsMode: View {
@State private var showAlert: NotificationAlert?
var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 16) {
Text("Push notifications")
.font(.largeTitle)
.bold()
.frame(maxWidth: .infinity)
Text("Send notifications:")
ForEach(NotificationsMode.values) { mode in
NtfModeSelector(mode: mode, selection: $notificationMode)
}
Spacer()
Button {
if let token = m.deviceToken {
setNotificationsMode(token, notificationMode)
} else {
AlertManager.shared.showAlertMsg(title: "No device token!")
GeometryReader { g in
ScrollView {
VStack(alignment: .leading, spacing: 16) {
Text("Push notifications")
.font(.largeTitle)
.bold()
.frame(maxWidth: .infinity)
Text("Send notifications:")
ForEach(NotificationsMode.values) { mode in
NtfModeSelector(mode: mode, selection: $notificationMode)
}
onboardingStageDefault.set(.onboardingComplete)
m.onboardingStage = .onboardingComplete
} label: {
if case .off = notificationMode {
Text("Use chat")
} else {
Text("Enable notifications")
Spacer()
Button {
if let token = m.deviceToken {
setNotificationsMode(token, notificationMode)
} else {
AlertManager.shared.showAlertMsg(title: "No device token!")
}
onboardingStageDefault.set(.onboardingComplete)
m.onboardingStage = .onboardingComplete
} label: {
if case .off = notificationMode {
Text("Use chat")
} else {
Text("Enable notifications")
}
}
.buttonStyle(OnboardingButtonStyle())
}
.font(.title)
.frame(maxWidth: .infinity)
.padding()
.frame(minHeight: g.size.height)
}
.padding()
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
}
.frame(maxHeight: .infinity)
}
private func setNotificationsMode(_ token: DeviceToken, _ mode: NotificationsMode) {