Skip to content

Commit

Permalink
feat: implement HomeScreen Loading & Failure components
Browse files Browse the repository at this point in the history
  • Loading branch information
yjyoon-dev committed Dec 9, 2022
1 parent 38b77de commit 792bbbc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 15 additions & 2 deletions app/src/main/java/com/neurosky/zonetrainer/ui/home/HomeScreen.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.neurosky.zonetrainer.ui.home

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
Expand All @@ -20,6 +21,7 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Headset
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FabPosition
import androidx.compose.material3.Icon
Expand All @@ -31,6 +33,7 @@ import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.shadow
Expand Down Expand Up @@ -70,11 +73,21 @@ fun HomeScreen(
) {
when (uiState) {
HomeUiState.Loading -> {
//TODO: Loading Component
Box(
modifier = Modifier.fillMaxSize()
) {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
}
}

HomeUiState.Failure -> {
//TODO: Failure Component
Box(
modifier = Modifier.fillMaxSize()
) {
Text(text = stringResource(id = R.string.fail_to_load))
}
}

is HomeUiState.Success -> {
HomeContent(
account = account,
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@
<string name="video_saved">Saved at %s</string>

<string name="sign_in_with_google">Sign in with Google</string>

<string name="fail_to_load">"Fail to load data. Please check your network status."</string>
</resources>

0 comments on commit 792bbbc

Please sign in to comment.