mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-20 20:17:12 +00:00
notifications mode button style
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user