mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Add option for old action bar
This commit is contained in:
parent
9355b32466
commit
e53ef1094a
@ -94,6 +94,7 @@ import org.futo.inputmethod.latin.uix.actions.FavoriteActions
|
|||||||
import org.futo.inputmethod.latin.uix.actions.MoreActionsAction
|
import org.futo.inputmethod.latin.uix.actions.MoreActionsAction
|
||||||
import org.futo.inputmethod.latin.uix.actions.PinnedActions
|
import org.futo.inputmethod.latin.uix.actions.PinnedActions
|
||||||
import org.futo.inputmethod.latin.uix.actions.toActionList
|
import org.futo.inputmethod.latin.uix.actions.toActionList
|
||||||
|
import org.futo.inputmethod.latin.uix.settings.useDataStore
|
||||||
import org.futo.inputmethod.latin.uix.settings.useDataStoreValueBlocking
|
import org.futo.inputmethod.latin.uix.settings.useDataStoreValueBlocking
|
||||||
import org.futo.inputmethod.latin.uix.theme.DarkColorScheme
|
import org.futo.inputmethod.latin.uix.theme.DarkColorScheme
|
||||||
import org.futo.inputmethod.latin.uix.theme.Typography
|
import org.futo.inputmethod.latin.uix.theme.Typography
|
||||||
@ -130,6 +131,27 @@ import kotlin.math.roundToInt
|
|||||||
* TODO: Will need to make RTL languages work
|
* TODO: Will need to make RTL languages work
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
val ActionBarScrollIndexSetting = SettingsKey(
|
||||||
|
intPreferencesKey("action_bar_scroll_index"),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
|
||||||
|
val ActionBarScrollOffsetSetting = SettingsKey(
|
||||||
|
intPreferencesKey("action_bar_scroll_offset"),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
|
||||||
|
val ActionBarExpanded = SettingsKey(
|
||||||
|
booleanPreferencesKey("actionExpanded"),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
|
||||||
|
val OldStyleActionsBar = SettingsKey(
|
||||||
|
booleanPreferencesKey("oldActionBar"),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
interface ImportantNotice {
|
interface ImportantNotice {
|
||||||
@Composable fun getText(): String
|
@Composable fun getText(): String
|
||||||
fun onDismiss(context: Context)
|
fun onDismiss(context: Context)
|
||||||
@ -422,14 +444,6 @@ fun ActionItemSmall(action: Action, onSelect: (Action) -> Unit, onLongSelect: (A
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val ActionBarScrollIndexSetting = SettingsKey(
|
|
||||||
intPreferencesKey("action_bar_scroll_index"),
|
|
||||||
0
|
|
||||||
)
|
|
||||||
val ActionBarScrollOffsetSetting = SettingsKey(
|
|
||||||
intPreferencesKey("action_bar_scroll_offset"),
|
|
||||||
0
|
|
||||||
)
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ActionItems(onSelect: (Action) -> Unit, onLongSelect: (Action) -> Unit) {
|
fun ActionItems(onSelect: (Action) -> Unit, onLongSelect: (Action) -> Unit) {
|
||||||
@ -613,11 +627,6 @@ fun ImportantNoticeView(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val ActionBarExpanded = SettingsKey(
|
|
||||||
booleanPreferencesKey("actionExpanded"),
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun RowScope.PinnedActionItems(onSelect: (Action) -> Unit, onLongSelect: (Action) -> Unit) {
|
fun RowScope.PinnedActionItems(onSelect: (Action) -> Unit, onLongSelect: (Action) -> Unit) {
|
||||||
val actions = if(!LocalInspectionMode.current) {
|
val actions = if(!LocalInspectionMode.current) {
|
||||||
@ -658,8 +667,10 @@ fun ActionBar(
|
|||||||
MaterialTheme.colorScheme.surfaceVariant
|
MaterialTheme.colorScheme.surfaceVariant
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val oldActionBar = useDataStore(OldStyleActionsBar)
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
if(isActionsExpanded) {
|
if(isActionsExpanded && !oldActionBar.value) {
|
||||||
Box(modifier = Modifier
|
Box(modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.height(1.dp)
|
.height(1.dp)
|
||||||
@ -694,6 +705,11 @@ fun ActionBar(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(oldActionBar.value && isActionsExpanded) {
|
||||||
|
Box(modifier = Modifier.weight(1.0f).fillMaxHeight()) {
|
||||||
|
ActionItems(onActionActivated, onActionAltActivated)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (importantNotice != null) {
|
if (importantNotice != null) {
|
||||||
ImportantNoticeView(importantNotice)
|
ImportantNoticeView(importantNotice)
|
||||||
} else {
|
} else {
|
||||||
@ -733,6 +749,7 @@ fun ActionBar(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -17,6 +17,7 @@ import kotlinx.coroutines.withContext
|
|||||||
import org.futo.inputmethod.latin.BuildConfig
|
import org.futo.inputmethod.latin.BuildConfig
|
||||||
import org.futo.inputmethod.latin.R
|
import org.futo.inputmethod.latin.R
|
||||||
import org.futo.inputmethod.latin.uix.HiddenKeysSetting
|
import org.futo.inputmethod.latin.uix.HiddenKeysSetting
|
||||||
|
import org.futo.inputmethod.latin.uix.OldStyleActionsBar
|
||||||
import org.futo.inputmethod.latin.uix.SettingsKey
|
import org.futo.inputmethod.latin.uix.SettingsKey
|
||||||
import org.futo.inputmethod.latin.uix.settings.NavigationItem
|
import org.futo.inputmethod.latin.uix.settings.NavigationItem
|
||||||
import org.futo.inputmethod.latin.uix.settings.NavigationItemStyle
|
import org.futo.inputmethod.latin.uix.settings.NavigationItemStyle
|
||||||
@ -55,6 +56,8 @@ fun DeveloperScreen(navController: NavHostController = rememberNavController())
|
|||||||
|
|
||||||
SettingToggleDataStore(title = "Dismissed migration notice", setting = dismissedMigrateUpdateNotice)
|
SettingToggleDataStore(title = "Dismissed migration notice", setting = dismissedMigrateUpdateNotice)
|
||||||
|
|
||||||
|
SettingToggleDataStore(title = "Old action bar", setting = OldStyleActionsBar)
|
||||||
|
|
||||||
NavigationItem(
|
NavigationItem(
|
||||||
title = "Crash the app",
|
title = "Crash the app",
|
||||||
style = NavigationItemStyle.MiscNoArrow,
|
style = NavigationItemStyle.MiscNoArrow,
|
||||||
|
Loading…
Reference in New Issue
Block a user