@@ -3,7 +3,10 @@ package com.jankinwu.fntv.client.ui.screen
33import androidx.compose.animation.AnimatedVisibility
44import androidx.compose.animation.slideInHorizontally
55import androidx.compose.animation.slideOutHorizontally
6+ import androidx.compose.foundation.BorderStroke
7+ import androidx.compose.foundation.ExperimentalFoundationApi
68import androidx.compose.foundation.Image
9+ import androidx.compose.foundation.TooltipArea
710import androidx.compose.foundation.background
811import androidx.compose.foundation.border
912import androidx.compose.foundation.clickable
@@ -126,7 +129,9 @@ data class FnConnectWindowRequest(
126129 val onBaseUrlDetected : ((String ) -> Unit )? = null
127130)
128131
129- @OptIn(ExperimentalHazeMaterialsApi ::class , ExperimentalComposeUiApi ::class )
132+ @OptIn(ExperimentalHazeMaterialsApi ::class , ExperimentalComposeUiApi ::class ,
133+ ExperimentalFoundationApi ::class
134+ )
130135@Suppress(" RememberReturnType" )
131136@Composable
132137fun LoginScreen (
@@ -401,16 +406,43 @@ fun LoginScreen(
401406 modifier = Modifier
402407 .padding(horizontal = 4 .dp, vertical = 12 .dp)
403408 )
404- NumberInput (
405- onValueChange = { port = it },
406- value = port,
409+ TooltipArea (
407410 modifier = Modifier .weight(1.0f ),
408- placeholder = " 端口" ,
409- minValue = 0 ,
410- label = " " ,
411- textColor = Colors .TextSecondaryColor ,
412- defaultValue = 5666
413- )
411+ tooltip = {
412+ Surface (
413+ modifier = Modifier .padding(4 .dp),
414+ color = FluentTheme .colors.background.smoke.default.copy(
415+ alpha = 0.8f
416+ ),
417+ shape = RoundedCornerShape (4 .dp),
418+ border = BorderStroke (
419+ 1 .dp,
420+ FluentTheme .colors.text.text.primary
421+ ),
422+ ) {
423+ Text (
424+ text = " 端口,填 0 代表使用 HTTP 或 HTTPS 协议的默认端口" ,
425+ modifier = Modifier
426+ .padding(8 .dp),
427+ // .width(200.dp),
428+ color = FluentTheme .colors.text.text.primary,
429+ style = FluentTheme .typography.caption
430+ )
431+ }
432+ },
433+ delayMillis = 800 ,
434+ ) {
435+ NumberInput (
436+ onValueChange = { port = it },
437+ value = port,
438+ modifier = Modifier ,
439+ placeholder = " 端口" ,
440+ minValue = 0 ,
441+ label = " " ,
442+ textColor = Colors .TextSecondaryColor ,
443+ defaultValue = 5666
444+ )
445+ }
414446 }
415447
416448 OutlinedTextField (
@@ -680,13 +712,11 @@ fun LoginScreen(
680712 password =
681713 if (history.rememberPassword) history.password.orEmpty() else " "
682714 rememberPassword = history.rememberPassword
683- val displayHost = history.displayHost
684- val displayPort = history.displayPort
685715 // 如果有密码,则直接登录
686716 if (history.rememberPassword && ! history.password.isNullOrEmpty()) {
687717 handleLogin(
688- host = history.displayHost,
689- port = history.displayPort,
718+ host = history.displayHost.ifBlank { history.host } ,
719+ port = history.displayPort ? : history.port ,
690720 username = history.username,
691721 password = history.password,
692722 isHttps = history.isHttps,
@@ -746,17 +776,23 @@ fun LoginScreen(
746776// unfocusedTextColor = Colors.TextSecondaryColor
747777// )
748778
749- internal fun updateLoginHistory (current : List <LoginHistory >, incoming : LoginHistory ): List <LoginHistory > {
779+ internal fun updateLoginHistory (
780+ current : List <LoginHistory >,
781+ incoming : LoginHistory
782+ ): List <LoginHistory > {
750783 fun normalize (value : String ): String = value.trim().lowercase()
751784
752785 fun isSameIdentity (a : LoginHistory , b : LoginHistory ): Boolean {
753786 if (a.isNasLogin != b.isNasLogin) return false
754787 return if (a.isNasLogin) {
755788 normalize(a.fnId) == normalize(b.fnId) && normalize(a.username) == normalize(b.username)
756- && a.isHttps == b.isHttps
757789 } else {
790+ if (a.displayHost.isBlank() || a.displayPort == null ) {
791+ return normalize(a.host) == normalize(b.displayHost) && a.port == b.displayPort
792+ && normalize(a.username) == normalize(b.username)
793+ }
758794 normalize(a.displayHost) == normalize(b.displayHost) && a.displayPort == b.displayPort
759- && normalize(a.username) == normalize(b.username) && a.isHttps == b.isHttps
795+ && normalize(a.username) == normalize(b.username)
760796 }
761797 }
762798
0 commit comments