From f6ff89c3ea040cc5c8781508f72f439bfdcd234e Mon Sep 17 00:00:00 2001 From: acrodriguezs1 Date: Sat, 22 Nov 2025 23:43:26 -0500 Subject: [PATCH 1/6] funciona --- .../java/org/tasks/compose/home/HomeScreen.kt | 323 +++++++++--------- .../res/layout/fragment_task_edit_empty.xml | 15 +- .../main/res/layout/fragment_task_list.xml | 42 +-- app/src/main/res/layout/scrollable_widget.xml | 15 +- app/src/main/res/values/theme.xml | 1 + kmp/src/commonMain/composeResources/values-in | 1 - kmp/src/commonMain/composeResources/values-iw | 1 - 7 files changed, 196 insertions(+), 202 deletions(-) delete mode 120000 kmp/src/commonMain/composeResources/values-in delete mode 120000 kmp/src/commonMain/composeResources/values-iw diff --git a/app/src/main/java/org/tasks/compose/home/HomeScreen.kt b/app/src/main/java/org/tasks/compose/home/HomeScreen.kt index 287552183..b386c5109 100644 --- a/app/src/main/java/org/tasks/compose/home/HomeScreen.kt +++ b/app/src/main/java/org/tasks/compose/home/HomeScreen.kt @@ -7,6 +7,7 @@ import androidx.activity.compose.LocalActivity import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.AppCompatActivity.RESULT_OK +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.PaddingValues @@ -20,8 +21,6 @@ import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.systemBars -import androidx.compose.foundation.layout.windowInsetsBottomHeight -import androidx.compose.foundation.layout.windowInsetsTopHeight import androidx.compose.material3.DrawerState import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme @@ -44,6 +43,7 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.res.painterResource +import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.dp import androidx.core.content.IntentCompat.getParcelableExtra import androidx.fragment.compose.AndroidFragment @@ -123,194 +123,183 @@ fun HomeScreen( ) { val context = LocalContext.current val scope = rememberCoroutineScope() - Box(modifier = Modifier.fillMaxSize()) { - TaskListDrawer( - arrangement = if (state.menuQuery.isBlank()) Arrangement.Top else Arrangement.Bottom, - filters = if (state.menuQuery.isNotEmpty()) state.searchItems else state.drawerItems, - onClick = { - when (it) { - is DrawerItem.Filter -> { - viewModel.setFilter(it.filter) - scope.launch { - drawerState.close() - keyboard?.hide() - } + TaskListDrawer( + arrangement = if (state.menuQuery.isBlank()) Arrangement.Top else Arrangement.Bottom, + filters = if (state.menuQuery.isNotEmpty()) state.searchItems else state.drawerItems, + onClick = { + when (it) { + is DrawerItem.Filter -> { + viewModel.setFilter(it.filter) + scope.launch { + drawerState.close() + keyboard?.hide() } + } - is DrawerItem.Header -> { - viewModel.toggleCollapsed(it.header) - } + is DrawerItem.Header -> { + viewModel.toggleCollapsed(it.header) } - }, - onAddClick = { - scope.launch { - drawerState.close() - when (it.header.addIntentRc) { - FilterProvider.REQUEST_NEW_FILTER -> - showNewFilterDialog() + } + }, + onAddClick = { + scope.launch { + drawerState.close() + when (it.header.addIntentRc) { + FilterProvider.REQUEST_NEW_FILTER -> + showNewFilterDialog() - REQUEST_NEW_PLACE -> - newList.launch(Intent(context, LocationPickerActivity::class.java)) + REQUEST_NEW_PLACE -> + newList.launch(Intent(context, LocationPickerActivity::class.java)) - REQUEST_NEW_TAGS -> - newList.launch(Intent(context, TagSettingsActivity::class.java)) + REQUEST_NEW_TAGS -> + newList.launch(Intent(context, TagSettingsActivity::class.java)) - REQUEST_NEW_LIST -> - when (it.header.subheaderType) { - NavigationDrawerSubheader.SubheaderType.CALDAV, - NavigationDrawerSubheader.SubheaderType.TASKS -> - viewModel - .getAccount(it.header.id.toLong()) - ?.let { - newList.launch( - Intent(context, it.listSettingsClass()) - .putExtra(EXTRA_CALDAV_ACCOUNT, it) - ) - } + REQUEST_NEW_LIST -> + when (it.header.subheaderType) { + NavigationDrawerSubheader.SubheaderType.CALDAV, + NavigationDrawerSubheader.SubheaderType.TASKS -> + viewModel + .getAccount(it.header.id.toLong()) + ?.let { + newList.launch( + Intent(context, it.listSettingsClass()) + .putExtra(EXTRA_CALDAV_ACCOUNT, it) + ) + } - else -> {} - } + else -> {} + } - else -> Timber.e("Unhandled request code: $it") - } + else -> Timber.e("Unhandled request code: $it") } - }, - onErrorClick = { - context.startActivity(Intent(context, MainPreferences::class.java)) - }, - searchBar = { - MenuSearchBar( - begForMoney = state.begForMoney, - onDrawerAction = { - scope.launch { - drawerState.close() - when (it) { - DrawerAction.PURCHASE -> - if (TasksApplication.IS_GENERIC) - context.openUri(R.string.url_donate) - else - context.startActivity( - Intent( - context, - PurchaseActivity::class.java - ) - ) - - DrawerAction.HELP_AND_FEEDBACK -> + } + }, + onErrorClick = { + context.startActivity(Intent(context, MainPreferences::class.java)) + }, + searchBar = { + MenuSearchBar( + begForMoney = state.begForMoney, + onDrawerAction = { + scope.launch { + drawerState.close() + when (it) { + DrawerAction.PURCHASE -> + if (TasksApplication.IS_GENERIC) + context.openUri(R.string.url_donate) + else context.startActivity( Intent( context, - HelpAndFeedback::class.java + PurchaseActivity::class.java ) ) - } - } - }, - query = state.menuQuery, - onQueryChange = { viewModel.queryMenu(it) }, - ) - }, - ) - SystemBarScrim( - modifier = Modifier - .windowInsetsTopHeight(WindowInsets.systemBars) - .align(Alignment.TopCenter) - ) - SystemBarScrim( - modifier = Modifier - .windowInsetsBottomHeight(WindowInsets.systemBars) - .align(Alignment.BottomCenter), - ) - } + DrawerAction.HELP_AND_FEEDBACK -> + context.startActivity( + Intent( + context, + HelpAndFeedback::class.java + ) + ) + } + } + }, + query = state.menuQuery, + onQueryChange = { viewModel.queryMenu(it) }, + ) + }, + ) } } ) { - Box(modifier = Modifier.fillMaxSize()) { - val scope = rememberCoroutineScope() - ListDetailPaneScaffold( - directive = navigator.scaffoldDirective, - value = navigator.scaffoldValue, - listPane = { - key (state.filter) { - val fragment = remember { mutableStateOf(null) } - val keyboardOpen = rememberImeState() - AndroidFragment( - fragmentState = rememberFragmentState(), - arguments = remember(state.filter) { - Bundle() - .apply { putParcelable(EXTRA_FILTER, state.filter) } - }, - modifier = Modifier - .fillMaxSize() - .imePadding(), - ) { tlf -> - fragment.value = tlf - tlf.applyInsets(windowInsets.value) - tlf.setNavigationClickListener { - scope.launch { drawerState.open() } - } - } - LaunchedEffect(fragment, windowInsets, keyboardOpen.value) { - fragment.value?.applyInsets( - if (keyboardOpen.value) { - PaddingValues( - top = windowInsets.value.calculateTopPadding(), - ) - } else { - windowInsets.value - } - ) - } - } - }, - detailPane = { - val direction = LocalLayoutDirection.current - Box( + val scope = rememberCoroutineScope() + + + ListDetailPaneScaffold( + directive = navigator.scaffoldDirective, + value = navigator.scaffoldValue, + listPane = { + key (state.filter) { + val fragment = remember { mutableStateOf(null) } + val keyboardOpen = rememberImeState() + AndroidFragment( + fragmentState = rememberFragmentState(), + arguments = remember(state.filter) { + Bundle() + .apply { putParcelable(EXTRA_FILTER, state.filter) } + }, modifier = Modifier .fillMaxSize() - .padding( - top = windowInsets.value.calculateTopPadding(), - start = windowInsets.value.calculateStartPadding(direction), - end = windowInsets.value.calculateEndPadding(direction), - bottom = if (rememberImeState().value) - WindowInsets.ime.asPaddingValues().calculateBottomPadding() - else - windowInsets.value.calculateBottomPadding() - ), - contentAlignment = Alignment.Center, - ) { - if (state.task == null) { - if (isListVisible && isDetailVisible) { - Icon( - painter = painterResource(org.tasks.kmp.R.drawable.ic_launcher_no_shadow_foreground), - contentDescription = null, - modifier = Modifier.size(192.dp), - tint = MaterialTheme.colorScheme.onSurfaceVariant, - ) - } - } else { - key(state.task) { - AndroidFragment( - fragmentState = rememberFragmentState(), - arguments = remember(state.task) { - Bundle() - .apply { putParcelable(EXTRA_TASK, state.task) } - }, - modifier = Modifier.fillMaxSize(), + .imePadding(), + ) { tlf -> + fragment.value = tlf + tlf.applyInsets(windowInsets.value) + tlf.setNavigationClickListener { + scope.launch { drawerState.open() } + } + } + LaunchedEffect(fragment, windowInsets, keyboardOpen.value) { + fragment.value?.applyInsets( + if (keyboardOpen.value) { + PaddingValues( + top = windowInsets.value.calculateTopPadding(), ) + } else { + windowInsets.value } - } + ) } - }, - ) + } + }, + detailPane = { + val direction = LocalLayoutDirection.current + val imeOpen = rememberImeState().value + val insets = windowInsets.value + val topPad = insets.calculateTopPadding() + val startPad = insets.calculateStartPadding(direction) + val endPad = insets.calculateEndPadding(direction) + val bottomPad = if (imeOpen) + WindowInsets.ime.asPaddingValues().calculateBottomPadding() + else + insets.calculateBottomPadding() - SystemBarScrim( - modifier = Modifier - .windowInsetsTopHeight(WindowInsets.systemBars) - .align(Alignment.TopCenter), - ) - } + Box( + modifier = Modifier + .fillMaxSize() + + .padding( + top = topPad, + start = startPad, + end = endPad, + bottom = bottomPad + ), + contentAlignment = Alignment.Center, + ) { + if (state.task == null) { + if (isListVisible && isDetailVisible) { + Icon( + painter = painterResource(org.tasks.kmp.R.drawable.ic_launcher_no_shadow_foreground), + contentDescription = null, + modifier = Modifier.size(192.dp), + tint = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + } else { + key(state.task) { + AndroidFragment( + fragmentState = rememberFragmentState(), + arguments = remember(state.task) { + Bundle() + .apply { putParcelable(EXTRA_TASK, state.task) } + }, + modifier = Modifier.fillMaxSize(), + ) + } + } + } + }, + ) } } -} +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_task_edit_empty.xml b/app/src/main/res/layout/fragment_task_edit_empty.xml index 63b4ac546..b1017f72b 100644 --- a/app/src/main/res/layout/fragment_task_edit_empty.xml +++ b/app/src/main/res/layout/fragment_task_edit_empty.xml @@ -1,11 +1,14 @@ + android:layout_width="match_parent" + android:layout_height="match_parent" + + android:background="?attr/colorSurface" + + android:orientation="vertical"> + android:id="@+id/toolbar" + layout="@layout/toolbar" /> - + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_task_list.xml b/app/src/main/res/layout/fragment_task_list.xml index 807697c55..315c9e290 100644 --- a/app/src/main/res/layout/fragment_task_list.xml +++ b/app/src/main/res/layout/fragment_task_list.xml @@ -1,18 +1,18 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/task_list_coordinator" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:descendantFocusability="beforeDescendants" + android:focusable="true" + android:focusableInTouchMode="true" + android:orientation="vertical"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="horizontal"> + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="100"> - + \ No newline at end of file diff --git a/app/src/main/res/layout/scrollable_widget.xml b/app/src/main/res/layout/scrollable_widget.xml index 9f54a5f07..e6289cba7 100644 --- a/app/src/main/res/layout/scrollable_widget.xml +++ b/app/src/main/res/layout/scrollable_widget.xml @@ -27,12 +27,15 @@ tools:padding="@dimen/widget_padding"/> + android:id="@+id/widget_reconfigure" + style="@style/WidgetButton" + android:layout_toStartOf="@id/widget_button" + android:src="@drawable/ic_outline_settings_24px" + android:contentDescription="@string/widget_settings" + android:background="@android:color/transparent" + android:padding="@dimen/widget_padding" + /> +