Skip to content

Commit

Permalink
Disabled iOS Sign In
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Robiez committed Apr 12, 2024
1 parent ef50b7d commit 2e6f80f
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -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()
}
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,79 +1,15 @@
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,
val signout: () -> Unit,
)

@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()
}
)
}
}
}
)
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -9,9 +10,12 @@ fun MainLayoutViewController(): UIViewController =
ComposeUIViewController {
AndroidMakersTheme {
MainLayout(
user = null,
versionName = "1.0.0",
versionCode = "1.0",
signinCallbacks = SigninCallbacks(
signin = {},
signout = {}
)
)
}
}
Original file line number Diff line number Diff line change
@@ -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
) {
}

0 comments on commit 2e6f80f

Please sign in to comment.