Przeglądaj źródła

1. 适配登录页面显示区域

bjb 1 miesiąc temu
rodzic
commit
93e6b04966

+ 89 - 21
app/src/main/java/com/iscs/bozzys/ui/pages/login/PageLogin.kt

@@ -84,7 +84,10 @@ class PageLogin : PageBase() {
             Modifier
                 .fillMaxSize()
                 .background(Color.White)
-                .clickable(onClick = { keyboard?.hide() }, indication = null, interactionSource = remember { MutableInteractionSource() })
+                .clickable(
+                    onClick = { keyboard?.hide() },
+                    indication = null,
+                    interactionSource = remember { MutableInteractionSource() })
         ) {
             // 顶部显示模块
             Column(
@@ -140,14 +143,22 @@ class PageLogin : PageBase() {
         Column(
             Modifier
                 .fillMaxSize()
-                .verticalScroll(rememberScrollState()), horizontalAlignment = Alignment.CenterHorizontally
+                .verticalScroll(rememberScrollState()),
+            horizontalAlignment = Alignment.CenterHorizontally
         ) {
-            Text("欢迎登录", fontSize = 20.sp, fontWeight = FontWeight.SemiBold, color = Text, modifier = Modifier.padding(top = 30.dp))
+            Text(
+                "欢迎登录",
+                fontSize = 20.sp,
+                fontWeight = FontWeight.SemiBold,
+                color = Text,
+                modifier = Modifier.padding(top = 30.dp)
+            )
             Spacer(Modifier.weight(1f))
             Row(
                 Modifier
                     .padding(top = 24.dp)
-                    .size(335.dp, 47.dp)
+                    .fillMaxWidth(0.8f)
+                    .height(47.dp)
                     .border(1.dp, color = Color(0xFFD1D5DB), shape = RoundedCornerShape(12.dp))
                     .clip(RoundedCornerShape(12.dp)),
                 verticalAlignment = Alignment.CenterVertically
@@ -182,13 +193,19 @@ class PageLogin : PageBase() {
             Row(
                 Modifier
                     .padding(top = 24.dp)
-                    .size(335.dp, 50.dp)
+                    .fillMaxWidth(0.8f)
+                    .height(50.dp)
                     .border(1.dp, color = Color(0xFFD1D5DB), shape = RoundedCornerShape(5.dp))
                     .padding(horizontal = 12.dp),
                 verticalAlignment = Alignment.CenterVertically
             ) {
                 val resId = if (state.loginType == 0) R.drawable.phone else R.drawable.user
-                Icon(painter = painterResource(resId), contentDescription = null, tint = Color(0xFF999999), modifier = Modifier.size(18.dp))
+                Icon(
+                    painter = painterResource(resId),
+                    contentDescription = null,
+                    tint = Color(0xFF999999),
+                    modifier = Modifier.size(18.dp)
+                )
                 BasicTextField(
                     state.account,
                     onValueChange = { value ->
@@ -210,8 +227,15 @@ class PageLogin : PageBase() {
                         Box(contentAlignment = Alignment.CenterStart) {
                             innerTextField()
                             if (state.account.isEmpty()) {
-                                val text = if (state.loginType == 0) "请输入手机号" else "请输入用户名"
-                                Text(text, color = Color(0xFF9CA3AF), fontSize = 16.sp, lineHeight = 20.sp, modifier = Modifier.offset(y = (-1).dp))
+                                val text =
+                                    if (state.loginType == 0) "请输入手机号" else "请输入用户名"
+                                Text(
+                                    text,
+                                    color = Color(0xFF9CA3AF),
+                                    fontSize = 16.sp,
+                                    lineHeight = 20.sp,
+                                    modifier = Modifier.offset(y = (-1).dp)
+                                )
                             }
                         }
                     },
@@ -222,13 +246,19 @@ class PageLogin : PageBase() {
             Row(
                 Modifier
                     .padding(top = 20.dp)
-                    .size(335.dp, 50.dp)
+                    .fillMaxWidth(0.8f)
+                    .height(50.dp)
                     .border(1.dp, color = Color(0xFFD1D5DB), shape = RoundedCornerShape(5.dp))
                     .padding(horizontal = 12.dp),
                 verticalAlignment = Alignment.CenterVertically
             ) {
                 val resId = if (state.loginType == 0) R.drawable.code else R.drawable.pwd
-                Icon(painter = painterResource(resId), contentDescription = null, tint = Color(0xFF999999), modifier = Modifier.size(18.dp))
+                Icon(
+                    painter = painterResource(resId),
+                    contentDescription = null,
+                    tint = Color(0xFF999999),
+                    modifier = Modifier.size(18.dp)
+                )
                 BasicTextField(
                     state.code,
                     onValueChange = { value ->
@@ -250,8 +280,15 @@ class PageLogin : PageBase() {
                         Box(contentAlignment = Alignment.CenterStart) {
                             innerTextField()
                             if (state.code.isEmpty()) {
-                                val text = if (state.loginType == 0) "请输入验证码" else "请输入密码"
-                                Text(text, color = Color(0xFF9CA3AF), fontSize = 16.sp, lineHeight = 20.sp, modifier = Modifier.offset(y = (-1).dp))
+                                val text =
+                                    if (state.loginType == 0) "请输入验证码" else "请输入密码"
+                                Text(
+                                    text,
+                                    color = Color(0xFF9CA3AF),
+                                    fontSize = 16.sp,
+                                    lineHeight = 20.sp,
+                                    modifier = Modifier.offset(y = (-1).dp)
+                                )
                             }
                         }
                     },
@@ -261,7 +298,7 @@ class PageLogin : PageBase() {
                 )
             }
             if (state.showTenantId) {
-                Row(modifier = Modifier.width(335.dp)) {
+                Row(modifier = Modifier.fillMaxWidth(0.8f)) {
                     Spacer(Modifier.weight(1f))
                     Text(
                         "关联租户",
@@ -300,7 +337,8 @@ class PageLogin : PageBase() {
                     }
                 }, Modifier
                     .padding(top = 30.dp)
-                    .size(335.dp, 52.dp)
+                    .fillMaxWidth(0.8f)
+                    .height(52.dp)
                     .clip(RoundedCornerShape(5.dp))
                     .background(Main)
             ) {
@@ -308,11 +346,24 @@ class PageLogin : PageBase() {
             }
             // 账号提示
             Row(Modifier.padding(top = 16.dp), verticalAlignment = Alignment.CenterVertically) {
-                Icon(painter = painterResource(R.drawable.tips), contentDescription = null, tint = Color(0xFF6B7280), modifier = Modifier.size(12.dp))
-                Text("工业安全系统,请妥善保管账号信息", Modifier.padding(start = 5.dp), fontSize = 12.sp, color = Color(0xFF6B7280))
+                Icon(
+                    painter = painterResource(R.drawable.tips),
+                    contentDescription = null,
+                    tint = Color(0xFF6B7280),
+                    modifier = Modifier.size(12.dp)
+                )
+                Text(
+                    "工业安全系统,请妥善保管账号信息",
+                    Modifier.padding(start = 5.dp),
+                    fontSize = 12.sp,
+                    color = Color(0xFF6B7280)
+                )
             }
             // 其他登录方式
-            if (fingerSupport) Box(Modifier.padding(top = 20.dp), contentAlignment = Alignment.Center) {
+            if (fingerSupport) Box(
+                Modifier.padding(top = 20.dp),
+                contentAlignment = Alignment.Center
+            ) {
                 Spacer(
                     Modifier
                         .size(335.dp, 1.dp)
@@ -325,7 +376,10 @@ class PageLogin : PageBase() {
                     fontSize = 14.sp, color = Color(0xFF999999)
                 )
             }
-            Row(Modifier.padding(top = 30.dp, bottom = 10.dp), verticalAlignment = Alignment.CenterVertically) {
+            Row(
+                Modifier.padding(top = 30.dp, bottom = 10.dp),
+                verticalAlignment = Alignment.CenterVertically
+            ) {
                 if (fingerSupport) Icon(
                     painter = painterResource(R.drawable.fingerprint),
                     contentDescription = null,
@@ -335,7 +389,11 @@ class PageLogin : PageBase() {
                         .clip(RoundedCornerShape(50))
                         .clickable {
                             val cipher = BiometricKeyStore.decryptCipher(Storage.readTokenIv())
-                            SystemUtil.showFingerAuth(this@PageLogin, cipher, Storage.readTokenIvValue()) {
+                            SystemUtil.showFingerAuth(
+                                this@PageLogin,
+                                cipher,
+                                Storage.readTokenIvValue()
+                            ) {
                                 // LogUtil.i("xiaoming", "当前 token -> ${Storage.readToken()}")
                                 // LogUtil.i("xiaoming", "解密 token -> ${String(it)}")
                             }
@@ -376,8 +434,18 @@ class PageLogin : PageBase() {
                         .height(1.dp)
                         .background(Color(0xFFEEEEEE))
                 )
-                Text("LOTO智能锁控·能量安全隔离", Modifier.padding(top = 20.dp, bottom = 4.dp), fontSize = 14.sp, color = Color(0xFF666666))
-                Text("版本 v${ctx.getAppVersionInfo().second}", Modifier.padding(bottom = 20.dp), fontSize = 14.sp, color = Color(0xFF666666))
+                Text(
+                    "LOTO智能锁控·能量安全隔离",
+                    Modifier.padding(top = 20.dp, bottom = 4.dp),
+                    fontSize = 14.sp,
+                    color = Color(0xFF666666)
+                )
+                Text(
+                    "版本 v${ctx.getAppVersionInfo().second}",
+                    Modifier.padding(bottom = 20.dp),
+                    fontSize = 14.sp,
+                    color = Color(0xFF666666)
+                )
             }
             Spacer(Modifier.weight(1f))
         }