From a4cb24c1ab5907ffb5da4fac09e4c3530df4f22e Mon Sep 17 00:00:00 2001 From: Sad Ellie Date: Tue, 19 Sep 2023 15:28:37 +0300 Subject: [PATCH] =?UTF-8?q?Remove=20=F0=9F=92=A9=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/epoch/.gitignore | 1 - feature/epoch/build.gradle.kts | 32 ----- feature/epoch/consumer-rules.pro | 0 feature/epoch/src/main/AndroidManifest.xml | 4 - .../unitto/feature/epoch/EpochScreen.kt | 91 -------------- .../unitto/feature/epoch/EpochViewModel.kt | 111 ------------------ .../epoch/component/DateTextFieldUtils.kt | 66 ----------- .../epoch/component/DateUnixTextFields.kt | 78 ------------ .../feature/epoch/component/EpochKeyboard.kt | 84 ------------- .../feature/epoch/component/SwapButton.kt | 64 ---------- .../unitto/feature/epoch/component/TopPart.kt | 74 ------------ .../epoch/navigation/EpochNavigation.kt | 40 ------- 12 files changed, 645 deletions(-) delete mode 100644 feature/epoch/.gitignore delete mode 100644 feature/epoch/build.gradle.kts delete mode 100644 feature/epoch/consumer-rules.pro delete mode 100644 feature/epoch/src/main/AndroidManifest.xml delete mode 100644 feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/EpochScreen.kt delete mode 100644 feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/EpochViewModel.kt delete mode 100644 feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/DateTextFieldUtils.kt delete mode 100644 feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/DateUnixTextFields.kt delete mode 100644 feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/EpochKeyboard.kt delete mode 100644 feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/SwapButton.kt delete mode 100644 feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/TopPart.kt delete mode 100644 feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/navigation/EpochNavigation.kt diff --git a/feature/epoch/.gitignore b/feature/epoch/.gitignore deleted file mode 100644 index 42afabfd..00000000 --- a/feature/epoch/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/feature/epoch/build.gradle.kts b/feature/epoch/build.gradle.kts deleted file mode 100644 index 97b943f0..00000000 --- a/feature/epoch/build.gradle.kts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Unitto is a unit converter for Android - * Copyright (c) 2023 Elshan Agaev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -plugins { - id("unitto.library") - id("unitto.library.compose") - id("unitto.library.feature") - id("unitto.android.hilt") -} - -android { - namespace = "com.sadellie.unitto.feature.epoch" -} - -dependencies { - implementation(project(mapOf("path" to ":data:epoch"))) -} \ No newline at end of file diff --git a/feature/epoch/consumer-rules.pro b/feature/epoch/consumer-rules.pro deleted file mode 100644 index e69de29b..00000000 diff --git a/feature/epoch/src/main/AndroidManifest.xml b/feature/epoch/src/main/AndroidManifest.xml deleted file mode 100644 index 44008a43..00000000 --- a/feature/epoch/src/main/AndroidManifest.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/EpochScreen.kt b/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/EpochScreen.kt deleted file mode 100644 index a8d17e30..00000000 --- a/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/EpochScreen.kt +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Unitto is a unit converter for Android - * Copyright (c) 2023 Elshan Agaev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.sadellie.unitto.feature.epoch - -import androidx.compose.foundation.layout.padding -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.TextRange -import androidx.compose.ui.unit.dp -import androidx.hilt.navigation.compose.hiltViewModel -import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.sadellie.unitto.core.base.R -import com.sadellie.unitto.core.ui.common.MenuButton -import com.sadellie.unitto.core.ui.common.PortraitLandscape -import com.sadellie.unitto.core.ui.common.UnittoScreenWithTopBar -import com.sadellie.unitto.feature.epoch.component.EpochKeyboard -import com.sadellie.unitto.feature.epoch.component.TopPart - -@Composable -internal fun EpochRoute( - navigateToMenu: () -> Unit, - viewModel: EpochViewModel = hiltViewModel() -) { - val uiState = viewModel.uiState.collectAsStateWithLifecycle() - EpochScreen( - navigateToMenu = navigateToMenu, - uiState = uiState.value, - addSymbol = viewModel::addSymbol, - deleteSymbol = viewModel::deleteSymbol, - swap = viewModel::swap, - clearSymbols = viewModel::clearSymbols, - onCursorChange = viewModel::onCursorChange - ) -} - -@Composable -private fun EpochScreen( - navigateToMenu: () -> Unit, - uiState: EpochUIState, - addSymbol: (String) -> Unit, - deleteSymbol: () -> Unit, - clearSymbols: () -> Unit, - swap: () -> Unit, - onCursorChange: (IntRange) -> Unit -) { - UnittoScreenWithTopBar( - title = { Text(stringResource(R.string.epoch_converter)) }, - navigationIcon = { MenuButton { navigateToMenu() } } - ) { padding -> - PortraitLandscape( - modifier = Modifier.padding(padding), - content1 = { topContentModifier -> - TopPart( - modifier = topContentModifier.padding(horizontal = 8.dp), - dateToUnix = uiState.dateToUnix, - dateValue = uiState.dateField, - unixValue = uiState.unixField, - swap = swap, - selection = TextRange(uiState.selection.first, uiState.selection.last), - onCursorChange = onCursorChange - ) - }, - content2 = { bottomModifier -> - EpochKeyboard( - modifier = bottomModifier, - addSymbol = addSymbol, - clearSymbols = clearSymbols, - deleteSymbol = deleteSymbol - ) - } - ) - } -} diff --git a/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/EpochViewModel.kt b/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/EpochViewModel.kt deleted file mode 100644 index 9c4bdf36..00000000 --- a/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/EpochViewModel.kt +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Unitto is a unit converter for Android - * Copyright (c) 2023 Elshan Agaev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.sadellie.unitto.feature.epoch - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import com.sadellie.unitto.data.epoch.EpochDateConverter -import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.SharingStarted -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.combine -import kotlinx.coroutines.flow.stateIn -import kotlinx.coroutines.flow.update -import javax.inject.Inject - -data class EpochUIState( - val dateField: String = "", - val unixField: String = "", - val dateToUnix: Boolean = true, - val selection: IntRange = 0..0 -) - -@HiltViewModel -class EpochViewModel @Inject constructor() : ViewModel() { - - private val _input: MutableStateFlow = MutableStateFlow("") - private val _fromDateToUnix: MutableStateFlow = MutableStateFlow(true) - private val _selection: MutableStateFlow = MutableStateFlow(IntRange(0, 0)) - - val uiState: StateFlow = combine( - _input, _fromDateToUnix, _selection - ) { input, fromDateToUnix, selection -> - if (fromDateToUnix) { - EpochUIState( - dateField = input, - unixField = EpochDateConverter.convertDateToUnix(input), - dateToUnix = fromDateToUnix, - selection = selection - ) - } else { - val date = try { - EpochDateConverter.convertUnixToDate(input) - } catch (e: IllegalArgumentException) { - "" - } - - EpochUIState( - unixField = input, - dateField = date, - dateToUnix = fromDateToUnix, - selection = selection - ) - } - }.stateIn( - viewModelScope, SharingStarted.WhileSubscribed(5000L), EpochUIState() - ) - - fun addSymbol(symbol: String) { - val selection = _selection.value - val maxSymbols = if (_fromDateToUnix.value) 14 else 10 - if (_input.value.length >= maxSymbols) return - - _input.update { - if (it.isEmpty()) symbol else it.replaceRange(selection.first, selection.last, symbol) - } - _selection.update { it.first + 1..it.first + 1 } - } - - fun deleteSymbol() { - val selection = _selection.value - val newSelectionStart = when (selection.last) { - 0 -> return - selection.first -> _selection.value.first - 1 - else -> _selection.value.first - } - - _selection.update { newSelectionStart..newSelectionStart } - _input.update { it.removeRange(newSelectionStart, selection.last) } - } - - fun clearSymbols() { - _selection.update { 0..0 } - _input.update { "" } - } - - fun swap() { - clearSymbols() - _fromDateToUnix.update { !it } - } - - fun onCursorChange(selectionRange: IntRange) { - _selection.update { selectionRange } - } -} diff --git a/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/DateTextFieldUtils.kt b/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/DateTextFieldUtils.kt deleted file mode 100644 index 6ca7165c..00000000 --- a/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/DateTextFieldUtils.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Unitto is a unit converter for Android - * Copyright (c) 2023 Elshan Agaev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.sadellie.unitto.feature.epoch.component - -import androidx.compose.ui.text.AnnotatedString -import androidx.compose.ui.text.input.OffsetMapping -import androidx.compose.ui.text.input.TransformedText -import androidx.compose.ui.text.input.VisualTransformation - -internal object DateVisTrans : VisualTransformation { - override fun filter(text: AnnotatedString): TransformedText = TransformedText( - text = AnnotatedString(text.text.toDateMask()), - offsetMapping = offsetMapping - ) - - private val offsetMapping = object : OffsetMapping { - override fun originalToTransformed(offset: Int): Int { - if (offset <= 2) return offset - if (offset <= 4) return offset + 1 - if (offset <= 6) return offset + 2 - if (offset <= 8) return offset + 3 - if (offset <= 10) return offset + 4 - if (offset <= 14) return offset + 5 - return 20 - } - - override fun transformedToOriginal(offset: Int): Int { - if (offset <= 2) return offset - if (offset <= 5) return offset - 1 - if (offset <= 9) return offset - 2 - if (offset <= 11) return offset - 3 - if (offset <= 14) return offset - 4 - if (offset <= 19) return offset - 5 - return 14 - } - } -} - -internal fun String.toDateMask(): String { - var maskedText = this - - if (maskedText.length > 2) maskedText = maskedText.replaceRange(2, 2, ":") - if (maskedText.length > 5) maskedText = maskedText.replaceRange(5, 5, ":") - if (maskedText.length > 8) maskedText = maskedText.replaceRange(8, 8, "\n") - if (maskedText.length > 10) maskedText = maskedText.replaceRange(11, 11, "d") - if (maskedText.length > 13) maskedText = maskedText.replaceRange(14, 14, "m") - if (maskedText.length > 18) maskedText = maskedText.replaceRange(19, 19, "y") - - return maskedText -} diff --git a/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/DateUnixTextFields.kt b/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/DateUnixTextFields.kt deleted file mode 100644 index 736b6077..00000000 --- a/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/DateUnixTextFields.kt +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Unitto is a unit converter for Android - * Copyright (c) 2023 Elshan Agaev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.sadellie.unitto.feature.epoch.component - -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.text.BasicTextField -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider -import androidx.compose.ui.platform.LocalTextInputService -import androidx.compose.ui.text.input.TextFieldValue -import androidx.compose.ui.text.input.VisualTransformation -import androidx.compose.ui.text.style.TextAlign -import com.sadellie.unitto.core.ui.theme.NumbersTextStyleDisplayMedium - -@Composable -internal fun DateUnixTextFields( - fromTextFieldValue: TextFieldValue, - onCursorChange: (IntRange) -> Unit, - fromSupportText: String, - toTextValue: String, - toSupportText: String, - visualTransformation: VisualTransformation, - fromPlaceholderText: String, - toPlaceholderText: String -) { - Column { - CompositionLocalProvider( - LocalTextInputService provides null - ) { - BasicTextField( - value = fromTextFieldValue, - onValueChange = { onCursorChange(it.selection.start..it.selection.end) }, - textStyle = NumbersTextStyleDisplayMedium.copy( - textAlign = TextAlign.Start, - color = MaterialTheme.colorScheme.onBackground - ), - minLines = 1, - maxLines = 2, - visualTransformation = visualTransformation, - decorationBox = { innerTextField -> - Text( - text = fromPlaceholderText, - minLines = 1, - maxLines = 2, - style = NumbersTextStyleDisplayMedium, - color = MaterialTheme.colorScheme.outline, - textAlign = TextAlign.Start - ) - innerTextField() - } - ) - } - Text(text = fromSupportText) - Text( - text = toTextValue.ifEmpty { toPlaceholderText }, - style = NumbersTextStyleDisplayMedium, - ) - Text(text = toSupportText) - } -} diff --git a/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/EpochKeyboard.kt b/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/EpochKeyboard.kt deleted file mode 100644 index 7dbf64d1..00000000 --- a/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/EpochKeyboard.kt +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Unitto is a unit converter for Android - * Copyright (c) 2023 Elshan Agaev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.sadellie.unitto.feature.epoch.component - -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import com.sadellie.unitto.core.base.Token -import com.sadellie.unitto.core.ui.common.KeyboardButtonLight -import com.sadellie.unitto.core.ui.common.key.UnittoIcons -import com.sadellie.unitto.core.ui.common.key.unittoicons.Backspace -import com.sadellie.unitto.core.ui.common.key.unittoicons.Key0 -import com.sadellie.unitto.core.ui.common.key.unittoicons.Key1 -import com.sadellie.unitto.core.ui.common.key.unittoicons.Key2 -import com.sadellie.unitto.core.ui.common.key.unittoicons.Key3 -import com.sadellie.unitto.core.ui.common.key.unittoicons.Key4 -import com.sadellie.unitto.core.ui.common.key.unittoicons.Key5 -import com.sadellie.unitto.core.ui.common.key.unittoicons.Key6 -import com.sadellie.unitto.core.ui.common.key.unittoicons.Key7 -import com.sadellie.unitto.core.ui.common.key.unittoicons.Key8 -import com.sadellie.unitto.core.ui.common.key.unittoicons.Key9 - -@Composable -internal fun EpochKeyboard( - modifier: Modifier, - addSymbol: (String) -> Unit, - clearSymbols: () -> Unit, - deleteSymbol: () -> Unit -) { - Column( - modifier = modifier - ) { - // Button modifier - val bModifier = Modifier - .fillMaxSize() - .weight(1f) - .padding(4.dp) - // Column modifier - val cModifier = Modifier.weight(1f) - val dModifier = Modifier - .fillMaxSize() - .weight(2f) - .padding(4.dp) - Row(cModifier) { - KeyboardButtonLight(bModifier, UnittoIcons.Key7, false) { addSymbol(Token._7) } - KeyboardButtonLight(bModifier, UnittoIcons.Key8, false) { addSymbol(Token._8) } - KeyboardButtonLight(bModifier, UnittoIcons.Key9, false) { addSymbol(Token._9) } - } - Row(cModifier) { - KeyboardButtonLight(bModifier, UnittoIcons.Key4, false) { addSymbol(Token._4) } - KeyboardButtonLight(bModifier, UnittoIcons.Key5, false) { addSymbol(Token._5) } - KeyboardButtonLight(bModifier, UnittoIcons.Key6, false) { addSymbol(Token._6) } - } - Row(cModifier) { - KeyboardButtonLight(bModifier, UnittoIcons.Key1, false) { addSymbol(Token._1) } - KeyboardButtonLight(bModifier, UnittoIcons.Key2, false) { addSymbol(Token._2) } - KeyboardButtonLight(bModifier, UnittoIcons.Key3, false) { addSymbol(Token._3) } - } - Row(cModifier) { - KeyboardButtonLight(bModifier, UnittoIcons.Key0, false) { addSymbol(Token._0) } - KeyboardButtonLight(dModifier, UnittoIcons.Backspace, false, clearSymbols) { deleteSymbol() } - } - } -} \ No newline at end of file diff --git a/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/SwapButton.kt b/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/SwapButton.kt deleted file mode 100644 index f4cead05..00000000 --- a/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/SwapButton.kt +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Unitto is a unit converter for Android - * Copyright (c) 2023 Elshan Agaev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.sadellie.unitto.feature.epoch.component - -import androidx.compose.animation.core.FastOutSlowInEasing -import androidx.compose.animation.core.animateIntAsState -import androidx.compose.animation.core.tween -import androidx.compose.foundation.interaction.MutableInteractionSource -import androidx.compose.foundation.interaction.collectIsPressedAsState -import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.SwapHoriz -import androidx.compose.material3.Button -import androidx.compose.material3.Icon -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.remember -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp - -@Composable -internal fun SwapButton( - modifier: Modifier, - swap: () -> Unit -) { - val interactionSource = remember { MutableInteractionSource() } - val isPressed by interactionSource.collectIsPressedAsState() - val cornerRadius: Int by animateIntAsState( - targetValue = if (isPressed) 30 else 50, - animationSpec = tween(easing = FastOutSlowInEasing), - ) - - Button( - onClick = swap, - shape = RoundedCornerShape(cornerRadius), - modifier = modifier, - contentPadding = PaddingValues(vertical = 26.dp, horizontal = 8.dp), - interactionSource = interactionSource - ) { - Icon(Icons.Default.SwapHoriz, null) - Spacer(modifier = Modifier.width(8.dp)) - Text("SWAP") - } -} diff --git a/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/TopPart.kt b/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/TopPart.kt deleted file mode 100644 index d43d1ef2..00000000 --- a/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/component/TopPart.kt +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Unitto is a unit converter for Android - * Copyright (c) 2023 Elshan Agaev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.sadellie.unitto.feature.epoch.component - -import androidx.compose.animation.Crossfade -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.text.TextRange -import androidx.compose.ui.text.input.TextFieldValue -import androidx.compose.ui.text.input.VisualTransformation -import androidx.compose.ui.unit.dp - -@Composable -fun TopPart( - modifier: Modifier, - dateToUnix: Boolean, - swap: () -> Unit, - dateValue: String, - unixValue: String, - selection: TextRange, - onCursorChange: (IntRange) -> Unit -) { - Column( - modifier = modifier, - verticalArrangement = Arrangement.spacedBy(8.dp) - ) { - Crossfade(dateToUnix) { - if (it) { - DateUnixTextFields( - fromTextFieldValue = TextFieldValue(text = dateValue, selection = selection), - onCursorChange = onCursorChange, - fromSupportText = "date", - toTextValue = unixValue, - toSupportText = "unix", - visualTransformation = DateVisTrans, - fromPlaceholderText = dateValue.padEnd(14, '0').toDateMask(), - toPlaceholderText = "0" - ) - } else { - val dateMasked = dateValue.padEnd(14, '0').toDateMask() - DateUnixTextFields( - fromTextFieldValue = TextFieldValue(text = unixValue, selection = selection), - onCursorChange = onCursorChange, - fromSupportText = "unix", - toTextValue = dateMasked, - toSupportText = "date", - visualTransformation = VisualTransformation.None, - fromPlaceholderText = if (unixValue.isEmpty()) "0" else "", - toPlaceholderText = dateMasked, - ) - } - } - SwapButton(modifier = Modifier.fillMaxWidth(), swap = swap) - } -} diff --git a/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/navigation/EpochNavigation.kt b/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/navigation/EpochNavigation.kt deleted file mode 100644 index 59b94afb..00000000 --- a/feature/epoch/src/main/java/com/sadellie/unitto/feature/epoch/navigation/EpochNavigation.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Unitto is a unit converter for Android - * Copyright (c) 2023 Elshan Agaev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.sadellie.unitto.feature.epoch.navigation - -import androidx.navigation.NavGraphBuilder -import androidx.navigation.compose.composable -import androidx.navigation.navDeepLink -import com.sadellie.unitto.core.base.TopLevelDestinations -import com.sadellie.unitto.feature.epoch.EpochRoute - -private val epochRoute: String by lazy { TopLevelDestinations.Epoch.route } - -fun NavGraphBuilder.epochScreen( - navigateToMenu: () -> Unit -) { - composable( - route = epochRoute, - deepLinks = listOf( - navDeepLink { uriPattern = "app://com.sadellie.unitto/$epochRoute" } - ) - ) { - EpochRoute(navigateToMenu = navigateToMenu) - } -}