Skip to content

Commit

Permalink
UI polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
w2sv committed Oct 5, 2024
1 parent 8242093 commit a1ff78b
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.w2sv.filenavigator.ui.theme.onSurfaceVariantDecreasedAlpha
import com.w2sv.filenavigator.ui.util.CharSequenceText

object ItemRowDefaults {
val IconTextSpacing = 16.dp
Expand All @@ -33,7 +34,7 @@ fun ItemRow(
icon: @Composable RowScope.() -> Unit,
@StringRes labelRes: Int,
modifier: Modifier = Modifier,
explanation: String? = null,
explanation: CharSequence? = null,
verticalAlignment: Alignment.Vertical = Alignment.Top,
content: @Composable RowScope.() -> Unit
) {
Expand All @@ -57,8 +58,8 @@ fun ItemRow(
}

@Composable
private fun Explanation(text: String, modifier: Modifier = Modifier) {
Text(
private fun Explanation(text: CharSequence, modifier: Modifier = Modifier) {
CharSequenceText(
text = text,
color = MaterialTheme.colorScheme.onSurfaceVariantDecreasedAlpha,
modifier = modifier,
Expand Down Expand Up @@ -87,7 +88,7 @@ fun SwitchItemRow(
checked: Boolean,
onCheckedChange: (Boolean) -> Unit,
modifier: Modifier = Modifier,
explanation: String? = null
explanation: CharSequence? = null
) {
ItemRow(
icon = icon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.annotation.RootGraph
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import com.w2sv.androidutils.os.dynamicColorsSupported
import com.w2sv.composed.rememberStyledTextResource
import com.w2sv.filenavigator.R
import com.w2sv.filenavigator.ui.LocalUseDarkTheme
import com.w2sv.filenavigator.ui.designsystem.AppCardDefaults
Expand Down Expand Up @@ -82,7 +83,7 @@ private fun SettingsCardColumn(appPreferences: AppPreferences, modifier: Modifie
labelRes = R.string.show_storage_volume_names,
checked = appPreferences.showStorageVolumeNames(),
onCheckedChange = appPreferences.setShowStorageVolumeNames,
explanation = stringResource(R.string.show_storage_volume_names_explanation)
explanation = rememberStyledTextResource(R.string.show_storage_volume_names_explanation)
)
}
SettingsCard(title = stringResource(id = R.string.appearance)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fun MoveHistory(
modifier = Modifier.padding(bottom = 4.dp)
)
}
MoveEntryView(
MoveRecordView(
movedFile = moveEntry,
onClick = onRowClick,
modifier = Modifier
Expand All @@ -89,7 +89,7 @@ fun MoveHistory(
}

@Composable
private fun MoveEntryView(
private fun MoveRecordView(
movedFile: MovedFile,
onClick: suspend (MovedFile, Boolean) -> Unit,
modifier: Modifier = Modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fun MoveHistoryCard(
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
text = stringResource(R.string.history),
text = stringResource(R.string.move_history),
style = MaterialTheme.typography.headlineMedium,
)

Expand Down Expand Up @@ -197,7 +197,7 @@ private fun NoHistoryPlaceHolder(modifier: Modifier = Modifier) {
)
Spacer(modifier = Modifier.height(12.dp))
Text(
text = stringResource(R.string.navigated_files_will_appear_here),
text = stringResource(R.string.move_history_placeholder),
modifier = Modifier.padding(horizontal = 12.dp)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,17 @@ private fun AutoMoveIntroductionDialog(
text = {
Column(modifier = Modifier.verticalScroll(rememberScrollState())) {
Text(
text = stringResource(R.string.you_can_now_enable_file_source_specific_auto_moving_by),
text = stringResource(R.string.auto_move_introduction_paragraph_1),
modifier = Modifier.padding(bottom = TextSectionBottomPadding)
)
Text(
text = rememberStyledTextResource(R.string._1_clicking_on_the_auto_button_of_an_enabled_file_source_2_selecting_a_destination_3_saving_the_changes),
text = rememberStyledTextResource(R.string.auto_move_introduction_paragraph_2),
modifier = Modifier
.padding(horizontal = 12.dp)
.padding(bottom = TextSectionBottomPadding)
)
Text(
text = stringResource(R.string.now_whenever_a_new_file_corresponding_to_the_file_source_is_discovered_it_will_be_automatically_moved_to_the_selected_destination_without_you_needing_to_do_anything_else)
text = stringResource(R.string.auto_move_introduction_paragraph_3)
)
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.w2sv.filenavigator.ui.util

import android.annotation.SuppressLint
import androidx.compose.foundation.text.InlineTextContent
import androidx.compose.material3.LocalTextStyle
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.TextLayoutResult
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.TextUnit

@Composable
fun CharSequenceText(
text: CharSequence,
modifier: Modifier = Modifier,
color: Color = Color.Unspecified,
fontSize: TextUnit = TextUnit.Unspecified,
fontStyle: FontStyle? = null,
fontWeight: FontWeight? = null,
fontFamily: FontFamily? = null,
letterSpacing: TextUnit = TextUnit.Unspecified,
textDecoration: TextDecoration? = null,
textAlign: TextAlign? = null,
lineHeight: TextUnit = TextUnit.Unspecified,
overflow: TextOverflow = TextOverflow.Clip,
softWrap: Boolean = true,
maxLines: Int = Int.MAX_VALUE,
minLines: Int = 1,
@SuppressLint("ComposeUnstableCollections") inlineContent: Map<String, InlineTextContent> = mapOf(),
onTextLayout: (TextLayoutResult) -> Unit = {},
style: TextStyle = LocalTextStyle.current
) {
when (text) {
is AnnotatedString -> androidx.compose.material3.Text(
text = text,
modifier = modifier,
color = color,
fontSize = fontSize,
fontStyle = fontStyle,
fontWeight = fontWeight,
fontFamily = fontFamily,
letterSpacing = letterSpacing,
textDecoration = textDecoration,
textAlign = textAlign,
lineHeight = lineHeight,
overflow = overflow,
softWrap = softWrap,
maxLines = maxLines,
minLines = minLines,
inlineContent = inlineContent,
onTextLayout = onTextLayout,
style = style
)

is String -> androidx.compose.material3.Text(
text = text,
modifier = modifier,
color = color,
fontSize = fontSize,
fontStyle = fontStyle,
fontWeight = fontWeight,
fontFamily = fontFamily,
letterSpacing = letterSpacing,
textDecoration = textDecoration,
textAlign = textAlign,
lineHeight = lineHeight,
overflow = overflow,
softWrap = softWrap,
maxLines = maxLines,
minLines = minLines,
onTextLayout = onTextLayout,
style = style
)

else -> throw IllegalArgumentException("text has to be either String or AnnotatedString")
}
}
12 changes: 6 additions & 6 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
<string name="active">Active</string>
<string name="inactive">Inactive</string>
<string name="delete_move_history">Delete move history?</string>
<string name="navigated_files_will_appear_here">Navigated files will appear here</string>
<string name="move_history_placeholder">Moved files will appear here</string>
<string name="return_to_main_screen">Return to main screen</string>
<string name="discard">Discard</string>
<string name="history">History</string>
<string name="move_history">Move History</string>
<string name="copyright">© 2023 - %1$s | w2sv</string>
<string name="navigator_settings">Navigator Settings</string>
<string name="couldn_t_find_file">Couldn\'t find file.</string>
Expand Down Expand Up @@ -66,12 +66,12 @@
<string name="start_navigator_on_system_boot">Start navigator on system boot</string>
<string name="app_settings">App Settings</string>
<string name="show_storage_volume_names">Show storage volume names</string>
<string name="show_storage_volume_names_explanation">E.g. primary:Folder/OtherFolder instead of Folder/OtherFolder</string>
<string name="show_storage_volume_names_explanation">E.g. <b>primary:Folder/OtherFolder</b> instead of <b>Folder/OtherFolder</b></string>
<string name="settings">Settings</string>
<string name="general">General</string>
<string name="you_can_now_enable_file_source_specific_auto_moving_by">You can now enable file source specific Auto Moving by</string>
<string name="now_whenever_a_new_file_corresponding_to_the_file_source_is_discovered_it_will_be_automatically_moved_to_the_selected_destination_without_you_needing_to_do_anything_else">Now, whenever a new file corresponding to the file source is discovered, it will be automatically moved to the selected destination without you needing to do anything else.</string>
<string name="_1_clicking_on_the_auto_button_of_an_enabled_file_source_2_selecting_a_destination_3_saving_the_changes"><b>1.</b> Clicking on the <b>Auto</b> button of an enabled file source\n<b>2.</b> Selecting a destination\n<b>3.</b> Saving the changes</string>
<string name="auto_move_introduction_paragraph_1">You can now enable file source specific Auto Moving by</string>
<string name="auto_move_introduction_paragraph_2"><b>1.</b> Clicking on the <b>Auto</b> button of an enabled file source\n<b>2.</b> Selecting a destination\n<b>3.</b> Saving the changes</string>
<string name="auto_move_introduction_paragraph_3">Then, whenever a new file corresponding to the file source is discovered, it will be automatically moved to the selected destination without you needing to do anything else.</string>
<string name="awesome">Awesome!</string>
<string name="introducing_auto_move">Introducing Auto Move</string>
<string name="notify">Notify</string>
Expand Down
2 changes: 1 addition & 1 deletion core/navigator/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<string name="cancel">Cancel</string>
<string name="directory_access">Directory Access</string>
<string name="understood">Understood</string>
<string name="quick_move_permission_query_dialog_content">You need to grant File Navigator access to the selected destination to quick-move files there. This is only necessary once per destination.</string>
<string name="quick_move_permission_query_dialog_content">You need to grant File Navigator access to the selected destination to quick-move files there.\n\nThis is necessary only once per destination.</string>
<plurals name="couldn_t_move_files_due_to">
<item quantity="one"><![CDATA[Couldn\'t move %1$s file due to <b>%2$s</b> exception]]></item>
<item quantity="other"><![CDATA[Couldn\'t move %1$s files due to <b>%2$s</b> exception]]></item>
Expand Down

0 comments on commit a1ff78b

Please sign in to comment.