Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled iOS Sign In #258

Merged
merged 1 commit into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
) {
}
Loading