-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* disabled favorite feature below 23 version * json parsed and architecture created for dynamic form * removed login changes * removed commented code
1 parent
eddc7bf
commit ffe9809
Showing
21 changed files
with
497 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,8 @@ android { | |
viewBinding = true | ||
} | ||
|
||
|
||
|
||
compileOptions { | ||
coreLibraryDesugaringEnabled true | ||
} | ||
|
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
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 @@ | ||
/build |
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,69 @@ | ||
plugins { | ||
id 'com.android.library' | ||
id 'org.jetbrains.kotlin.android' | ||
} | ||
|
||
android { | ||
namespace 'com.alfresco.content.process' | ||
compileSdk 33 | ||
|
||
defaultConfig { | ||
minSdk 26 | ||
targetSdk 33 | ||
vectorDrawables { | ||
useSupportLibrary true | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_17 | ||
targetCompatibility JavaVersion.VERSION_17 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '17' | ||
} | ||
|
||
buildFeatures { | ||
compose = true | ||
} | ||
|
||
composeOptions { | ||
kotlinCompilerExtensionVersion = "1.5.4" | ||
} | ||
packagingOptions { | ||
resources { | ||
excludes += '/META-INF/{AL2.0,LGPL2.1}' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation project(':base') | ||
implementation project(':common') | ||
implementation project(':data') | ||
|
||
implementation libs.androidx.core | ||
implementation libs.androidx.appcompat | ||
implementation libs.androidx.lifecycle.runtime | ||
implementation libs.activity.compose | ||
implementation platform(libs.compose.bom) | ||
implementation libs.ui | ||
implementation libs.ui.graphics | ||
implementation libs.ui.tooling.preview | ||
implementation libs.material3 | ||
|
||
implementation libs.navigation.compose | ||
implementation libs.mavericks.compose | ||
|
||
androidTestImplementation platform(libs.compose.bom) | ||
androidTestImplementation libs.ui.test.junit4 | ||
debugImplementation libs.ui.tooling | ||
debugImplementation libs.ui.test.manifest | ||
|
||
} |
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,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application> | ||
<activity | ||
android:name=".ProcessFormActivity" | ||
android:configChanges="orientation|screenSize" | ||
android:exported="false"/> | ||
</application> | ||
|
||
</manifest> |
63 changes: 63 additions & 0 deletions
63
process-app/src/main/kotlin/com/alfresco/content/process/FormViewModel.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,63 @@ | ||
package com.alfresco.content.process | ||
|
||
import android.content.Context | ||
import com.airbnb.mvrx.Async | ||
import com.airbnb.mvrx.Fail | ||
import com.airbnb.mvrx.Loading | ||
import com.airbnb.mvrx.MavericksState | ||
import com.airbnb.mvrx.MavericksViewModel | ||
import com.airbnb.mvrx.MavericksViewModelFactory | ||
import com.airbnb.mvrx.Success | ||
import com.airbnb.mvrx.Uninitialized | ||
import com.airbnb.mvrx.ViewModelContext | ||
import com.alfresco.content.data.ProcessEntry | ||
import com.alfresco.content.data.ResponseListForm | ||
import com.alfresco.content.data.TaskRepository | ||
import com.alfresco.coroutines.asFlow | ||
import kotlinx.coroutines.launch | ||
|
||
data class FormViewState( | ||
val parent: ProcessEntry, | ||
val requestStartForm: Async<ResponseListForm> = Uninitialized, | ||
) : MavericksState { | ||
constructor(target: ProcessEntry) : this(parent = target) | ||
} | ||
|
||
class FormViewModel( | ||
state: FormViewState, | ||
val context: Context, | ||
private val repository: TaskRepository, | ||
) : MavericksViewModel<FormViewState>(state) { | ||
|
||
init { | ||
getStartForm(state.parent) | ||
} | ||
|
||
private fun getStartForm(processEntry: ProcessEntry) { | ||
requireNotNull(processEntry.id) | ||
viewModelScope.launch { | ||
repository::startForm.asFlow(processEntry.id).execute { | ||
when (it) { | ||
is Loading -> copy(requestStartForm = Loading()) | ||
is Fail -> copy(requestStartForm = Fail(it.error)) | ||
is Success -> { | ||
println("form-data == ${it()}") | ||
copy(requestStartForm = Success(it())) | ||
} | ||
|
||
else -> { | ||
this | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
companion object : MavericksViewModelFactory<FormViewModel, FormViewState> { | ||
|
||
override fun create( | ||
viewModelContext: ViewModelContext, | ||
state: FormViewState, | ||
) = FormViewModel(state, viewModelContext.activity(), TaskRepository()) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
process-app/src/main/kotlin/com/alfresco/content/process/NavigationComponent.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.alfresco.content.process | ||
|
||
import android.os.Bundle | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.navigation.compose.NavHost | ||
import androidx.navigation.compose.composable | ||
import androidx.navigation.compose.rememberNavController | ||
import com.alfresco.content.process.ui.FormFragment | ||
|
||
@Composable | ||
fun NavigationComponent(extras: Bundle?) { | ||
val navController = rememberNavController() | ||
|
||
Surface(modifier = Modifier.fillMaxSize()) { | ||
NavHost(navController = navController, startDestination = "first_screen") { | ||
composable("first_screen") { | ||
// Replace with the content of your first fragment | ||
FormFragment(navController = navController, extras) | ||
} | ||
// Add more composable entries for other fragments in your navigation graph | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
process-app/src/main/kotlin/com/alfresco/content/process/ProcessFormActivity.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,34 @@ | ||
package com.alfresco.content.process | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import com.alfresco.content.process.ui.theme.AlfrescoBaseTheme | ||
|
||
class ProcessFormActivity : ComponentActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContent { | ||
AlfrescoBaseTheme { | ||
// A surface container using the 'background' color from the theme | ||
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) { | ||
NavigationComponent(intent.extras) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun GreetingPreview() { | ||
AlfrescoBaseTheme { | ||
NavigationComponent(null) | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
process-app/src/main/kotlin/com/alfresco/content/process/ui/FormFragment.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,72 @@ | ||
package com.alfresco.content.process.ui | ||
|
||
import android.os.Bundle | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TopAppBar | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.navigation.NavController | ||
import com.airbnb.mvrx.compose.mavericksActivityViewModel | ||
import com.alfresco.content.process.FormViewModel | ||
import com.alfresco.content.process.ui.components.TextInputField | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun FormFragment(navController: NavController, extras: Bundle?) { | ||
val context = LocalContext.current | ||
Scaffold( | ||
topBar = { | ||
TopAppBar( | ||
title = { | ||
Text(text = "Form Details") | ||
}, | ||
navigationIcon = { | ||
IconButton(onClick = { /* Handle navigation icon click */ }) { | ||
// Add navigation icon here | ||
} | ||
}, | ||
actions = { | ||
// Add actions if any | ||
}, | ||
) | ||
}, | ||
content = { padding -> | ||
FormDetailScreen(padding) | ||
}, | ||
) | ||
} | ||
|
||
@Composable | ||
fun FormDetailScreen(padding: PaddingValues) { | ||
// This will get or create a ViewModel scoped to the Activity. | ||
val viewModel: FormViewModel = mavericksActivityViewModel() | ||
|
||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(16.dp), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
) { | ||
TextInputField(1) | ||
// Add more Composables here based on your UI requirements | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun PreviewProcessDetailScreen() { | ||
FormDetailScreen(PaddingValues(16.dp)) | ||
} |
19 changes: 19 additions & 0 deletions
19
process-app/src/main/kotlin/com/alfresco/content/process/ui/components/ComponentSettings.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,19 @@ | ||
package com.alfresco.content.process.ui.components | ||
|
||
data class ComponentSettings( | ||
val id: String, | ||
val placeHolder: String, | ||
val isRequired: Boolean, | ||
val isReadOnly: Boolean, | ||
val value: String, | ||
val minLength: Int, | ||
val maxLength: Int, | ||
val minValue: String, | ||
val maxValue: String, | ||
val options: ComponentOptions, | ||
) | ||
|
||
data class ComponentOptions( | ||
val id: String, | ||
val name: String, | ||
) |
33 changes: 33 additions & 0 deletions
33
process-app/src/main/kotlin/com/alfresco/content/process/ui/components/TextInputField.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,33 @@ | ||
package com.alfresco.content.process.ui.components | ||
|
||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.text.KeyboardOptions | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.OutlinedTextField | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.input.KeyboardType | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun TextInputField(maxLines: Int) { | ||
OutlinedTextField( | ||
value = "", // Initial value of the text field | ||
onValueChange = { /* Handle value changes here */ }, | ||
modifier = Modifier.padding(16.dp), // Add padding or other modifiers as needed | ||
label = { Text("Enter text") }, // Label for the text field | ||
placeholder = { Text("Type something") }, // Placeholder text | ||
maxLines = maxLines, // Set the maximum number of lines to 1 | ||
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Text), // Set keyboard type | ||
// Other optional parameters like keyboardOptions, keyboardActions, etc., can be added as needed | ||
) | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun TextInputFieldPreview() { | ||
TextInputField(1) | ||
} |
24 changes: 24 additions & 0 deletions
24
process-app/src/main/kotlin/com/alfresco/content/process/ui/theme/Color.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,24 @@ | ||
package com.alfresco.content.process.ui.theme | ||
|
||
import androidx.compose.ui.graphics.Color | ||
|
||
val AlfrescoBlue900 = Color(0xFF1A43A9) | ||
val AlfrescoBlue700 = Color(0xFF1F74DB) | ||
val AlfrescoBlue300 = Color(0xFF6EACFF) | ||
|
||
val AlfrescoGray900 = Color(0xFF212328) | ||
|
||
val AlfrescoGray90015 = Color(0x26212328) | ||
val AlfrescoGray90030 = Color(0x4D212328) | ||
val AlfrescoGray90060 = Color(0x99212328) | ||
val AlfrescoGray90070 = Color(0xB3212328) | ||
val AlfrescoGray100 = Color(0xFFF5F5F5) | ||
|
||
val AlfrescoError = Color(0xFFB8082A) | ||
|
||
val Transparent = Color.Transparent | ||
val White = Color.White | ||
val White15 = Color(0x26FFFFFF) | ||
val White60 = Color(0x99FFFFFF) | ||
val ActionModeColor = AlfrescoBlue700 // Using AlfrescoBlue700 as action mode color | ||
val SeparateColorGray = Color(0xFF212121) |
74 changes: 74 additions & 0 deletions
74
process-app/src/main/kotlin/com/alfresco/content/process/ui/theme/Theme.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,74 @@ | ||
package com.alfresco.content.process.ui.theme | ||
|
||
import android.app.Activity | ||
import android.os.Build | ||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.darkColorScheme | ||
import androidx.compose.material3.dynamicDarkColorScheme | ||
import androidx.compose.material3.dynamicLightColorScheme | ||
import androidx.compose.material3.lightColorScheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.SideEffect | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.toArgb | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.platform.LocalView | ||
import androidx.core.view.WindowCompat | ||
|
||
private val DarkColorScheme = darkColorScheme( | ||
primary = Color.White, | ||
) | ||
private val LightColorScheme = lightColorScheme( | ||
primary = AlfrescoBlue700, // Replace with your alfresco_blue_700 color | ||
surface = Color.White, | ||
onSurface = Color(0xFF212121), // Replace with your alfresco_gray_900 color | ||
background = Color.White, | ||
onBackground = Color.Black, | ||
|
||
/* Other default colors to override | ||
background = Color(0xFFFFFBFE), | ||
surface = Color(0xFFFFFBFE), | ||
onPrimary = Color.White, | ||
onSecondary = Color.White, | ||
onTertiary = Color.White, | ||
onBackground = Color(0xFF1C1B1F), | ||
onSurface = Color(0xFF1C1B1F), | ||
*/ | ||
) | ||
|
||
@Composable | ||
fun AlfrescoBaseTheme( | ||
darkTheme: Boolean = isSystemInDarkTheme(), | ||
// Dynamic color is available on Android 12+ | ||
dynamicColor: Boolean = true, | ||
content: @Composable () -> Unit, | ||
) { | ||
val colorScheme = when { | ||
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { | ||
val context = LocalContext.current | ||
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) | ||
} | ||
|
||
darkTheme -> DarkColorScheme.copy( | ||
secondary = MaterialTheme.colorScheme.primary, // | ||
) | ||
else -> LightColorScheme.copy( | ||
secondary = MaterialTheme.colorScheme.primary, // | ||
) | ||
} | ||
val view = LocalView.current | ||
if (!view.isInEditMode) { | ||
SideEffect { | ||
val window = (view.context as Activity).window | ||
window.statusBarColor = colorScheme.primary.toArgb() | ||
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme | ||
} | ||
} | ||
|
||
MaterialTheme( | ||
colorScheme = colorScheme, | ||
typography = Typography, | ||
content = content, | ||
) | ||
} |
34 changes: 34 additions & 0 deletions
34
process-app/src/main/kotlin/com/alfresco/content/process/ui/theme/Type.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,34 @@ | ||
package com.alfresco.content.process.ui.theme | ||
|
||
import androidx.compose.material3.Typography | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontFamily | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.sp | ||
|
||
// Set of Material typography styles to start with | ||
val Typography = Typography( | ||
bodyLarge = TextStyle( | ||
fontFamily = FontFamily.Default, | ||
fontWeight = FontWeight.Normal, | ||
fontSize = 16.sp, | ||
lineHeight = 24.sp, | ||
letterSpacing = 0.5.sp, | ||
), | ||
/* Other default text styles to override | ||
titleLarge = TextStyle( | ||
fontFamily = FontFamily.Default, | ||
fontWeight = FontWeight.Normal, | ||
fontSize = 22.sp, | ||
lineHeight = 28.sp, | ||
letterSpacing = 0.sp | ||
), | ||
labelSmall = TextStyle( | ||
fontFamily = FontFamily.Default, | ||
fontWeight = FontWeight.Medium, | ||
fontSize = 11.sp, | ||
lineHeight = 16.sp, | ||
letterSpacing = 0.5.sp | ||
) | ||
*/ | ||
) |
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,2 @@ | ||
<resources> | ||
</resources> |
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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<style name="Theme.Alfrescomobileworkspaceandroid" parent="android:Theme.Material.Light.NoActionBar" /> | ||
</resources> |
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