feat: 新增扫码功能
- 添加 CameraX 和 ML Kit Barcode Scanning 依赖,用于实现二维码扫描。 - 在 AndroidManifest.xml 中添加相机权限声明。 - 新增 `ScanQrScreen` 扫码页面及相应的 `ScanQr` 导航路由。 - 在首页右上角菜单中,为“扫一扫”按钮添加跳转到扫码页面的功能。
This commit is contained in:
@@ -127,5 +127,11 @@ dependencies {
|
|||||||
implementation (libs.eventbus)
|
implementation (libs.eventbus)
|
||||||
implementation(libs.lottie)
|
implementation(libs.lottie)
|
||||||
|
|
||||||
|
// CameraX + ML Kit(版本在 libs.versions.toml)
|
||||||
|
implementation(libs.androidx.camera.camera2)
|
||||||
|
implementation(libs.androidx.camera.lifecycle)
|
||||||
|
implementation(libs.androidx.camera.view)
|
||||||
|
implementation(libs.mlkit.barcode.scanning)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
<uses-feature android:name="android.hardware.camera.any" android:required="false" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".RaveNowApplication"
|
android:name=".RaveNowApplication"
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ import com.aiosman.ravenow.ui.post.PostScreen
|
|||||||
import com.aiosman.ravenow.ui.profile.AccountProfileV2
|
import com.aiosman.ravenow.ui.profile.AccountProfileV2
|
||||||
import com.aiosman.ravenow.ui.index.tabs.profile.vip.VipSelPage
|
import com.aiosman.ravenow.ui.index.tabs.profile.vip.VipSelPage
|
||||||
import com.aiosman.ravenow.ui.notification.NotificationScreen
|
import com.aiosman.ravenow.ui.notification.NotificationScreen
|
||||||
|
import com.aiosman.ravenow.ui.scan.ScanQrScreen
|
||||||
|
|
||||||
sealed class NavigationRoute(
|
sealed class NavigationRoute(
|
||||||
val route: String,
|
val route: String,
|
||||||
@@ -130,6 +131,7 @@ sealed class NavigationRoute(
|
|||||||
data object NotificationScreen : NavigationRoute("NotificationScreen")
|
data object NotificationScreen : NavigationRoute("NotificationScreen")
|
||||||
data object MbtiSelect : NavigationRoute("MbtiSelect")
|
data object MbtiSelect : NavigationRoute("MbtiSelect")
|
||||||
data object ZodiacSelect : NavigationRoute("ZodiacSelect")
|
data object ZodiacSelect : NavigationRoute("ZodiacSelect")
|
||||||
|
data object ScanQr : NavigationRoute("ScanQr")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -453,6 +455,9 @@ fun NavigationController(
|
|||||||
SearchScreen()
|
SearchScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
composable(route = NavigationRoute.ScanQr.route) {
|
||||||
|
ScanQrScreen()
|
||||||
|
}
|
||||||
composable(
|
composable(
|
||||||
route = NavigationRoute.FollowerList.route,
|
route = NavigationRoute.FollowerList.route,
|
||||||
arguments = listOf(navArgument("id") { type = NavType.IntType })
|
arguments = listOf(navArgument("id") { type = NavType.IntType })
|
||||||
|
|||||||
@@ -586,7 +586,11 @@ fun SideMenuContent(
|
|||||||
.align(Alignment.TopEnd)
|
.align(Alignment.TopEnd)
|
||||||
.offset(x = (-112).dp, y = 88.dp)
|
.offset(x = (-112).dp, y = 88.dp)
|
||||||
.noRippleClickable {
|
.noRippleClickable {
|
||||||
// TODO: 实现扫一扫功能
|
// 扫一扫功能:跳转到扫码页面
|
||||||
|
coroutineScope.launch {
|
||||||
|
onClose()
|
||||||
|
navController.navigate(NavigationRoute.ScanQr.route)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ lifecycleProcess = "2.8.4"
|
|||||||
playServicesAuth = "21.4.0"
|
playServicesAuth = "21.4.0"
|
||||||
rendering = "1.17.1"
|
rendering = "1.17.1"
|
||||||
zoomable = "1.6.1"
|
zoomable = "1.6.1"
|
||||||
|
camerax = "1.3.4"
|
||||||
|
mlkitBarcode = "17.3.0"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanistSystemuicontroller" }
|
accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanistSystemuicontroller" }
|
||||||
@@ -56,6 +58,9 @@ androidx-media3-ui = { module = "androidx.media3:media3-ui", version.ref = "medi
|
|||||||
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigationCompose" }
|
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigationCompose" }
|
||||||
androidx-paging-compose = { module = "androidx.paging:paging-compose", version.ref = "pagingRuntime" }
|
androidx-paging-compose = { module = "androidx.paging:paging-compose", version.ref = "pagingRuntime" }
|
||||||
androidx-paging-runtime = { module = "androidx.paging:paging-runtime", version.ref = "pagingRuntime" }
|
androidx-paging-runtime = { module = "androidx.paging:paging-runtime", version.ref = "pagingRuntime" }
|
||||||
|
androidx-camera-camera2 = { module = "androidx.camera:camera-camera2", version.ref = "camerax" }
|
||||||
|
androidx-camera-lifecycle = { module = "androidx.camera:camera-lifecycle", version.ref = "camerax" }
|
||||||
|
androidx-camera-view = { module = "androidx.camera:camera-view", version.ref = "camerax" }
|
||||||
coil = { module = "io.coil-kt:coil", version.ref = "coil" }
|
coil = { module = "io.coil-kt:coil", version.ref = "coil" }
|
||||||
coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
|
coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
|
||||||
compose-image-blurhash = { module = "com.github.orlando-dev-code:compose-image-blurhash", version.ref = "composeImageBlurhash" }
|
compose-image-blurhash = { module = "com.github.orlando-dev-code:compose-image-blurhash", version.ref = "composeImageBlurhash" }
|
||||||
@@ -99,6 +104,7 @@ rendering = { group = "com.google.ar.sceneform", name = "rendering", version.ref
|
|||||||
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "converterGson" }
|
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "converterGson" }
|
||||||
zoomable = { module = "net.engawapg.lib:zoomable", version.ref = "zoomable" }
|
zoomable = { module = "net.engawapg.lib:zoomable", version.ref = "zoomable" }
|
||||||
lottie = { module="com.airbnb.android:lottie-compose", version="6.6.10"}
|
lottie = { module="com.airbnb.android:lottie-compose", version="6.6.10"}
|
||||||
|
mlkit-barcode-scanning = { module = "com.google.mlkit:barcode-scanning", version.ref = "mlkitBarcode" }
|
||||||
[plugins]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
|
|||||||
Reference in New Issue
Block a user