Skip to content

Commit

Permalink
Update ui module (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
n3gbx authored Feb 9, 2024
1 parent 38bcfc1 commit 473fa21
Show file tree
Hide file tree
Showing 98 changed files with 1,093 additions and 2,057 deletions.
51 changes: 23 additions & 28 deletions app/src/main/java/org/expenny/custom/ExpennyExceptionActivity.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
package org.expenny.custom

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
Expand All @@ -20,11 +27,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.core.view.WindowCompat
import org.expenny.core.resources.R
import org.expenny.core.ui.foundation.ExpennyButton
import org.expenny.core.ui.foundation.ExpennyText
import org.expenny.core.ui.foundation.model.button.ExpennyFlatButtonAttributes
import org.expenny.core.ui.foundation.model.button.ExpennyFlatButtonSize
import org.expenny.core.ui.foundation.model.button.ExpennyFlatButtonType
import org.expenny.core.ui.foundation.ExpennyFlatButton
import org.expenny.core.ui.theme.ExpennyTheme
import org.expenny.main.MainActivity

Expand Down Expand Up @@ -69,34 +72,26 @@ private fun ExceptionContent(
tint = MaterialTheme.colorScheme.primary,
contentDescription = null
)
ExpennyText(
Text(
text = "Unexpected Error Occurred",
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onSurface
style = MaterialTheme.typography.titleLarge
)
ExpennyText(
Text(
text = "Sorry for inconvenience. Please report this error to us.",
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurface
style = MaterialTheme.typography.bodyMedium
)
ExpennyButton(
ExpennyFlatButton(
modifier = Modifier.width(200.dp),
onClick = {},
attributes = ExpennyFlatButtonAttributes(
type = ExpennyFlatButtonType.Primary,
size = ExpennyFlatButtonSize.Large,
label = "Report"
)
label = {
Text(text = "Report")
}
)
ExpennyText(
modifier = Modifier.clickable {
onRestartClick()
},
text = "Restart app",
color = MaterialTheme.colorScheme.onSurface,
style = MaterialTheme.typography.bodyMedium.copy(
textDecoration = TextDecoration.Underline
),
Text(
modifier = Modifier.clickable { onRestartClick() },
text = "Sorry for inconvenience. Please report this error to us.",
style = MaterialTheme.typography.labelLarge,
textDecoration = TextDecoration.Underline
)
}
}
Expand Down
10 changes: 2 additions & 8 deletions app/src/main/java/org/expenny/main/MainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.annotation.SuppressLint
import androidx.activity.compose.BackHandler
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.material3.*
import androidx.compose.material3.DrawerState
Expand All @@ -14,13 +13,8 @@ import androidx.compose.material3.rememberDrawerState
import androidx.compose.runtime.*
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import androidx.navigation.*
import androidx.navigation.compose.rememberNavController
import com.google.accompanist.navigation.material.BottomSheetNavigator
import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi
import com.google.accompanist.navigation.material.ModalBottomSheetLayout
import com.google.accompanist.navigation.material.rememberBottomSheetNavigator
import org.expenny.core.common.ExpennySnackbarManager
import org.expenny.core.ui.foundation.ExpennySnackbar
import com.ramcosta.composedestinations.spec.NavGraphSpec
Expand All @@ -30,7 +24,7 @@ import kotlinx.coroutines.delay
import org.expenny.navigation.*
import org.expenny.navigation.ExpennyNavigation
import org.expenny.core.ui.utils.ExpennyDrawerState
import org.expenny.main.drawer.ExpennyNavigationDrawer
import org.expenny.main.drawer.MainNavigationDrawer
import org.expenny.main.drawer.DrawerTab

@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
Expand Down Expand Up @@ -63,7 +57,7 @@ internal fun MainScreen(startRoute: Route) {
if (state.drawerState.isDrawerTabAsState) {
val currentSelectedTab by navController.currentTabAsState()

ExpennyNavigationDrawer(
MainNavigationDrawer(
currentTab = currentSelectedTab,
onTabSelect = {
state.drawerState.animateTo(DrawerValue.Closed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,36 @@ import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.material3.Divider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
Expand All @@ -27,14 +50,13 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.ramcosta.composedestinations.spec.NavGraphSpec
import org.expenny.core.resources.R
import org.expenny.core.ui.foundation.ExpennyText
import org.expenny.navigation.ExpennyNavGraphs
import org.expenny.main.drawer.DrawerSection.Main
import org.expenny.main.drawer.DrawerSection.Others
import org.expenny.navigation.ExpennyNavGraphs


@Composable
internal fun ExpennyNavigationDrawer(
internal fun MainNavigationDrawer(
currentTab: NavGraphSpec,
onTabSelect: (NavGraphSpec) -> Unit
) {
Expand Down Expand Up @@ -90,12 +112,10 @@ private fun NavigationDrawerHeader(
.padding(horizontal = optionHorizontalPadding),
contentAlignment = Alignment.Center,
) {
ExpennyText(
Text(
text = stringResource(R.string.menu_label),
style = MaterialTheme.typography.titleLarge.copy(
textAlign = TextAlign.Center
),
color = MaterialTheme.colorScheme.onSurface
style = MaterialTheme.typography.titleLarge,
textAlign = TextAlign.Center
)
}
}
Expand Down Expand Up @@ -259,15 +279,13 @@ private fun NavigationDrawerOption(
tint = iconColor,
contentDescription = null
)

Box(modifier = Modifier.weight(1f)) {
ExpennyText(
Text(
text = label,
color = labelColor,
style = labelStyle
)
}

trailingContent()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,35 @@ package org.expenny.core.ui.components

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.windowInsetsBottomHeight
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.layout.windowInsetsTopHeight
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.BottomSheetDefaults
import androidx.compose.material3.BottomSheetScaffold
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.SheetState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.unit.dp
import com.google.accompanist.navigation.material.ModalBottomSheetLayout
import org.expenny.core.ui.foundation.ExpennyText

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ExpennyActionsBottomSheet(
modifier: Modifier = Modifier,
sheetState: SheetState,
header: @Composable (() -> Unit)? = { BottomSheetDefaults.DragHandle() },
onDismiss: () -> Unit,
header: @Composable (() -> Unit)? = { BottomSheetDefaults.DragHandle() },
content: @Composable ColumnScope.() -> Unit,
) {
// Declaring insets outside of modal bottom sheet scope because it doesn't expose WindowInsets
Expand Down Expand Up @@ -85,10 +73,9 @@ fun ExpennyActionsBottomSheetItem(
contentDescription = null
)
}
ExpennyText(
Text(
text = label,
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurface
style = MaterialTheme.typography.bodyLarge
)
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
package org.expenny.core.ui.foundation
package org.expenny.core.ui.components

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Checkbox
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.LocalMinimumInteractiveComponentEnforcement
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp


@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ExpennyCheckBoxGroup(
modifier: Modifier = Modifier,
Expand Down Expand Up @@ -47,16 +55,17 @@ fun ExpennyCheckBoxGroup(
verticalAlignment = Alignment.Top,
horizontalArrangement = Arrangement.spacedBy(16.dp)
) {
ExpennyCheckBox(
isChecked = isChecked,
isEnabled = isEnabled,
onClick = onClick
)
ExpennyText(
CompositionLocalProvider(LocalMinimumInteractiveComponentEnforcement provides false) {
Checkbox(
enabled = isEnabled,
checked = isChecked,
onCheckedChange = onClick,
)
}
Text(
text = labelText,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
maxLines = Int.MAX_VALUE,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
error?.let {
Expand Down
Loading

0 comments on commit 473fa21

Please sign in to comment.