7
7
package com.aliucord.manager.ui.screens.home
8
8
9
9
import androidx.compose.animation.*
10
- import androidx.compose.animation.core.tween
11
10
import androidx.compose.foundation.layout.*
12
11
import androidx.compose.foundation.lazy.LazyColumn
13
12
import androidx.compose.foundation.lazy.items
@@ -17,6 +16,9 @@ import androidx.compose.ui.Alignment
17
16
import androidx.compose.ui.Modifier
18
17
import androidx.compose.ui.draw.alpha
19
18
import androidx.compose.ui.res.stringResource
19
+ import androidx.compose.ui.text.SpanStyle
20
+ import androidx.compose.ui.text.font.FontWeight
21
+ import androidx.compose.ui.text.withStyle
20
22
import androidx.compose.ui.unit.dp
21
23
import cafe.adriel.voyager.core.screen.Screen
22
24
import cafe.adriel.voyager.koin.getScreenModel
@@ -27,6 +29,7 @@ import com.aliucord.manager.ui.components.ProjectHeader
27
29
import com.aliucord.manager.ui.components.dialogs.InstallerDialog
28
30
import com.aliucord.manager.ui.screens.home.components.*
29
31
import com.aliucord.manager.ui.screens.install.InstallScreen
32
+ import com.aliucord.manager.ui.screens.plugins.PluginsScreen
30
33
import com.aliucord.manager.ui.util.DiscordVersion
31
34
import com.aliucord.manager.ui.util.paddings.PaddingValuesSides
32
35
import com.aliucord.manager.ui.util.paddings.exclude
@@ -40,7 +43,6 @@ class HomeScreen : Screen {
40
43
val model = getScreenModel<HomeModel >()
41
44
42
45
var showInstallerDialog by remember { mutableStateOf(false ) }
43
-
44
46
if (showInstallerDialog) {
45
47
InstallerDialog (
46
48
onDismiss = { showInstallerDialog = false },
@@ -55,7 +57,7 @@ class HomeScreen : Screen {
55
57
topBar = { HomeAppBar () },
56
58
) { paddingValues ->
57
59
LazyColumn (
58
- verticalArrangement = Arrangement .spacedBy(4 .dp),
60
+ verticalArrangement = Arrangement .spacedBy(6 .dp),
59
61
horizontalAlignment = Alignment .CenterHorizontally ,
60
62
contentPadding = paddingValues
61
63
.exclude(PaddingValuesSides .Horizontal + PaddingValuesSides .Top ),
@@ -68,6 +70,17 @@ class HomeScreen : Screen {
68
70
ProjectHeader ()
69
71
}
70
72
73
+ item(key = " ADD_INSTALL_BUTTON" ) {
74
+ InstallButton (
75
+ // TODO: install options screen to configure pkg name
76
+ enabled = (model.installations as ? InstallsState .Fetched )?.data?.isEmpty() ? : false ,
77
+ onClick = { showInstallerDialog = true },
78
+ modifier = Modifier
79
+ .fillMaxWidth()
80
+ .padding(top = 10 .dp)
81
+ )
82
+ }
83
+
71
84
item(key = " SUPPORTED_VERSION" ) {
72
85
AnimatedVisibility (
73
86
enter = fadeIn() + slideInVertically { it * - 2 },
@@ -77,37 +90,19 @@ class HomeScreen : Screen {
77
90
VersionDisplay (
78
91
version = model.supportedVersion,
79
92
prefix = {
80
- append(stringResource(R .string.version_supported))
81
- append(" " )
93
+ withStyle(SpanStyle (fontWeight = FontWeight .Bold )) {
94
+ append(stringResource(R .string.version_supported))
95
+ append(" " )
96
+ }
82
97
},
83
- modifier = Modifier .alpha(.5f ),
98
+ modifier = Modifier
99
+ .alpha(.5f )
100
+ .padding(bottom = 22 .dp),
84
101
)
85
102
}
86
-
87
- Spacer (Modifier .height(12 .dp))
88
- }
89
-
90
- item(key = " INSTALL_BUTTON" ) {
91
- AnimatedVisibility (
92
- visible = model.installations !is InstallsFetchState .Fetching ,
93
- enter = fadeIn(
94
- animationSpec = tween(delayMillis = 700 )
95
- ) + slideInVertically(
96
- animationSpec = tween(delayMillis = 700 ),
97
- initialOffsetY = { it * 3 },
98
- ),
99
- exit = ExitTransition .None ,
100
- ) {
101
- InstallButton (
102
- onClick = { showInstallerDialog = true },
103
- modifier = Modifier .fillMaxWidth(),
104
- )
105
-
106
- Spacer (Modifier .height(4 .dp))
107
- }
108
103
}
109
104
110
- val installations = (model.installations as ? InstallsFetchState .Fetched )?.data
105
+ val installations = (model.installations as ? InstallsState .Fetched )?.data
111
106
? : return @LazyColumn
112
107
113
108
items(installations, key = { it.packageName }) {
@@ -117,13 +112,12 @@ class HomeScreen : Screen {
117
112
visible = model.supportedVersion !is DiscordVersion .None ,
118
113
) {
119
114
InstalledItemCard (
120
- appIcon = it.icon,
121
- appName = it.name,
122
- packageName = it.packageName,
123
- discordVersion = it.version,
124
- onOpenApp = { }, // TODO: multi-install open app handler
125
- onOpenInfo = {}, // TODO: multi-install open info handler
126
- onUninstall = {}, // TODO: multi-install uninstall handler
115
+ data = it,
116
+ onUpdate = { showInstallerDialog = true }, // TODO: prefilled install options screen
117
+ onOpenApp = { model.launchApp(it.packageName) },
118
+ onOpenInfo = { model.openAppInfo(it.packageName) },
119
+ onOpenPlugins = { navigator.push(PluginsScreen ()) }, // TODO: install-specific plugins
120
+ modifier = Modifier .fillMaxWidth()
127
121
)
128
122
}
129
123
}
0 commit comments