Skip to content

Commit ef9e0af

Browse files
authored
Merge pull request #92 from wxxsfxyzm/hotfix
fix(installer): improve SDK info layout and animation in InstallInfoDialog
2 parents 9719651 + ab37feb commit ef9e0af

1 file changed

Lines changed: 80 additions & 85 deletions

File tree

app/src/main/java/com/rosan/installer/ui/page/installer/dialog/inner/InstallInfoDialog.kt

Lines changed: 80 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
package com.rosan.installer.ui.page.installer.dialog.inner
22

3-
// import androidx.compose.runtime.LaunchedEffect // No longer needed here
4-
// import androidx.compose.runtime.getValue // No longer needed here
5-
// import androidx.compose.runtime.mutableStateOf // No longer needed here
6-
// import androidx.compose.runtime.remember // No longer needed here
7-
// import androidx.compose.runtime.setValue // No longer needed here
8-
// import com.rosan.installer.ui.page.installer.dialog.DialogViewState // No longer needed here
93
import android.os.Build
104
import androidx.compose.animation.AnimatedVisibility
115
import androidx.compose.foundation.ExperimentalFoundationApi
@@ -33,7 +27,6 @@ import androidx.compose.runtime.getValue
3327
import androidx.compose.ui.Alignment
3428
import androidx.compose.ui.Modifier
3529
import androidx.compose.ui.draw.clip
36-
import androidx.compose.ui.platform.LocalDensity
3730
import androidx.compose.ui.res.stringResource
3831
import androidx.compose.ui.text.style.TextAlign
3932
import androidx.compose.ui.unit.dp
@@ -62,7 +55,6 @@ fun installInfoDialog(
6255
preInstallAppInfo: InstalledAppInfo?, // Crucial parameter: Info *before* install operation
6356
onTitleExtraClick: () -> Unit = {}
6457
): DialogParams {
65-
val density = LocalDensity.current
6658
val iconMap by viewModel.displayIcons.collectAsState()
6759
val selectedApps = installer.entities.filter { it.selected }.map { it.app }
6860
// If no apps are selected, return empty DialogParams
@@ -129,7 +121,7 @@ fun installInfoDialog(
129121
subtitle = DialogInnerParams(uniqueContentKey) {
130122
Column(
131123
horizontalAlignment = Alignment.CenterHorizontally,
132-
verticalArrangement = Arrangement.spacedBy(4.dp)
124+
// verticalArrangement = Arrangement.spacedBy(4.dp) // Removed to avoid spacing issues during animation
133125
) {
134126
// --- 显示包名 ---
135127
Text(
@@ -142,9 +134,7 @@ fun installInfoDialog(
142134

143135
// --- 显示版本信息 ---
144136
if (entityToInstall is AppEntity.BaseEntity) {
145-
// 直接使用传入的 preInstallAppInfo 作为旧版本信息
146-
val oldInfo = preInstallAppInfo
147-
if (oldInfo == null) {
137+
if (preInstallAppInfo == null) {
148138
// 首次安装或无法获取旧信息: 只显示新版本,不带前缀
149139
Text(
150140
text = stringResource(
@@ -163,8 +153,8 @@ fun installInfoDialog(
163153
Text( // 旧版本带前缀
164154
text = stringResource(R.string.old_version_prefix) + stringResource(
165155
R.string.installer_version_short,
166-
oldInfo.versionName,
167-
oldInfo.versionCode
156+
preInstallAppInfo.versionName,
157+
preInstallAppInfo.versionCode
168158
),
169159
textAlign = TextAlign.Center,
170160
modifier = Modifier.basicMarquee()
@@ -173,14 +163,14 @@ fun installInfoDialog(
173163
imageVector = AppIcons.ArrowDropDownFilled,
174164
contentDescription = "to",
175165
tint =
176-
if (oldInfo.versionCode > entityToInstall.versionCode)
166+
if (preInstallAppInfo.versionCode > entityToInstall.versionCode)
177167
MaterialTheme.colorScheme.error
178168
else
179169
MaterialTheme.colorScheme.primary,
180170
modifier = Modifier.size(24.dp)
181171
)
182172
Text( // 新版本带前缀
183-
text = if (entityToInstall.versionCode >= oldInfo.versionCode)
173+
text = if (entityToInstall.versionCode >= preInstallAppInfo.versionCode)
184174
stringResource(R.string.upgrade_version_prefix) + stringResource(
185175
R.string.installer_version_short,
186176
entityToInstall.versionName,
@@ -190,7 +180,7 @@ fun installInfoDialog(
190180
entityToInstall.versionName,
191181
entityToInstall.versionCode
192182
),
193-
color = if (oldInfo.versionCode > entityToInstall.versionCode)
183+
color = if (preInstallAppInfo.versionCode > entityToInstall.versionCode)
194184
MaterialTheme.colorScheme.error
195185
else
196186
MaterialTheme.colorScheme.primary,
@@ -200,86 +190,91 @@ fun installInfoDialog(
200190
}
201191
}
202192
}
203-
// --- SDK版本变动显示 ---
204-
// 如果有SDK信息则显示SDK
205-
val oldInfo = preInstallAppInfo
206-
// Min SDK
207-
entityToInstall.minSdk?.let { newMinSdk ->
208-
AnimatedVisibility(visible = installer.config.displaySdk) {
193+
// --- SDK Information Showcase ---
194+
// Use a single AnimatedVisibility to control the entire SDK block
195+
AnimatedVisibility(visible = installer.config.displaySdk) {
196+
Column(
197+
horizontalAlignment = Alignment.CenterHorizontally,
198+
// Spacing between Min and Target SDK is now handled cleanly here.
199+
verticalArrangement = Arrangement.spacedBy(4.dp)
200+
) {
201+
// This Spacer creates a gap between the version info above and this SDK block.
202+
// It's animated along with the content, ensuring a smooth transition.
203+
Spacer(modifier = Modifier.size(4.dp))
204+
// Min SDK
205+
entityToInstall.minSdk?.let { newMinSdk ->
206+
val oldMinSdk = preInstallAppInfo?.minSdk
207+
if (oldMinSdk != null && oldMinSdk.toString() != newMinSdk) {
208+
Row(verticalAlignment = Alignment.CenterVertically) {
209+
Text(
210+
text = stringResource(
211+
R.string.installer_package_min_sdk,
212+
oldMinSdk.toString()
213+
)
214+
)
215+
Icon(
216+
modifier = Modifier.size(24.dp),
217+
imageVector = AppIcons.ArrowRight,
218+
tint =
219+
if (newMinSdk.toInt() > Build.VERSION.SDK_INT)
220+
MaterialTheme.colorScheme.error
221+
else
222+
MaterialTheme.colorScheme.primary,
223+
contentDescription = null
224+
)
225+
Text(
226+
text = newMinSdk,
227+
color =
228+
if (newMinSdk.toInt() > Build.VERSION.SDK_INT)
229+
MaterialTheme.colorScheme.error
230+
else
231+
MaterialTheme.colorScheme.primary,
232+
)
209233

210-
val oldMinSdk = oldInfo?.minSdk
211-
if (oldMinSdk != null && oldMinSdk.toString() != newMinSdk) {
212-
Row(verticalAlignment = Alignment.CenterVertically) {
234+
}
235+
} else {
213236
Text(
214237
text = stringResource(
215238
R.string.installer_package_min_sdk,
216-
oldMinSdk.toString()
217-
)
218-
)
219-
Icon(
220-
modifier = Modifier.size(24.dp),
221-
imageVector = AppIcons.ArrowRight,
222-
tint =
223-
if (newMinSdk.toInt() > Build.VERSION.SDK_INT)
224-
MaterialTheme.colorScheme.error
225-
else
226-
MaterialTheme.colorScheme.primary,
227-
contentDescription = null
228-
)
229-
Text(
230-
text = newMinSdk,
231-
color =
232-
if (newMinSdk.toInt() > Build.VERSION.SDK_INT)
233-
MaterialTheme.colorScheme.error
234-
else
235-
MaterialTheme.colorScheme.primary,
239+
newMinSdk
240+
),
241+
textAlign = TextAlign.Center,
242+
modifier = Modifier.basicMarquee()
236243
)
237-
238244
}
239-
} else {
240-
Text(
241-
text = stringResource(
242-
R.string.installer_package_min_sdk,
243-
newMinSdk
244-
),
245-
textAlign = TextAlign.Center,
246-
modifier = Modifier.basicMarquee()
247-
)
248245
}
249-
}
250-
}
251-
// Target SDK
252-
entityToInstall.targetSdk?.let { newTargetSdk ->
253-
AnimatedVisibility(visible = installer.config.displaySdk) {
254-
val oldTargetSdk = oldInfo?.targetSdk
255-
if (oldTargetSdk != null && oldTargetSdk.toString() != newTargetSdk) {
256-
Row(verticalAlignment = Alignment.CenterVertically) {
246+
// Target SDK
247+
entityToInstall.targetSdk?.let { newTargetSdk ->
248+
val oldTargetSdk = preInstallAppInfo?.targetSdk
249+
if (oldTargetSdk != null && oldTargetSdk.toString() != newTargetSdk) {
250+
Row(verticalAlignment = Alignment.CenterVertically) {
251+
Text(
252+
text = stringResource(
253+
R.string.installer_package_target_sdk,
254+
oldTargetSdk.toString()
255+
)
256+
)
257+
Icon(
258+
modifier = Modifier.size(24.dp),
259+
imageVector = AppIcons.ArrowRight,
260+
tint = MaterialTheme.colorScheme.primary,
261+
contentDescription = null
262+
)
263+
Text(
264+
text = newTargetSdk,
265+
color = MaterialTheme.colorScheme.primary,
266+
)
267+
}
268+
} else {
257269
Text(
258270
text = stringResource(
259271
R.string.installer_package_target_sdk,
260-
oldTargetSdk.toString()
261-
)
262-
)
263-
Icon(
264-
modifier = Modifier.size(24.dp),
265-
imageVector = AppIcons.ArrowRight,
266-
tint = MaterialTheme.colorScheme.primary,
267-
contentDescription = null
268-
)
269-
Text(
270-
text = newTargetSdk,
271-
color = MaterialTheme.colorScheme.primary,
272+
newTargetSdk
273+
),
274+
textAlign = TextAlign.Center,
275+
modifier = Modifier.basicMarquee()
272276
)
273277
}
274-
} else {
275-
Text(
276-
text = stringResource(
277-
R.string.installer_package_target_sdk,
278-
newTargetSdk
279-
),
280-
textAlign = TextAlign.Center,
281-
modifier = Modifier.basicMarquee()
282-
)
283278
}
284279
}
285280
}

0 commit comments

Comments
 (0)