-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
1,042 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
android/src/main/java/com/degica/komoju/android/sdk/ui/composables/TextButton.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.degica.komoju.android.sdk.ui.composables | ||
|
||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.ButtonDefaults | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Composable | ||
internal fun TextButton(modifier : Modifier = Modifier, text: String, onClick: () -> Unit) { | ||
Button( | ||
modifier = modifier, | ||
onClick = onClick, | ||
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.surface, contentColor = Color.Black), | ||
shape = RoundedCornerShape(8.dp), | ||
) { | ||
Text(modifier = Modifier.padding(8.dp), text = text, style = TextStyle(fontWeight = FontWeight.Normal), maxLines = 1) | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
android/src/main/java/com/degica/komoju/android/sdk/ui/screens/KomojuPaymentRoutes.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.degica.komoju.android.sdk.ui.screens | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import cafe.adriel.voyager.navigator.LocalNavigator | ||
import cafe.adriel.voyager.navigator.currentOrThrow | ||
import com.degica.komoju.android.sdk.KomojuSDK | ||
import com.degica.komoju.android.sdk.ui.screens.status.PaymentStatusScreen | ||
import com.degica.komoju.android.sdk.ui.screens.webview.WebViewScreen | ||
import com.degica.komoju.mobile.sdk.entities.Payment | ||
|
||
internal sealed class Router { | ||
data object Pop : Router() | ||
data object PopToRoot : Router() | ||
data class Push(val route: KomojuPaymentRoute) : Router() | ||
data class Replace(val route: KomojuPaymentRoute) : Router() | ||
data class ReplaceAll(val route: KomojuPaymentRoute) : Router() | ||
} | ||
|
||
internal sealed interface KomojuPaymentRoute { | ||
data class Status(val configuration: KomojuSDK.Configuration, val payment: Payment) : KomojuPaymentRoute | ||
data class WebView(val url: String, val canComeBack: Boolean = false) : KomojuPaymentRoute | ||
|
||
val screen | ||
get() = when (this) { | ||
is WebView -> WebViewScreen(this) | ||
is Status -> PaymentStatusScreen(this) | ||
} | ||
} | ||
|
||
@Composable | ||
internal fun RouterEffect(router: Router?, onHandled: () -> Unit) { | ||
val navigator = LocalNavigator.currentOrThrow | ||
LaunchedEffect(router) { | ||
when (router) { | ||
is Router.Pop -> navigator.pop() | ||
is Router.PopToRoot -> navigator.popUntilRoot() | ||
is Router.Push -> navigator.push(router.route.screen) | ||
is Router.Replace -> navigator.replace(router.route.screen) | ||
is Router.ReplaceAll -> navigator.replaceAll(router.route.screen) | ||
null -> Unit | ||
} | ||
onHandled() | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
android/src/main/java/com/degica/komoju/android/sdk/ui/screens/KomojuPaymentScreenNavHost.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.