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+ }
0 commit comments