From 2e6f80f15f7d55da5b41582683f9950ac1e1d626 Mon Sep 17 00:00:00 2001 From: Antoine Robiez Date: Fri, 12 Apr 2024 14:29:58 +0200 Subject: [PATCH] Disabled iOS Sign In --- .../ui/common/SigninButton.android.kt | 74 +++++++++++++++++++ .../androidmakers/ui/common/SigninButton.kt | 68 +---------------- .../ui/MainLayoutViewController.kt | 6 +- .../ui/common/SigninButton.ios.kt | 11 +++ 4 files changed, 92 insertions(+), 67 deletions(-) create mode 100644 shared/ui/src/androidMain/kotlin/com/androidmakers/ui/common/SigninButton.android.kt create mode 100644 shared/ui/src/iosMain/kotlin/com/androidmakers/ui/common/SigninButton.ios.kt diff --git a/shared/ui/src/androidMain/kotlin/com/androidmakers/ui/common/SigninButton.android.kt b/shared/ui/src/androidMain/kotlin/com/androidmakers/ui/common/SigninButton.android.kt new file mode 100644 index 00000000..7ec67e5a --- /dev/null +++ b/shared/ui/src/androidMain/kotlin/com/androidmakers/ui/common/SigninButton.android.kt @@ -0,0 +1,74 @@ +package com.androidmakers.ui.common + +import androidx.compose.foundation.Image +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.rounded.AccountCircle +import androidx.compose.material3.DropdownMenu +import androidx.compose.material3.DropdownMenuItem +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import com.seiko.imageloader.rememberImagePainter +import dev.icerock.moko.resources.compose.stringResource +import fr.androidmakers.domain.model.User +import fr.paug.androidmakers.ui.MR + +@Composable +actual fun SigninButton( + user: User?, + callbacks: SigninCallbacks, +) { + val expandedState = remember { mutableStateOf(false) } + + IconButton( + onClick = { + expandedState.value = true + } + ) { + if (user == null) { + Icon( + imageVector = Icons.Rounded.AccountCircle, + contentDescription = stringResource(MR.strings.signin) + ) + } else { + Image( + modifier = Modifier.clip(CircleShape), + painter = rememberImagePainter(user.photoUrl ?: ""), + contentDescription = stringResource(MR.strings.signout) + ) + } + } + + DropdownMenu( + expanded = expandedState.value, + onDismissRequest = { expandedState.value = false } + ) { + if (user == null) { + DropdownMenuItem( + text = { + Text(stringResource(MR.strings.signin)) + }, + onClick = { + expandedState.value = false + callbacks.signin() + } + ) + } else { + DropdownMenuItem( + text = { + Text(stringResource(MR.strings.signout)) + }, + onClick = { + expandedState.value = false + callbacks.signout() + } + ) + } + } +} diff --git a/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/common/SigninButton.kt b/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/common/SigninButton.kt index 74cbe249..843ca297 100644 --- a/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/common/SigninButton.kt +++ b/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/common/SigninButton.kt @@ -1,23 +1,7 @@ package com.androidmakers.ui.common -import androidx.compose.foundation.Image -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.rounded.AccountCircle -import androidx.compose.material3.DropdownMenu -import androidx.compose.material3.DropdownMenuItem -import androidx.compose.material3.Icon -import androidx.compose.material3.IconButton -import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import com.seiko.imageloader.rememberImagePainter -import dev.icerock.moko.resources.compose.stringResource import fr.androidmakers.domain.model.User -import fr.paug.androidmakers.ui.MR class SigninCallbacks( val signin: () -> Unit, @@ -25,55 +9,7 @@ class SigninCallbacks( ) @Composable -fun SigninButton( +expect fun SigninButton( user: User?, callbacks: SigninCallbacks, -) { - val expandedState = remember { mutableStateOf(false) } - - IconButton( - onClick = { - expandedState.value = true - } - ) { - if (user == null) { - Icon( - imageVector = Icons.Rounded.AccountCircle, - contentDescription = stringResource(MR.strings.signin) - ) - } else { - Image( - modifier = Modifier.clip(CircleShape), - painter = rememberImagePainter(user.photoUrl ?: ""), - contentDescription = stringResource(MR.strings.signout) - ) - } - } - - DropdownMenu( - expanded = expandedState.value, - onDismissRequest = { expandedState.value = false } - ) { - if (user == null) { - DropdownMenuItem( - text = { - Text(stringResource(MR.strings.signin)) - }, - onClick = { - expandedState.value = false - callbacks.signin() - } - ) - } else { - DropdownMenuItem( - text = { - Text(stringResource(MR.strings.signout)) - }, - onClick = { - expandedState.value = false - callbacks.signout() - } - ) - } - } -} \ No newline at end of file +) diff --git a/shared/ui/src/iosMain/kotlin/com/androidmakers/ui/MainLayoutViewController.kt b/shared/ui/src/iosMain/kotlin/com/androidmakers/ui/MainLayoutViewController.kt index 43c1d998..fa25b266 100644 --- a/shared/ui/src/iosMain/kotlin/com/androidmakers/ui/MainLayoutViewController.kt +++ b/shared/ui/src/iosMain/kotlin/com/androidmakers/ui/MainLayoutViewController.kt @@ -1,6 +1,7 @@ package com.androidmakers.ui import androidx.compose.ui.window.ComposeUIViewController +import com.androidmakers.ui.common.SigninCallbacks import com.androidmakers.ui.theme.AndroidMakersTheme import platform.UIKit.UIViewController @@ -9,9 +10,12 @@ fun MainLayoutViewController(): UIViewController = ComposeUIViewController { AndroidMakersTheme { MainLayout( - user = null, versionName = "1.0.0", versionCode = "1.0", + signinCallbacks = SigninCallbacks( + signin = {}, + signout = {} + ) ) } } diff --git a/shared/ui/src/iosMain/kotlin/com/androidmakers/ui/common/SigninButton.ios.kt b/shared/ui/src/iosMain/kotlin/com/androidmakers/ui/common/SigninButton.ios.kt new file mode 100644 index 00000000..6061e4b9 --- /dev/null +++ b/shared/ui/src/iosMain/kotlin/com/androidmakers/ui/common/SigninButton.ios.kt @@ -0,0 +1,11 @@ +package com.androidmakers.ui.common + +import androidx.compose.runtime.Composable +import fr.androidmakers.domain.model.User + +@Composable +actual fun SigninButton( + user: User?, + callbacks: SigninCallbacks +) { +}