diff --git a/app/src/main/kotlin/pl/pawelosinski/skatefreak/service/FirebaseAuthService.kt b/app/src/main/kotlin/pl/pawelosinski/skatefreak/service/FirebaseAuthService.kt index fb1de8a..a68e6b7 100644 --- a/app/src/main/kotlin/pl/pawelosinski/skatefreak/service/FirebaseAuthService.kt +++ b/app/src/main/kotlin/pl/pawelosinski/skatefreak/service/FirebaseAuthService.kt @@ -2,37 +2,14 @@ package pl.pawelosinski.skatefreak.service import android.app.Activity import android.content.Context -import android.content.Intent import android.util.Log import android.widget.Toast import androidx.activity.ComponentActivity import androidx.activity.result.contract.ActivityResultContracts -import androidx.compose.foundation.border -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material3.Button -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.OutlinedTextField -import androidx.compose.material3.Surface -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.text.input.KeyboardType -import androidx.compose.ui.unit.dp -import androidx.compose.ui.viewinterop.AndroidView import com.google.android.gms.auth.api.signin.GoogleSignIn import com.google.android.gms.auth.api.signin.GoogleSignInAccount import com.google.android.gms.auth.api.signin.GoogleSignInOptions -import com.google.android.gms.common.SignInButton import com.google.android.gms.common.api.ApiException import com.google.android.gms.tasks.Task import com.google.firebase.FirebaseException @@ -46,22 +23,11 @@ import com.google.firebase.auth.PhoneAuthOptions import com.google.firebase.auth.PhoneAuthProvider import pl.pawelosinski.skatefreak.R import pl.pawelosinski.skatefreak.auth.PhoneAuthUserData -import pl.pawelosinski.skatefreak.local.isDarkMode import pl.pawelosinski.skatefreak.local.loggedUser import pl.pawelosinski.skatefreak.model.User import pl.pawelosinski.skatefreak.model.User.Companion.ACCOUNT_TYPE_GOOGLE import pl.pawelosinski.skatefreak.model.User.Companion.ACCOUNT_TYPE_PHONE -import pl.pawelosinski.skatefreak.service.FirebaseAuthService.Companion.PHONE_TAG -import pl.pawelosinski.skatefreak.service.FirebaseAuthService.Companion.isUserDataSet -import pl.pawelosinski.skatefreak.service.FirebaseAuthService.Companion.isUserLoggedIn -import pl.pawelosinski.skatefreak.service.FirebaseAuthService.Companion.phoneAuthUserData -import pl.pawelosinski.skatefreak.service.FirebaseAuthService.Companion.resendToken -import pl.pawelosinski.skatefreak.service.FirebaseAuthService.Companion.storedVerificationId -import pl.pawelosinski.skatefreak.ui.auth.UserSetDataActivity -import pl.pawelosinski.skatefreak.ui.common.myCommonModifier import pl.pawelosinski.skatefreak.ui.common.myToast -import pl.pawelosinski.skatefreak.ui.menu.MainMenuActivity -import pl.pawelosinski.skatefreak.ui.theme.SkateFreakTheme import java.util.concurrent.TimeUnit class FirebaseAuthService(val activity: ComponentActivity) { @@ -394,251 +360,6 @@ class FirebaseAuthService(val activity: ComponentActivity) { } } -@Composable -fun LoginScreen(firebaseAuthService: FirebaseAuthService) { - val isUserDataSet by remember { - mutableStateOf(isUserDataSet) - } - - val isUserLoggedIn by remember { - mutableStateOf(isUserLoggedIn) - } - -// val isAuthInProgress by remember { -// mutableStateOf(phoneAuthUserData.value.isAuthInProgress.value) -// } -// var verificationCode by remember { mutableStateOf("") } - - SkateFreakTheme(darkTheme = isDarkMode) { - // A surface container using the 'background' color from the theme - Surface( - modifier = Modifier.fillMaxSize(), - color = MaterialTheme.colorScheme.background, - - ) { - Column( - modifier = Modifier - .padding(16.dp), - verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally - ) { - if (isUserLoggedIn.value && loggedUser.value.firebaseId.isNotEmpty()) { - databaseService.setLoggedUserById(loggedUser.value.firebaseId) - Log.d("LoginActivity", "Before data check: isUserDataSet: $isUserDataSet") - if (!isUserDataSet.value) { - isUserDataSet.value = loggedUser.value.checkRequiredData() - Log.d("LoginActivity", "After data check: isUserDataSet: $isUserDataSet") - } - - if (!isUserDataSet.value) { - Log.d("LoginActivity", "isUserDataSet: ${isUserDataSet.value}") - Text( - text = "Aby kontynuować, proszę uzupełnić dane profilu", - modifier = Modifier.padding(bottom = 16.dp) - ) - } else if (loggedUser.value.name.isNotEmpty()) { - Text( - text = "Witaj ${loggedUser.value.name}", - modifier = Modifier.padding(bottom = 16.dp) - ) - } else { - Text( - text = "Witaj ${loggedUser.value.phoneNumber}", - modifier = Modifier.padding(bottom = 16.dp) - ) - } - - if (isUserDataSet.value) { - // Button to go to LoggedUserMenuActivity - MainMenuButton(firebaseAuthService) - } else { - // Button to go to UserDataActivity - Button( - onClick = { - phoneAuthUserData.value = PhoneAuthUserData() - val intent = Intent( - firebaseAuthService.currentActivity.value, - UserSetDataActivity::class.java - ) - firebaseAuthService.currentActivity.value.startActivity(intent) - firebaseAuthService.currentActivity.value.finish() - }, - modifier = myCommonModifier, - shape = MaterialTheme.shapes.small - ) { - Text("Uzupełnij dane użytkownika") - } - } - SignOutButton(signOut = { firebaseAuthService.signOut() }) - } else { - Text( - text = "Zaloguj się", - modifier = Modifier.padding(bottom = 16.dp) - ) - PhoneLoginForm(firebaseAuthService) - GoogleSignInButton(firebaseAuthService) - } - } - } - } - -} - - -@Composable -fun MainMenuButton(firebaseAuthService: FirebaseAuthService) { - val context = LocalContext.current - Button( - onClick = { - val intent = Intent(context, MainMenuActivity::class.java) - firebaseAuthService.currentActivity.value.startActivity(intent) - firebaseAuthService.currentActivity.value.finish() - }, - modifier = myCommonModifier, - shape = MaterialTheme.shapes.small - ) { - Text("Przejdź do menu głównego") - } -} - - -@Composable -fun SignOutButton( - signOut: () -> Unit = { - // Configure Google Sign In - } -) { - Button( - modifier = myCommonModifier, - onClick = { - signOut() - }, - shape = MaterialTheme.shapes.small - ) { - Text(text = "Wyloguj się") - } -} - - -@Composable -fun GoogleSignInButton(firebaseAuthService: FirebaseAuthService) { - // Reference to the GoogleSignInClient from the activity - - AndroidView( - modifier = myCommonModifier - .border(1.dp, MaterialTheme.colorScheme.onSurface, MaterialTheme.shapes.small), - factory = { context -> - SignInButton(context).apply { - setSize(SignInButton.SIZE_WIDE) - } - }, - update = { signInButton -> - signInButton.setOnClickListener { - // Start the sign-in process when the Google sign-in button is clicked - firebaseAuthService.googleSignIn() - } - } - ) -} - - -@Composable -fun PhoneLoginForm(firebaseAuthService: FirebaseAuthService) { -// val loginService = LoginService() - val isAuthInProgress by remember { - mutableStateOf(phoneAuthUserData.value.isAuthInProgress.value) - } - val isVerificationCompleted by remember { - mutableStateOf(phoneAuthUserData.value.isVerificationCompleted) - } - val isUserLoggedIn by remember { - mutableStateOf(phoneAuthUserData.value.isUserLoggedIn) - } - val storedVerificationId by remember { - mutableStateOf(storedVerificationId.value) - } - var userPhoneNumber by remember { - if (phoneAuthUserData.value.userPhoneNumber.value.isEmpty()) { - mutableStateOf("+48") - } else { - mutableStateOf(phoneAuthUserData.value.userPhoneNumber.value) - } - } - val resendToken by remember { - mutableStateOf(resendToken) - } - var verificationCode by remember { mutableStateOf("") } - Column( - modifier = Modifier - .padding(16.dp), - verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally - ) { -// val pattern = remember { Regex("^\\+48\\d\\d\\d\\d\\d\\d\\d\\d\\d$") } - OutlinedTextField( - value = userPhoneNumber, - onValueChange = { - userPhoneNumber = it - }, - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), - label = { Text("Phone (+48XXXXXXXXX)") }, - singleLine = true - ) - Log.d(PHONE_TAG, "isAuthInProgress: $isAuthInProgress") - if (isAuthInProgress) { - val pattern = remember { Regex("^\\d?\\d?\\d?\\d?\\d?\\d?$") } - OutlinedTextField( - value = verificationCode, - onValueChange = { - if (it.isEmpty() || it.matches(pattern)) { - verificationCode = it - } - }, - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), - label = { Text("Kod Weryfikacyjny SMS") }, - singleLine = true - ) - Button( - onClick = { - firebaseAuthService.resendVerificationCode(userPhoneNumber, resendToken.value) - }, - modifier = myCommonModifier, - shape = MaterialTheme.shapes.small - ) { - Text("Wyślij ponownie kod weryfikacyjny") - } - } - - Button( - onClick = { - if ( - !isAuthInProgress && - !isVerificationCompleted.value && - !isUserLoggedIn.value - ) { - firebaseAuthService.startPhoneNumberVerification(userPhoneNumber) - } else if (!isVerificationCompleted.value) { - if (verificationCode.matches(Regex("^\\d\\d\\d\\d\\d\\d$"))) { - firebaseAuthService.verifyPhoneNumberWithCode( - storedVerificationId, - verificationCode - ) - } else { - Toast.makeText( - firebaseAuthService.currentActivity.value, - "Niepoprawny kod weryfikacyjny", - Toast.LENGTH_SHORT - ).show() - } - } - }, - modifier = myCommonModifier, - shape = MaterialTheme.shapes.small - ) { - Text("Login") - } - } -} diff --git a/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/auth/LoginActivity.kt b/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/auth/LoginActivity.kt index cadcfe6..f34c37b 100644 --- a/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/auth/LoginActivity.kt +++ b/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/auth/LoginActivity.kt @@ -1,33 +1,59 @@ package pl.pawelosinski.skatefreak.ui.auth +import android.content.Intent import android.os.Bundle +import android.util.Log +import android.widget.Toast import androidx.activity.ComponentActivity import androidx.activity.compose.setContent +import androidx.compose.foundation.border +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.text.input.KeyboardType +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.compose.ui.viewinterop.AndroidView +import com.google.android.gms.common.SignInButton +import pl.pawelosinski.skatefreak.auth.PhoneAuthUserData import pl.pawelosinski.skatefreak.local.firebaseAuthService import pl.pawelosinski.skatefreak.local.isDarkMode +import pl.pawelosinski.skatefreak.local.loggedUser import pl.pawelosinski.skatefreak.service.FirebaseAuthService -import pl.pawelosinski.skatefreak.service.LoginScreen +import pl.pawelosinski.skatefreak.service.databaseService +import pl.pawelosinski.skatefreak.ui.common.myButtonModifier16dp +import pl.pawelosinski.skatefreak.ui.common.myButtonModifier8dp +import pl.pawelosinski.skatefreak.ui.menu.MainMenuActivity import pl.pawelosinski.skatefreak.ui.theme.SkateFreakTheme class LoginActivity : ComponentActivity() { - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) firebaseAuthService = FirebaseAuthService(this) setContent { -// LocalContext.current SkateFreakTheme(darkTheme = isDarkMode) { // A surface container using the 'background' color from the theme Surface( modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background, - ) { LoginScreen(firebaseAuthService) } @@ -36,10 +62,241 @@ class LoginActivity : ComponentActivity() { } } +@Composable +fun LoginScreen(firebaseAuthService: FirebaseAuthService) { + val isUserDataSet by remember { + mutableStateOf(FirebaseAuthService.isUserDataSet) + } + val isUserLoggedIn by remember { + mutableStateOf(FirebaseAuthService.isUserLoggedIn) + } + + SkateFreakTheme(darkTheme = isDarkMode) { + // A surface container using the 'background' color from the theme + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background, + ) { + Column( + modifier = Modifier + .padding(16.dp), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally + ) { + if (isUserLoggedIn.value && loggedUser.value.firebaseId.isNotEmpty()) { + databaseService.setLoggedUserById(loggedUser.value.firebaseId) + Log.d("LoginActivity", "Before data check: isUserDataSet: $isUserDataSet") + if (!isUserDataSet.value) { + isUserDataSet.value = loggedUser.value.checkRequiredData() + Log.d("LoginActivity", "After data check: isUserDataSet: $isUserDataSet") + } + + if (!isUserDataSet.value) { + Log.d("LoginActivity", "isUserDataSet: ${isUserDataSet.value}") + Text( + text = "Aby kontynuować, proszę uzupełnić dane profilu", + modifier = Modifier.padding(bottom = 16.dp) + ) + } else if (loggedUser.value.name.isNotEmpty()) { + Text( + text = "Witaj ${loggedUser.value.name}", + modifier = Modifier.padding(bottom = 16.dp) + ) + } else { + Text( + text = "Witaj ${loggedUser.value.phoneNumber}", + modifier = Modifier.padding(bottom = 16.dp) + ) + } + if (isUserDataSet.value) { + // Button to go to LoggedUserMenuActivity + MainMenuButton(firebaseAuthService) + } else { + // Button to go to UserDataActivity + Button( + onClick = { + FirebaseAuthService.phoneAuthUserData.value = PhoneAuthUserData() + val intent = Intent( + firebaseAuthService.currentActivity.value, + UserSetDataActivity::class.java + ) + firebaseAuthService.currentActivity.value.startActivity(intent) + firebaseAuthService.currentActivity.value.finish() + }, + modifier = myButtonModifier16dp, + shape = MaterialTheme.shapes.small + ) { + Text("Uzupełnij dane użytkownika") + } + } + SignOutButton(signOut = { firebaseAuthService.signOut() }) + } else { + Text( + text = "Zaloguj się", + modifier = Modifier.padding(bottom = 32.dp), + style = MaterialTheme.typography.titleLarge + ) + PhoneLoginForm(firebaseAuthService) + GoogleSignInButton(firebaseAuthService) + } + } + } + } +} + +@Composable +fun MainMenuButton(firebaseAuthService: FirebaseAuthService) { + val context = LocalContext.current + Button( + onClick = { + val intent = Intent(context, MainMenuActivity::class.java) + firebaseAuthService.currentActivity.value.startActivity(intent) + firebaseAuthService.currentActivity.value.finish() + }, + modifier = myButtonModifier16dp, + shape = MaterialTheme.shapes.small + ) { + Text("Przejdź do menu głównego") + } +} +@Composable +fun SignOutButton(signOut: () -> Unit = {}) { + Button( + modifier = myButtonModifier16dp, + onClick = { + signOut() + }, + shape = MaterialTheme.shapes.small + ) { + Text(text = "Wyloguj się", fontSize = 18.sp) + } +} +@Composable +fun GoogleSignInButton(firebaseAuthService: FirebaseAuthService) { + // Reference to the GoogleSignInClient from the activity + AndroidView( + modifier = Modifier + .fillMaxWidth() + .padding(bottom = 0.dp, top = 8.dp, start = 16.dp, end = 16.dp) + .border(1.dp, MaterialTheme.colorScheme.onSurface, MaterialTheme.shapes.small), + factory = { context -> + SignInButton(context).apply { + setSize(SignInButton.SIZE_WIDE) + } + }, + update = { signInButton -> + signInButton.setOnClickListener { + // Start the sign-in process when the Google sign-in button is clicked + firebaseAuthService.googleSignIn() + } + } + ) +} + +@Composable +fun PhoneLoginForm(firebaseAuthService: FirebaseAuthService) { + val isAuthInProgress by remember { + mutableStateOf(FirebaseAuthService.phoneAuthUserData.value.isAuthInProgress.value) + } + val isVerificationCompleted by remember { + mutableStateOf(FirebaseAuthService.phoneAuthUserData.value.isVerificationCompleted) + } + val isUserLoggedIn by remember { + mutableStateOf(FirebaseAuthService.phoneAuthUserData.value.isUserLoggedIn) + } + val storedVerificationId by remember { + mutableStateOf(FirebaseAuthService.storedVerificationId.value) + } + var userPhoneNumber by remember { + if (FirebaseAuthService.phoneAuthUserData.value.userPhoneNumber.value.isEmpty()) { + mutableStateOf("+48") + } else { + mutableStateOf(FirebaseAuthService.phoneAuthUserData.value.userPhoneNumber.value) + } + } + val resendToken by remember { + mutableStateOf(FirebaseAuthService.resendToken) + } + var verificationCode by remember { mutableStateOf("") } + Column( + modifier = Modifier + .padding(16.dp), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally + ) { + OutlinedTextField( + value = userPhoneNumber, + onValueChange = { + userPhoneNumber = it + }, + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), + label = { Text("Phone (+48XXXXXXXXX)") }, + singleLine = true + ) + Log.d(FirebaseAuthService.PHONE_TAG, "isAuthInProgress: $isAuthInProgress") + if (isAuthInProgress) { + val pattern = remember { Regex("^\\d?\\d?\\d?\\d?\\d?\\d?$") } + OutlinedTextField( + value = verificationCode, + onValueChange = { + if (it.isEmpty() || it.matches(pattern)) { + verificationCode = it + } + }, + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), + label = { Text("Kod Weryfikacyjny SMS") }, + singleLine = true + ) + } + Button( + onClick = { + if ( + !isAuthInProgress && + !isVerificationCompleted.value && + !isUserLoggedIn.value + ) { + firebaseAuthService.startPhoneNumberVerification(userPhoneNumber) + } else if (!isVerificationCompleted.value) { + if (verificationCode.matches(Regex("^\\d\\d\\d\\d\\d\\d$"))) { + firebaseAuthService.verifyPhoneNumberWithCode( + storedVerificationId, + verificationCode + ) + } else { + Toast.makeText( + firebaseAuthService.currentActivity.value, + "Niepoprawny kod weryfikacyjny", + Toast.LENGTH_SHORT + ).show() + } + } + }, + modifier = myButtonModifier8dp, + shape = MaterialTheme.shapes.small + ) { + if(!isAuthInProgress){ + Text("Zaloguj się") + } else { + Text("Zweryfikuj kod") + } + } + if(isAuthInProgress) { + Button( + onClick = { + firebaseAuthService.resendVerificationCode(userPhoneNumber, resendToken.value) + }, + modifier = myButtonModifier8dp, + shape = MaterialTheme.shapes.small + ) { + Text("Wyślij kod ponownie") + } + } + } +} diff --git a/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/common/BottomNavigationBar.kt b/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/common/BottomNavigationBar.kt index 1b9efcc..a97d023 100644 --- a/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/common/BottomNavigationBar.kt +++ b/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/common/BottomNavigationBar.kt @@ -33,7 +33,7 @@ import pl.pawelosinski.skatefreak.model.TrickInfo import pl.pawelosinski.skatefreak.model.TrickRecord import pl.pawelosinski.skatefreak.model.User import pl.pawelosinski.skatefreak.repository.UserRepository -import pl.pawelosinski.skatefreak.service.LoginScreen +import pl.pawelosinski.skatefreak.ui.auth.LoginScreen import pl.pawelosinski.skatefreak.ui.home.HomeScreen import pl.pawelosinski.skatefreak.ui.profile.ProfileScreen import pl.pawelosinski.skatefreak.ui.profile.edit.EditProfile diff --git a/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/common/Modifiers.kt b/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/common/Modifiers.kt index 8615661..54fdef0 100644 --- a/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/common/Modifiers.kt +++ b/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/common/Modifiers.kt @@ -11,9 +11,13 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp -val myCommonModifier = Modifier - .fillMaxWidth() - .padding(16.dp) +val myButtonModifier8dp = Modifier + .fillMaxWidth() + .padding(8.dp) + +val myButtonModifier16dp = Modifier + .fillMaxWidth() + .padding(16.dp) @SuppressLint("ModifierFactoryExtensionFunction") fun avatarModifier(borderColor: Color) = Modifier diff --git a/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/profile/ProfileScreen.kt b/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/profile/ProfileScreen.kt index 0e22ed1..da4b817 100644 --- a/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/profile/ProfileScreen.kt +++ b/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/profile/ProfileScreen.kt @@ -33,6 +33,7 @@ import pl.pawelosinski.skatefreak.local.loggedUser import pl.pawelosinski.skatefreak.model.User import pl.pawelosinski.skatefreak.ui.common.Screens import pl.pawelosinski.skatefreak.ui.common.avatarModifier +import pl.pawelosinski.skatefreak.ui.common.myButtonModifier16dp import pl.pawelosinski.skatefreak.ui.theme.SkateFreakTheme @Composable @@ -143,7 +144,8 @@ fun UserDataTextRow(label: String, value: String) { fun EditProfileButton(navController: NavController) { Button( onClick = { navController.navigate(Screens.EditProfile.route) }, - modifier = Modifier.fillMaxWidth() + shape = MaterialTheme.shapes.small, + modifier = myButtonModifier16dp ) { Text("Edytuj Profil", fontSize = 18.sp) } diff --git a/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/settings/SettingsScreen.kt b/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/settings/SettingsScreen.kt index 3ffc49c..c45491e 100644 --- a/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/settings/SettingsScreen.kt +++ b/app/src/main/kotlin/pl/pawelosinski/skatefreak/ui/settings/SettingsScreen.kt @@ -26,9 +26,10 @@ import pl.pawelosinski.skatefreak.local.ThemePreferences import pl.pawelosinski.skatefreak.local.firebaseAuthService import pl.pawelosinski.skatefreak.local.isDarkMode import pl.pawelosinski.skatefreak.local.loggedUser -import pl.pawelosinski.skatefreak.service.SignOutButton import pl.pawelosinski.skatefreak.service.UserService import pl.pawelosinski.skatefreak.ui.auth.LoginActivity +import pl.pawelosinski.skatefreak.ui.auth.SignOutButton +import pl.pawelosinski.skatefreak.ui.profile.EditProfileButton import pl.pawelosinski.skatefreak.ui.theme.SkateFreakTheme @@ -56,7 +57,8 @@ fun SettingsScreen(navController: NavController) { } ) { innerPadding -> Column(modifier = Modifier.padding(innerPadding)) { - // Przełącznik + Text("Profil", style = MaterialTheme.typography.titleMedium, modifier = Modifier.padding(16.dp)) + // switch RowSettingsItem( title = "Widoczność profilu", description = "Pozwól innym użytkownikom na\nprzeglądanie Twojego profilu" @@ -66,8 +68,10 @@ fun SettingsScreen(navController: NavController) { UserService.setUserPublicProfile(it) }) } + // profile edit button + EditProfileButton(navController = navController) - // Przyciski radio + // radio buttons Text("Wybierz motyw", style = MaterialTheme.typography.titleMedium, modifier = Modifier.padding(16.dp)) themes.forEach { theme -> RowSettingsItem(