Skip to content

Commit

Permalink
Tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
erikeelde committed Sep 30, 2023
1 parent f6499b9 commit 6d7a67a
Show file tree
Hide file tree
Showing 13 changed files with 229 additions and 189 deletions.
1 change: 1 addition & 0 deletions modules/booleanconfiguration/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies {
implementation(libs.androidx.appcompat)
implementation(libs.androidx.navigation.navigation.compose)
implementation(libs.androidx.hilt.hilt.navigation.compose)
implementation(libs.androidx.lifecycle.lifecycle.runtime.compose)
implementation(libs.androidx.compose.runtime)
implementation(libs.androidx.compose.material3)
debugImplementation(libs.androidx.compose.ui.ui.tooling)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,64 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment.Companion.End
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import kotlinx.coroutines.launch

@OptIn(ExperimentalMaterial3Api::class)
@Composable
@Suppress("LongParameterList")
fun BooleanValueView(
modifier: Modifier = Modifier,
viewModel: FragmentBooleanValueViewModel = hiltViewModel(),
back: () -> Unit,
) {
val viewState by viewModel.state.collectAsStateWithLifecycle()
Scaffold(
topBar = {
TopAppBar(
title = { Text("") },
navigationIcon =
{
IconButton(onClick = { back() }) {
Icon(
imageVector = Icons.Filled.ArrowBack,
contentDescription = null
)
}
}
)
},
) { paddingValues ->
BooleanValueView(
uiState = viewState,
popBackStack = { back() },
revert = { viewModel.revertClick() },
save = { viewModel.saveClick() },
setBooleanValue = { viewModel.checkedChanged(it) },
modifier = modifier.padding(paddingValues),
)
}
}
@Composable
@Suppress("LongParameterList")
internal fun BooleanValueView(
uiState: ViewState,
popBackStack: () -> Unit,
setBooleanValue: (Boolean) -> Unit,
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions modules/enumconfiguration/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies {
implementation(libs.androidx.appcompat)
implementation(libs.androidx.navigation.navigation.compose)
implementation(libs.androidx.hilt.hilt.navigation.compose)
implementation(libs.androidx.lifecycle.lifecycle.runtime.compose)
implementation(libs.androidx.compose.runtime)
implementation(libs.androidx.compose.material3)
debugImplementation(libs.androidx.compose.ui.ui.tooling)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,63 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.ListItem
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import kotlinx.coroutines.launch

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun EnumValueView(
modifier: Modifier = Modifier,
viewModel: FragmentEnumValueViewModel = hiltViewModel(),
back: () -> Unit,
) {
val viewState by viewModel.state.collectAsStateWithLifecycle()
Scaffold(
topBar = {
TopAppBar(
title = { Text("") },
navigationIcon =
{
IconButton(onClick = { back() }) {
Icon(
imageVector = Icons.Filled.ArrowBack,
contentDescription = null
)
}
}
)
},
) { paddingValues ->
EnumValueView(
state = viewState,
setEnumValue = { viewModel.saveClick(it) },
revert = { viewModel.revertClick() },
popBackStack = { back() },
modifier = modifier.padding(paddingValues)
)
}
}

@Composable
internal fun EnumValueView(
state: ViewState,
setEnumValue: suspend (String) -> Unit,
revert: suspend () -> Unit,
Expand Down
36 changes: 33 additions & 3 deletions modules/help/src/main/java/se/eelde/toggles/help/HelpView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,44 @@ package se.eelde.toggles.help

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
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.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HelpView(modifier: Modifier = Modifier) {
Box(modifier.fillMaxSize()) {
Text(text = "Implementation", color = Color.White)
fun HelpView(modifier: Modifier = Modifier, back: () -> Unit) {
Scaffold(
topBar = {
TopAppBar(
title = { Text(stringResource(id = R.string.help)) },
navigationIcon =
{
IconButton(onClick = { back() }) {
Icon(
imageVector = Icons.Filled.ArrowBack,
contentDescription = null
)
}
}
)
},
) { paddingValues ->
Box(
modifier
.fillMaxSize()
.padding(paddingValues)) {
Text(text = "Implementation", color = Color.White)
}
}
}
4 changes: 4 additions & 0 deletions modules/help/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="help">Help</string>
</resources>
3 changes: 2 additions & 1 deletion modules/integerconfiguration/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

android {
namespace = "se.eelde.toggles.booleanconfiguration"
namespace = "se.eelde.toggles.integerconfiguration"
buildFeatures {
compose = true
}
Expand All @@ -23,6 +23,7 @@ dependencies {
implementation(libs.androidx.appcompat)
implementation(libs.androidx.navigation.navigation.compose)
implementation(libs.androidx.hilt.hilt.navigation.compose)
implementation(libs.androidx.lifecycle.lifecycle.runtime.compose)
implementation(libs.androidx.compose.runtime)
implementation(libs.androidx.compose.material3)
debugImplementation(libs.androidx.compose.ui.ui.tooling)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,27 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
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
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import kotlinx.coroutines.launch

@Preview
Expand All @@ -31,9 +41,44 @@ fun IntegerValueViewPreview() {
)
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
@Suppress("LongParameterList")
fun IntegerValueView(
modifier: Modifier = Modifier,
viewModel: FragmentIntegerValueViewModel = hiltViewModel(),
back: () -> Unit,
) {
val viewState by viewModel.state.collectAsStateWithLifecycle()
Scaffold(
topBar = {
TopAppBar(
title = { Text("") },
navigationIcon =
{
IconButton(onClick = { back() }) {
Icon(
imageVector = Icons.Filled.ArrowBack,
contentDescription = null
)
}
}
)
},
) { paddingValues ->
IntegerValueView(
uiState = viewState,
popBackStack = { back() },
revert = { viewModel.revertClick() },
save = { viewModel.saveClick() },
setIntegerValue = { viewModel.setIntegerValue(it) },
modifier = Modifier.padding(paddingValues),
)
}
}

@Composable
@Suppress("LongParameterList")
internal fun IntegerValueView(
uiState: ViewState,
popBackStack: () -> Unit,
revert: suspend () -> Unit,
Expand Down
1 change: 1 addition & 0 deletions modules/stringconfiguration/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies {
implementation(libs.androidx.appcompat)
implementation(libs.androidx.navigation.navigation.compose)
implementation(libs.androidx.hilt.hilt.navigation.compose)
implementation(libs.androidx.lifecycle.lifecycle.runtime.compose)
implementation(libs.androidx.compose.runtime)
implementation(libs.androidx.compose.material3)
debugImplementation(libs.androidx.compose.ui.ui.tooling)
Expand Down
Loading

0 comments on commit 6d7a67a

Please sign in to comment.