Skip to content

Commit 069aeea

Browse files
Updated example app
1 parent 28c96a9 commit 069aeea

File tree

7 files changed

+230
-23
lines changed

7 files changed

+230
-23
lines changed

app/build.gradle

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
3-
apply plugin: 'kotlin-android-extensions'
43

54
android {
65
compileSdkVersion 33
@@ -10,8 +9,8 @@ android {
109
compose true
1110
}
1211
composeOptions {
13-
kotlinCompilerExtensionVersion '1.3.2'
14-
kotlinCompilerVersion '1.7.20'
12+
kotlinCompilerExtensionVersion '1.4.3'
13+
kotlinCompilerVersion '1.8.10'
1514
}
1615

1716
defaultConfig {
@@ -47,30 +46,30 @@ dependencies {
4746
implementation fileTree(dir: "libs", include: ["*.jar"])
4847

4948
//Dapi
50-
implementation 'co.dapi:connect:2.30.1'
49+
implementation 'co.dapi:connect:2.33.0'
5150

5251
// Compose
53-
implementation "androidx.compose.runtime:runtime:1.3.0"
54-
implementation "androidx.compose.ui:ui:1.3.0"
55-
implementation "androidx.compose.foundation:foundation:1.3.0"
56-
implementation "androidx.compose.foundation:foundation-layout:1.3.0"
57-
implementation "androidx.compose.material:material:1.3.0"
58-
implementation "androidx.compose.ui:ui-tooling:1.3.0"
59-
implementation "com.google.android.material:compose-theme-adapter:1.1.21"
52+
implementation "androidx.compose.runtime:runtime:1.3.3"
53+
implementation "androidx.compose.ui:ui:1.3.3"
54+
implementation "androidx.compose.foundation:foundation:1.3.1"
55+
implementation "androidx.compose.foundation:foundation-layout:1.3.1"
56+
implementation "androidx.compose.material:material:1.3.1"
57+
implementation "androidx.compose.ui:ui-tooling:1.3.3"
58+
implementation "com.google.android.material:compose-theme-adapter:1.2.1"
6059
implementation "androidx.activity:activity-compose:1.6.1"
6160
implementation "io.coil-kt:coil-compose:2.0.0"
6261
implementation "androidx.navigation:navigation-compose:2.5.3"
63-
implementation "androidx.compose.ui:ui-tooling-preview:1.3.0"
64-
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"
62+
implementation "androidx.compose.ui:ui-tooling-preview:1.3.3"
63+
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.0"
6564
implementation "androidx.multidex:multidex:2.0.1"
6665
implementation "androidx.core:core-ktx:1.9.0"
67-
implementation "androidx.compose.runtime:runtime-livedata:1.3.0"
66+
implementation "androidx.compose.runtime:runtime-livedata:1.3.3"
6867

6968
//Android Architecture Components
7069
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
71-
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
70+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.0"
7271

7372
testImplementation "junit:junit:4.13.2"
74-
androidTestImplementation "androidx.test.ext:junit:1.1.3"
75-
androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"
73+
androidTestImplementation "androidx.test.ext:junit:1.1.5"
74+
androidTestImplementation "androidx.test.espresso:espresso-core:3.5.1"
7675
}
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
package com.dapi.dapiconnect.home
2+
3+
import androidx.compose.foundation.layout.Arrangement
4+
import androidx.compose.foundation.layout.Column
5+
import androidx.compose.foundation.layout.fillMaxWidth
6+
import androidx.compose.foundation.layout.padding
7+
import androidx.compose.foundation.rememberScrollState
8+
import androidx.compose.foundation.verticalScroll
9+
import androidx.compose.material.Text
10+
import androidx.compose.material.TextField
11+
import androidx.compose.runtime.*
12+
import androidx.compose.ui.Alignment
13+
import androidx.compose.ui.Modifier
14+
import androidx.compose.ui.text.input.TextFieldValue
15+
import androidx.compose.ui.unit.dp
16+
import co.dapi.connect.core.base.Dapi
17+
import co.dapi.connect.data.models.DapiEnvironment
18+
import co.dapi.connect.data.models.DapiLanguage
19+
import co.dapi.connect.data.models.DapiTheme
20+
import com.dapi.dapiconnect.home.components.ConfigurationCheckbox
21+
22+
@Composable
23+
fun ConfigurationsScreen() {
24+
val isSandboxChecked =
25+
remember { mutableStateOf(Dapi.configurations.environment == DapiEnvironment.SANDBOX) }
26+
val isShowLogosChecked = remember { mutableStateOf(Dapi.configurations.showLogos) }
27+
val isShowExperimentalBanksChecked =
28+
remember { mutableStateOf(Dapi.configurations.showExperimentalBanks) }
29+
val isShowCloseButtonChecked =
30+
remember { mutableStateOf(Dapi.configurations.showCloseButton) }
31+
val isShowAddButtonChecked = remember { mutableStateOf(Dapi.configurations.showAddButton) }
32+
val isShowTransferSuccessfulResultChecked =
33+
remember { mutableStateOf(Dapi.configurations.showTransferSuccessfulResult) }
34+
val isShowTransferErrorResultChecked =
35+
remember { mutableStateOf(Dapi.configurations.showTransferErrorResult) }
36+
var theme by remember { mutableStateOf(TextFieldValue(Dapi.configurations.theme.enforceTheme.name)) }
37+
var lightPrimaryColor by remember {
38+
mutableStateOf(
39+
TextFieldValue(
40+
Dapi.configurations.theme.primaryColor.lightMode ?: ""
41+
)
42+
)
43+
}
44+
var darkPrimaryColor by remember {
45+
mutableStateOf(
46+
TextFieldValue(
47+
Dapi.configurations.theme.primaryColor.darkMode ?: ""
48+
)
49+
)
50+
}
51+
var language by remember { mutableStateOf(TextFieldValue(Dapi.configurations.language.name)) }
52+
53+
54+
Column(
55+
horizontalAlignment = Alignment.Start,
56+
verticalArrangement = Arrangement.SpaceEvenly,
57+
modifier = Modifier.verticalScroll(rememberScrollState())
58+
) {
59+
ConfigurationCheckbox(isSandboxChecked, "Sandbox") {
60+
Dapi.configurations.environment =
61+
if (it) DapiEnvironment.SANDBOX else DapiEnvironment.PRODUCTION
62+
}
63+
64+
ConfigurationCheckbox(isShowLogosChecked, "Show Logos") {
65+
Dapi.configurations.showLogos = it
66+
}
67+
68+
ConfigurationCheckbox(isShowExperimentalBanksChecked, "Show Experimental Banks") {
69+
Dapi.configurations.showExperimentalBanks = it
70+
}
71+
72+
ConfigurationCheckbox(isShowCloseButtonChecked, "Show Close Button") {
73+
Dapi.configurations.showCloseButton = it
74+
}
75+
76+
ConfigurationCheckbox(isShowAddButtonChecked, "Show Add Button") {
77+
Dapi.configurations.showAddButton = it
78+
}
79+
80+
ConfigurationCheckbox(
81+
isShowTransferSuccessfulResultChecked,
82+
"Show Transfer Successful Result"
83+
) {
84+
Dapi.configurations.showTransferSuccessfulResult = it
85+
}
86+
87+
ConfigurationCheckbox(isShowTransferErrorResultChecked, "Show Transfer Error Result") {
88+
Dapi.configurations.showTransferErrorResult = it
89+
}
90+
91+
TextField(
92+
modifier = Modifier.padding(all = 16.dp).fillMaxWidth(),
93+
value = theme,
94+
label = { Text(text = "Theme: LIGHT, DARK, DYNAMIC") },
95+
onValueChange = {
96+
theme = it
97+
when (theme.text.lowercase()) {
98+
"light" -> {
99+
Dapi.configurations.theme.enforceTheme = DapiTheme.LIGHT
100+
}
101+
"dark" -> {
102+
Dapi.configurations.theme.enforceTheme = DapiTheme.DARK
103+
}
104+
else -> {
105+
Dapi.configurations.theme.enforceTheme = DapiTheme.DYNAMIC
106+
}
107+
}
108+
}
109+
)
110+
111+
TextField(
112+
modifier = Modifier.padding(all = 16.dp).fillMaxWidth(),
113+
value = lightPrimaryColor,
114+
label = { Text(text = "Light Primary Color #xxxxxx") },
115+
onValueChange = {
116+
lightPrimaryColor = it
117+
if (lightPrimaryColor.text.matches(Regex("^#(?:[0-9a-fA-F]{3}){1,2}\$")))
118+
Dapi.configurations.theme.primaryColor.lightMode = lightPrimaryColor.text
119+
}
120+
)
121+
122+
TextField(
123+
modifier = Modifier.padding(all = 16.dp).fillMaxWidth(),
124+
value = darkPrimaryColor,
125+
label = { Text(text = "Dark Primary Color #xxxxxx") },
126+
onValueChange = {
127+
darkPrimaryColor = it
128+
if (darkPrimaryColor.text.matches(Regex("^#(?:[0-9a-fA-F]{3}){1,2}\$")))
129+
Dapi.configurations.theme.primaryColor.darkMode = darkPrimaryColor.text
130+
}
131+
)
132+
133+
TextField(
134+
modifier = Modifier.padding(all = 16.dp).fillMaxWidth(),
135+
value = language,
136+
label = { Text(text = "Language: AR, EN") },
137+
onValueChange = {
138+
language = it
139+
when (language.text.lowercase()) {
140+
"ar" -> {
141+
Dapi.configurations.language = DapiLanguage.AR
142+
}
143+
else -> {
144+
Dapi.configurations.language = DapiLanguage.EN
145+
}
146+
}
147+
}
148+
)
149+
}
150+
151+
152+
}

app/src/main/java/com/dapi/dapiconnect/home/HomeScreen.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,22 @@ fun HomeScreen(
8181
text = "Connect With Dapi",
8282
modifier = Modifier
8383
.fillMaxWidth()
84-
.padding(all = 24.dp),
84+
.padding(start = 24.dp, end = 24.dp, top = 24.dp),
8585
onClick = {
8686
onConnect()
8787
}
8888
)
8989

90+
MainActionButton(
91+
text = "Edit Configurations",
92+
modifier = Modifier
93+
.fillMaxWidth()
94+
.padding(start = 24.dp, end = 24.dp, bottom = 24.dp, top = 2.dp),
95+
onClick = {
96+
navController.navigate(Screen.Configurations.route)
97+
}
98+
)
99+
90100
SnackbarHost(
91101
hostState = snackbarHostState,
92102
)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.dapi.dapiconnect.home.components
2+
3+
import androidx.compose.foundation.layout.Arrangement
4+
import androidx.compose.foundation.layout.Row
5+
import androidx.compose.foundation.layout.fillMaxWidth
6+
import androidx.compose.foundation.layout.padding
7+
import androidx.compose.material.Checkbox
8+
import androidx.compose.material.Text
9+
import androidx.compose.runtime.Composable
10+
import androidx.compose.runtime.MutableState
11+
import androidx.compose.ui.Alignment
12+
import androidx.compose.ui.Modifier
13+
import androidx.compose.ui.unit.dp
14+
15+
@Composable
16+
fun ConfigurationCheckbox(
17+
configuration: MutableState<Boolean>,
18+
text: String,
19+
onCheckedChange: (Boolean) -> Unit
20+
) {
21+
Row(
22+
horizontalArrangement = Arrangement.Start,
23+
verticalAlignment = Alignment.CenterVertically,
24+
modifier = Modifier.fillMaxWidth()
25+
) {
26+
Checkbox(
27+
modifier = Modifier.padding(horizontal = 16.dp),
28+
checked = configuration.value,
29+
onCheckedChange = {
30+
configuration.value = it
31+
onCheckedChange(it)
32+
}
33+
)
34+
35+
Text(text = text)
36+
}
37+
}

app/src/main/java/com/dapi/dapiconnect/navigation/Navigation.kt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import com.dapi.dapiconnect.api.payment.create_beneficiary.CreateBeneficiaryScre
1818
import com.dapi.dapiconnect.api.wire.WireScreen
1919
import com.dapi.dapiconnect.api.wire.beneficiaries.WireBeneficiariesScreen
2020
import com.dapi.dapiconnect.api.wire.create_beneficiary.CreateWireBeneficiaryScreen
21+
import com.dapi.dapiconnect.home.ConfigurationsScreen
2122
import com.dapi.dapiconnect.home.HomeScreen
2223

2324
@Composable
@@ -31,10 +32,17 @@ fun AppNavigation(
3132
) {
3233
HomeScreen(
3334
viewModel = viewModel,
34-
navController = navController
35-
) {
36-
viewModel.presentConnect()
37-
}
35+
navController = navController,
36+
onConnect = {
37+
viewModel.presentConnect()
38+
}
39+
)
40+
}
41+
42+
composable(
43+
route = Screen.Configurations.route
44+
) {
45+
ConfigurationsScreen()
3846
}
3947

4048
composable(

app/src/main/java/com/dapi/dapiconnect/navigation/Screen.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.dapi.dapiconnect.navigation
33

44
sealed class Screen(val route: String) {
55
object Home : Screen("home_screen")
6+
object Configurations : Screen("configurations_screen")
67
object APIs : Screen("apis_screen")
78
object Data : Screen("data_screen")
89
object Metadata : Screen("metadata_screen")

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
buildscript {
3-
ext.kotlin_version = '1.7.20'
3+
ext.kotlin_version = '1.8.10'
44
repositories {
55
mavenCentral()
66
google()

0 commit comments

Comments
 (0)