新增登录

This commit is contained in:
2024-07-30 16:57:25 +08:00
parent f28236b365
commit 2c79195f44
8 changed files with 237 additions and 63 deletions

View File

@@ -31,22 +31,45 @@ import androidx.compose.ui.unit.dp
import androidx.core.view.WindowCompat
import androidx.navigation.NavHostController
import androidx.navigation.compose.currentBackStackEntryAsState
import com.aiosman.riderpro.data.TestUserServiceImpl
import com.aiosman.riderpro.data.UserService
import com.aiosman.riderpro.ui.Navigation
import com.aiosman.riderpro.ui.NavigationRoute
import com.aiosman.riderpro.ui.index.NavigationItem
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.google.android.libraries.places.api.Places
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class MainActivity : ComponentActivity() {
private val scope = CoroutineScope(Dispatchers.Main)
suspend fun getAccount() {
//TODO apply token to client
if (!AppStore.rememberMe) {
return
}
val userService: UserService = TestUserServiceImpl()
userService.getMyAccount()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
if (!Places.isInitialized()) {
Places.initialize(applicationContext, "AIzaSyDpgLDH1-SECw_pdjJq_msynq1XrxwgKVI")
}
AppStore.init(this)
enableEdgeToEdge()
setContent {
Navigation()
scope.launch {
getAccount()
var startDestination = NavigationRoute.Login.route
if (AppStore.token != null && AppStore.rememberMe) {
startDestination = NavigationRoute.Index.route
}
setContent {
Navigation(startDestination)
}
}
}
}