Skip to content

Commit

Permalink
feat(ui): internal changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JunkFood02 committed Apr 5, 2024
1 parent e729f15 commit c201162
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.text.font.FontFamily
Expand All @@ -60,6 +61,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.junkfood.seal.Downloader
import com.junkfood.seal.R
import com.junkfood.seal.database.objects.CommandTemplate
import com.junkfood.seal.ui.common.HapticFeedback.slightHapticFeedback
import com.junkfood.seal.ui.common.SVGImage
import com.junkfood.seal.ui.common.intState
import com.junkfood.seal.ui.component.BackButton
Expand Down Expand Up @@ -87,6 +89,7 @@ import kotlinx.coroutines.launch
@Composable
fun TaskListPage(onNavigateBack: () -> Unit, onNavigateToDetail: (Int) -> Unit) {
val scope = rememberCoroutineScope()
val view = LocalView.current

val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
var showBottomSheet by remember { mutableStateOf(false) }
Expand Down Expand Up @@ -225,6 +228,7 @@ fun TaskListPage(onNavigateBack: () -> Unit, onNavigateToDetail: (Int) -> Unit)
item {
FilledButtonWithIcon(
onClick = {
view.slightHapticFeedback()
Downloader.executeCommandWithUrl(url)
onDismissRequest()
},
Expand Down Expand Up @@ -292,7 +296,7 @@ fun ColumnScope.TaskCreatorDialogContent(
textAlign = TextAlign.Center,
modifier = Modifier
.align(Alignment.CenterHorizontally)
.padding(bottom = 16.dp)
.padding(bottom = 24.dp)
)

OutlinedTextField(
Expand All @@ -318,16 +322,16 @@ fun ColumnScope.TaskCreatorDialogContent(
}
item {
OutlinedButtonChip(
icon = Icons.Outlined.NewLabel,
label = stringResource(id = R.string.new_template),
onClick = onNewTemplateClicked
icon = Icons.Outlined.Edit,
label = stringResource(id = R.string.edit_template, template.name),
onClick = onEditClicked
)
}
item {
OutlinedButtonChip(
icon = Icons.Outlined.Edit,
label = stringResource(id = R.string.edit_template, template.name),
onClick = onEditClicked
icon = Icons.Outlined.NewLabel,
label = stringResource(id = R.string.new_template),
onClick = onNewTemplateClicked
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ fun DownloadPage(
val clipboardManager = LocalClipboardManager.current
val keyboardController = LocalSoftwareKeyboardController.current
val useDialog = LocalWindowWidthState.current != WindowWidthSizeClass.Compact
val view = LocalView.current
var showDownloadDialog by rememberSaveable { mutableStateOf(false) }
var showMeteredNetworkDialog by remember { mutableStateOf(false) }

Expand Down Expand Up @@ -188,6 +189,7 @@ fun DownloadPage(


val downloadCallback: () -> Unit = {
view.slightHapticFeedback()
keyboardController?.hide()
if (NOTIFICATION.getBoolean() && notificationPermission?.status?.isGranted == false) {
showNotificationDialog = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.junkfood.seal.R
import com.junkfood.seal.database.backup.BackupUtil
import com.junkfood.seal.database.objects.CommandTemplate
import com.junkfood.seal.ui.common.HapticFeedback.slightHapticFeedback
import com.junkfood.seal.ui.common.intState
Expand All @@ -76,7 +77,6 @@ import com.junkfood.seal.ui.component.PreferenceItemVariant
import com.junkfood.seal.ui.component.PreferenceSwitchWithContainer
import com.junkfood.seal.ui.component.TemplateItem
import com.junkfood.seal.ui.page.settings.about.ytdlpUrl
import com.junkfood.seal.database.backup.BackupUtil
import com.junkfood.seal.util.CUSTOM_COMMAND
import com.junkfood.seal.util.DatabaseUtil
import com.junkfood.seal.util.PreferenceUtil
Expand Down Expand Up @@ -243,6 +243,7 @@ fun TemplateListPage(onNavigateBack: () -> Unit, onNavigateToEditPage: (Int) ->
modifier = Modifier.fillMaxWidth()
) {
TriStateCheckbox(state = checkBoxState, onClick = {
view.slightHapticFeedback()
when (checkBoxState) {
ToggleableState.On -> selectedTemplates.clear()
else -> selectedTemplates.run {
Expand All @@ -262,6 +263,7 @@ fun TemplateListPage(onNavigateBack: () -> Unit, onNavigateToEditPage: (Int) ->

IconButton(
onClick = {
view.slightHapticFeedback()
scope.launch {
snackbarHostState.showSnackbar(
context.getString(R.string.template_exported)
Expand All @@ -288,7 +290,10 @@ fun TemplateListPage(onNavigateBack: () -> Unit, onNavigateToEditPage: (Int) ->
)
}
IconButton(
onClick = { showDeleteDialog = true },
onClick = {
view.slightHapticFeedback()
showDeleteDialog = true
},
enabled = selectedTemplates.isNotEmpty()
) {
Icon(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.junkfood.seal.R
import com.junkfood.seal.database.objects.DownloadedVideoInfo
import com.junkfood.seal.ui.common.HapticFeedback.slightHapticFeedback
import com.junkfood.seal.ui.component.FilledTonalButtonWithIcon
import com.junkfood.seal.ui.component.LongTapTextButton
import com.junkfood.seal.ui.component.OutlinedButtonWithIcon
Expand All @@ -51,7 +53,6 @@ import com.junkfood.seal.ui.theme.SealTheme
import com.junkfood.seal.util.FileUtil
import com.junkfood.seal.util.ToastUtil

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun VideoDetailDrawer(
sheetState: ModalBottomSheetState,
Expand All @@ -61,6 +62,7 @@ fun VideoDetailDrawer(
onDelete: () -> Unit = {},
) {
val uriHandler = LocalUriHandler.current
val view = LocalView.current
val context = LocalContext.current
val hapticFeedback = LocalHapticFeedback.current
BackHandler(sheetState.targetValue == ModalBottomSheetValue.Expanded) {
Expand Down Expand Up @@ -91,13 +93,15 @@ fun VideoDetailDrawer(
onReDownload = onReDownload,
onDismissRequest = onDismissRequest,
onDelete = {
view.slightHapticFeedback()
onDismissRequest()
onDelete()
}, onOpenLink = {
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
onDismissRequest()
uriHandler.openUri(videoUrl)
}, onShareFile = {
view.slightHapticFeedback()
FileUtil.createIntentForSharingFile(videoPath)?.runCatching {
context.startActivity(
Intent.createChooser(this, shareTitle)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<string name="link_copied">Link copied to clipboard</string>
<string name="open_url">Open link</string>
<string name="remove">Remove</string>
<string name="delete_file">Delete</string>
<string name="delete_file">Delete file</string>
<string name="about">About</string>
<string name="about_page">Version, feedback, auto update</string>
<string name="back">Back</string>
Expand Down

0 comments on commit c201162

Please sign in to comment.