Skip to content

Commit

Permalink
7.0.3 (#516)
Browse files Browse the repository at this point in the history
* fix: 修复固定歌词宽度滚动不到位问题

* fix: ui: 限制页面返回范围

* opt: 横屏 UI

* opt: 修复 #511

* fix: 修复歌词滚动过头

* fix: 使用横屏小窗时歌词被隐藏的问题 (#515)

---------

Co-authored-by: 焕晨HChen <[email protected]>
  • Loading branch information
YuKongA and HChenX authored Jan 3, 2025
1 parent 17333a1 commit c16aa34
Show file tree
Hide file tree
Showing 19 changed files with 338 additions and 167 deletions.
8 changes: 6 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@
tools:ignore="AllowBackup">
<activity
android:name=".MainActivity"
android:enableOnBackInvokedCallback="false"
android:exported="true"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
tools:ignore="UnusedAttribute">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="de.robv.android.xposed.category.MODULE_SETTINGS" />
</intent-filter>
</activity>
<activity-alias
android:name=".AliasActivity"
android:enableOnBackInvokedCallback="false"
android:exported="true"
android:targetActivity=".MainActivity"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
tools:ignore="UnusedAttribute">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
97 changes: 77 additions & 20 deletions app/src/main/kotlin/statusbar/lyric/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,31 @@ import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.core.app.ActivityCompat.finishAffinity
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import statusbar.lyric.MainActivity.Companion.context
import statusbar.lyric.ui.page.ChoosePage
import statusbar.lyric.ui.page.ExtendPage
import statusbar.lyric.ui.page.HomePage
Expand All @@ -35,32 +46,46 @@ import top.yukonga.miuix.kmp.basic.Box
import top.yukonga.miuix.kmp.basic.Icon
import top.yukonga.miuix.kmp.basic.Scaffold
import top.yukonga.miuix.kmp.theme.MiuixTheme
import top.yukonga.miuix.kmp.utils.BackHandler
import top.yukonga.miuix.kmp.utils.getWindowSize

@SuppressLint("UnusedBoxWithConstraintsScope")
@Composable
fun App() {
val configuration = LocalConfiguration.current
val isLandscape = configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
val navController = rememberNavController()
val currentStartDestination = remember { mutableStateOf("") }

AppTheme {
Scaffold {
BoxWithConstraints {
if (isLandscape || maxWidth > 768.dp) {
LandscapeLayout()
LandscapeLayout(navController, currentStartDestination)
} else {
PortraitLayout()
PortraitLayout(navController, currentStartDestination)
}
}
}
}
}

@Composable
fun PortraitLayout() {
fun PortraitLayout(navController: NavHostController, currentStartDestination: MutableState<String>) {
val windowWidth = getWindowSize().width
val easing = CubicBezierEasing(0.12f, 0.38f, 0.2f, 1f)
val navController = rememberNavController()

LaunchedEffect(navController) {
currentStartDestination.value = "HomePage"
navController.addOnDestinationChangedListener { _, destination, _ ->
if (destination.route == "EmptyPage") {
navController.navigate("HomePage") {
popUpTo("HomePage") { inclusive = true }
}
}
}
}

NavHost(
navController = navController,
startDestination = "HomePage",
Expand Down Expand Up @@ -90,21 +115,34 @@ fun PortraitLayout() {
}
) {
composable("HomePage") { HomePage(navController) }
composable("MenuPage") { MenuPage(navController) }
composable("EmptyPage") { EmptyPage() }
composable("MenuPage") { MenuPage(navController, currentStartDestination) }
composable("ChoosePage") { ChoosePage(navController) }
composable("TestPage") { TestPage(navController) }
composable("LyricPage") { LyricPage(navController) }
composable("IconPage") { IconPage(navController) }
composable("ExtendPage") { ExtendPage(navController) }
composable("SystemSpecialPage") { SystemSpecialPage(navController) }
composable("TestPage") { TestPage(navController, currentStartDestination) }
composable("LyricPage") { LyricPage(navController, currentStartDestination) }
composable("IconPage") { IconPage(navController, currentStartDestination) }
composable("ExtendPage") { ExtendPage(navController, currentStartDestination) }
composable("SystemSpecialPage") { SystemSpecialPage(navController, currentStartDestination) }
}
}

@Composable
fun LandscapeLayout() {
fun LandscapeLayout(navController: NavHostController, currentStartDestination: MutableState<String>) {
val windowWidth = getWindowSize().width
val easing = CubicBezierEasing(0.12f, 0.88f, 0.2f, 1f)
val navController = rememberNavController()
val dividerLineColor = MiuixTheme.colorScheme.dividerLine

LaunchedEffect(navController) {
currentStartDestination.value = "EmptyPage"
navController.addOnDestinationChangedListener { _, destination, _ ->
if (destination.route == "HomePage") {
navController.navigate("EmptyPage") {
popUpTo("EmptyPage") { inclusive = true }
}
}
}
}

Row(
modifier = Modifier
.fillMaxSize()
Expand All @@ -115,6 +153,19 @@ fun LandscapeLayout() {
) {
HomePage(navController)
}
Canvas(
Modifier
.fillMaxHeight()
.padding(horizontal = 12.dp)
.width(0.75.dp)
) {
drawLine(
color = dividerLineColor,
strokeWidth = 0.75.dp.toPx(),
start = Offset(0.75.dp.toPx() / 2, 0f),
end = Offset(0.75.dp.toPx() / 2, size.height),
)
}
NavHost(
navController = navController,
startDestination = "EmptyPage",
Expand All @@ -123,25 +174,28 @@ fun LandscapeLayout() {
slideInHorizontally(
initialOffsetX = { windowWidth },
animationSpec = tween(durationMillis = 500, easing = easing)
) + fadeIn(
animationSpec = tween(durationMillis = 200)
)
},
exitTransition = {
slideOutHorizontally(
targetOffsetX = { windowWidth / 5 },
animationSpec = tween(durationMillis = 500, easing = easing)
) + fadeOut(
animationSpec = tween(durationMillis = 200)
animationSpec = tween(durationMillis = 500)
)
},
) {
composable("EmptyPage", exitTransition = { fadeOut() }, popEnterTransition = { fadeIn() }) { EmptyPage() }
composable("MenuPage") { MenuPage(navController) }
composable("HomePage") { HomePage(navController) }
composable("EmptyPage") { EmptyPage() }
composable("MenuPage") { MenuPage(navController, currentStartDestination) }
composable("ChoosePage") { ChoosePage(navController) }
composable("TestPage") { TestPage(navController) }
composable("LyricPage") { LyricPage(navController) }
composable("IconPage") { IconPage(navController) }
composable("ExtendPage") { ExtendPage(navController) }
composable("SystemSpecialPage") { SystemSpecialPage(navController) }
composable("TestPage") { TestPage(navController, currentStartDestination) }
composable("LyricPage") { LyricPage(navController, currentStartDestination) }
composable("IconPage") { IconPage(navController, currentStartDestination) }
composable("ExtendPage") { ExtendPage(navController, currentStartDestination) }
composable("SystemSpecialPage") { SystemSpecialPage(navController, currentStartDestination) }
}
}
}
Expand All @@ -152,6 +206,9 @@ fun EmptyPage() {
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
BackHandler(true) {
finishAffinity(context as MainActivity)
}
Icon(
painter = painterResource(R.drawable.ic_launcher_foreground),
contentDescription = null,
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/kotlin/statusbar/lyric/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Config {
}
var outLog: Boolean
get() {
return if (BuildConfig.DEBUG) true else config.opt("outlog", true)
return if (BuildConfig.DEBUG) true else config.opt("outlog", false)
}
set(value) {
config.put("outlog", value)
Expand Down Expand Up @@ -165,8 +165,7 @@ class Config {
}
var lyricEndMargins: Int
get() {

return config.opt("lyricEnd", if (XposedOwnSP.config.mHyperOSTexture) 20 else 7)
return config.opt("lyricEnd", if (XposedOwnSP.config.mHyperOSTexture) 20 else 10)
}
set(value) {
config.put("lyricEnd", value)
Expand Down
Loading

0 comments on commit c16aa34

Please sign in to comment.