mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
WIP
This commit is contained in:
parent
784bf8e8e7
commit
ee6fed85c3
4 changed files with 121 additions and 13 deletions
|
|
@ -9,3 +9,24 @@ object DatastoreKeys {
|
|||
const val omnivoreAuthToken = "omnivoreAuthToken"
|
||||
const val omnivoreAuthCookieString = "omnivoreAuthCookieString"
|
||||
}
|
||||
|
||||
object AppleConstants {
|
||||
const val clientId = "app.omnivore"
|
||||
const val redirectURI = "MY_REDIRECT_URI"
|
||||
const val scope = "name%20email"
|
||||
const val authUrl = "https://appleid.apple.com/auth/authorize"
|
||||
const val tokenUrl = "https://appleid.apple.com/auth/token"
|
||||
}
|
||||
|
||||
//clientId="app.omnivore"
|
||||
//scope="name email"
|
||||
//state="web:login"
|
||||
//redirectURI={appleAuthRedirectURI}
|
||||
//responseMode="form_post"
|
||||
//responseType="code id_token"
|
||||
//designProp={{
|
||||
// color: 'black',
|
||||
// width: 261,
|
||||
// height: 40,
|
||||
// type: 'continue',
|
||||
//}}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,99 @@
|
|||
package app.omnivore.omnivore.ui.auth
|
||||
|
||||
import android.view.ViewGroup
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Done
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import app.omnivore.omnivore.R
|
||||
|
||||
@Composable
|
||||
fun AppleAuthButton(viewModel: LoginViewModel) {
|
||||
var showDialog = remember { mutableStateOf(false) }
|
||||
|
||||
LoadingButtonWithIcon(
|
||||
text = "Continue with Apple",
|
||||
loadingText = "Signing in...",
|
||||
isLoading = viewModel.isLoading,
|
||||
icon = painterResource(id = R.drawable.ic_logo_apple),
|
||||
modifier = Modifier.padding(vertical = 6.dp),
|
||||
onClick = { showDialog.value = true }
|
||||
)
|
||||
|
||||
if (showDialog.value) {
|
||||
AppleAuthDialog(setShowDialog = {
|
||||
showDialog.value = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun AppleAuthDialog(setShowDialog: (Boolean) -> Unit) {
|
||||
Dialog(onDismissRequest = { setShowDialog(false) }) {
|
||||
Surface(
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
color = Color.White
|
||||
) {
|
||||
AppleAuthWebView()
|
||||
// Box(
|
||||
// contentAlignment = Alignment.Center
|
||||
// ) {
|
||||
// Column(modifier = Modifier.padding(20.dp)) {
|
||||
// Row(
|
||||
// modifier = Modifier.fillMaxWidth(),
|
||||
// horizontalArrangement = Arrangement.SpaceBetween,
|
||||
// verticalAlignment = Alignment.CenterVertically
|
||||
// ) {
|
||||
// Icon(
|
||||
// imageVector = Icons.Filled.Done,
|
||||
// contentDescription = "",
|
||||
// tint = colorResource(android.R.color.darker_gray),
|
||||
// modifier = Modifier
|
||||
// .width(30.dp)
|
||||
// .height(30.dp)
|
||||
// .clickable { setShowDialog(false) }
|
||||
// )
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun AppleAuthWebView() {
|
||||
// Declare a string that contains a url
|
||||
val mUrl = "https://omnivore.app"
|
||||
|
||||
// Adding a WebView inside AndroidView
|
||||
// with layout as full screen
|
||||
AndroidView(factory = {
|
||||
WebView(it).apply {
|
||||
layoutParams = ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
webViewClient = WebViewClient()
|
||||
loadUrl(mUrl)
|
||||
}
|
||||
}, update = {
|
||||
it.loadUrl(mUrl)
|
||||
})
|
||||
}
|
||||
|
|
@ -15,8 +15,6 @@ import com.google.android.gms.auth.api.signin.GoogleSignInAccount
|
|||
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
|
||||
import com.google.android.gms.tasks.Task
|
||||
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@Composable
|
||||
fun GoogleAuthButton(viewModel: LoginViewModel) {
|
||||
val context = LocalContext.current
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import androidx.compose.foundation.background
|
|||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.text.ClickableText
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
|
|
@ -24,9 +23,7 @@ import androidx.compose.ui.text.SpanStyle
|
|||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.style.TextDecoration
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.navigation.NavHostController
|
||||
import app.omnivore.omnivore.R
|
||||
import app.omnivore.omnivore.Routes
|
||||
import com.google.android.gms.common.GoogleApiAvailability
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
|
@ -140,14 +137,7 @@ fun AuthProviderView(
|
|||
GoogleAuthButton(viewModel)
|
||||
}
|
||||
|
||||
// Disable apple auth for now
|
||||
// LoadingButtonWithIcon(
|
||||
// text = "Continue with Apple",
|
||||
// loadingText = "Signing in...",
|
||||
// icon = painterResource(id = R.drawable.ic_logo_apple),
|
||||
// modifier = Modifier.padding(vertical = 6.dp),
|
||||
// onClick = {}
|
||||
// )
|
||||
// AppleAuthButton(viewModel)
|
||||
|
||||
ClickableText(
|
||||
text = AnnotatedString("Continue with Email"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue