Skip to content

UI refactor #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ dependencies {
implementation(libs.coil.compose)
implementation(libs.coil.network)
implementation(libs.bytebeats.charts)
implementation(libs.androidx.splashscreen)
kapt(libs.room.compiler)

testImplementation(libs.junit)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.LeetcodePlus"
android:theme="@style/Theme.App.Starting"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.LeetcodePlus">
android:theme="@style/Theme.App.Starting">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.byteutility.dev.leetcode.plus
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.lifecycle.lifecycleScope
import androidx.navigation.compose.rememberNavController
import com.byteutility.dev.leetcode.plus.data.datastore.UserDatastore
Expand All @@ -22,6 +23,7 @@ class MainActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
lifecycleScope.launch {
val userLoggedIn =
userDatastore.getUserBasicInfo().first()?.userName?.isNotEmpty() == true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.byteutility.dev.leetcode.plus.ui.login

import android.util.Log
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand All @@ -9,8 +8,9 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -20,22 +20,19 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import com.byteutility.dev.leetcode.plus.R

private const val TAG = "UserLoginScreen"
@Composable
fun UserLoginScreen(
viewModel: UserLoginViewModel = hiltViewModel(),
onProceedClick: () -> Unit = {}
) {
LeetCodeUsernameScreen {
Log.e(TAG, "UserLoginScreen: $it", )
viewModel.saveUserName(it)
onProceedClick()
}
Expand All @@ -56,31 +53,30 @@ fun LeetCodeUsernameScreen(
Image(
painter = painterResource(id = R.drawable.leetcode_logo),
contentDescription = "App Logo",
modifier = Modifier.size(100.dp)
contentScale = ContentScale.FillWidth,
modifier = Modifier
.fillMaxWidth()
.padding(start = 32.dp, end = 32.dp)
)
Spacer(modifier = Modifier.height(16.dp))
Text(
text = "LeetCode Plus",
fontWeight = FontWeight.Bold,
fontSize = 32.sp
)

Spacer(modifier = Modifier.height(16.dp))

var username by remember { mutableStateOf("") }

OutlinedTextField(
value = username,
onValueChange = { username = it },
modifier = Modifier.fillMaxWidth(),
singleLine = true
)

Spacer(modifier = Modifier.height(16.dp))
Spacer(modifier = Modifier.height(32.dp))

Button(onClick = {
onProceedClick(username)
}) {
Button(
onClick = {
onProceedClick(username)
},
shape = RoundedCornerShape(32.dp),
elevation = ButtonDefaults.elevatedButtonElevation(defaultElevation = 6.dp)
) {
Text(text = "Proceed")
}
}
Expand Down
Binary file modified app/src/main/res/drawable/leetcode_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
<resources>

<style name="Theme.LeetcodePlus" parent="android:Theme.Material.Light.NoActionBar" />

<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<item name="postSplashScreenTheme">@style/Theme.LeetcodePlus</item>
</style>
</resources>
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ hilt-work = "1.0.0"
androidxDatastore = "1.1.0"
coil = "3.0.0-rc01"
bytebeats-charts = "0.2.1"
androidx-splashscreen = "1.0.0"

[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
Expand Down Expand Up @@ -58,7 +59,7 @@ androidx-datastore = { group = "androidx.datastore", name = "datastore-preferenc
coil-compose = { group = "io.coil-kt.coil3", name = "coil-compose", version.ref = "coil" }
coil-network = { group = "io.coil-kt.coil3", name = "coil-network-okhttp", version.ref = "coil" }
bytebeats-charts = { group = "io.github.bytebeats", name = "compose-charts", version.ref = "bytebeats-charts" }

androidx-splashscreen = { group = "androidx.core", name = "core-splashscreen", version.ref = "androidx-splashscreen" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
Expand Down