Skip to content

Commit

Permalink
feat: Menu (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
OdisBy authored Nov 12, 2024
2 parents 6c0bcd5 + 56ad8e0 commit 95c2315
Show file tree
Hide file tree
Showing 40 changed files with 967 additions and 64 deletions.
23 changes: 23 additions & 0 deletions app/src/main/java/com/loryblu/loryblu/navigation/NavGraph.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.loryblu.loryblu.navigation

import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import com.loryblu.core.util.Screen
Expand All @@ -11,10 +12,12 @@ import com.loryblu.feature.auth.register.navigation.registerChildRoute
import com.loryblu.feature.auth.register.navigation.registerGuardianRoute
import com.loryblu.feature.auth.register.navigation.registrationConfirmedRoute
import com.loryblu.feature.logbook.navigation.logbookNavigation
import com.loryblu.loryblu.R
import com.odisby.feature.dashboard.navigation.dashboardRoute

@Composable
fun SetupNavGraph(startDestination: String, navController: NavHostController) {
val context = LocalContext.current
NavHost(
startDestination = startDestination,
navController = navController
Expand Down Expand Up @@ -64,6 +67,26 @@ fun SetupNavGraph(startDestination: String, navController: NavHostController) {
dashboardRoute(
navigateToLogbook = {
navController.navigate(Screen.Logbook.route)
},
navigateToLogin = {
navController.popBackStack()
navController.navigate(Screen.Login.route)
},
navigateToFaq = {
navController.navigate(
Screen.WebViewScreen.editRoute(
url = " https://drive.google.com/file/d/1AZMx5-b1mLGPs041Zok6X2blpjIkZ2vs/view",
title = context.getString(R.string.faq_title),
)
)
},
navigateToTerms = {
navController.navigate(
Screen.WebViewScreen.editRoute(
url = "https://drive.google.com/file/d/1A1WIDpEiSVI9Ep5oA9YMSA-JWC2O8q4M/view",
title = context.getString(R.string.terms_title),
)
)
}
)
logbookNavigation(
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="faq_title">Frequently Asked Questions</string>
<string name="terms_title">Privacy Policy</string>
</resources>
5 changes: 5 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="faq_title" translatable="false">Perguntas Frequentes</string>
<string name="terms_title" translatable="false">Termo e Privacidade</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class UserSession(

private var childIdCache: Int = 0
private var childNameCache: String = ""
private var parentNameCache: String = ""

suspend fun saveToken(loginToken: String) {
dataStore.edit {
Expand All @@ -37,15 +38,20 @@ class UserSession(
}
}

fun saveChild(childId: Int, childName: String) {
fun saveChild(childId: Int, childName: String, parentName: String) {
childIdCache = childId
childNameCache = childName
parentNameCache = parentName
}

fun getChildName(): String {
return childNameCache
}

fun getParentName(): String {
return parentNameCache
}

fun getToken(): String {
var response: String
runBlocking {
Expand All @@ -58,4 +64,4 @@ class UserSession(
fun getChildId(): Int {
return childIdCache
}
}
}
28 changes: 20 additions & 8 deletions core/ui/src/main/java/com/loryblu/core/ui/components/LBCard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.loryblu.core.ui.components.extensions.loryShadow
import com.loryblu.core.ui.theme.LBAfternoonBlue
import com.loryblu.core.ui.theme.LBBottomDisabledColor
import com.loryblu.core.ui.theme.LBBottomHome
Expand Down Expand Up @@ -63,14 +64,25 @@ fun LBCardDashboard(
colors = CardDefaults.cardColors(
containerColor = contentColor,
),
border = BorderStroke(4.dp, borderColor),
border = if(card.isDisabled) {
CardDefaults.outlinedCardBorder()
} else {
BorderStroke(4.dp, borderColor)
},
modifier = modifier
.clickable {
if (!card.isDisabled) {
onclick()
}
}
.alpha(saturation),
}.then(if (card.isDisabled.not()) {
Modifier.loryShadow(
offsetX = 1.dp,
offsetY = 5.dp,
cornerRadius = 8.dp,
)
} else {
Modifier
}).alpha(saturation),
shape = RoundedCornerShape(rounded),
) {
Column(
Expand Down Expand Up @@ -102,7 +114,7 @@ fun LBCardDashboard(
Text(
text = stringResource(id = card.text),
style = TextStyle(
fontSize = 20.sp,
fontSize = 26.sp,
lineHeight = 24.sp,
fontWeight = FontWeight(500),
color = Color.White,
Expand Down Expand Up @@ -169,7 +181,7 @@ fun LBCategoryCard(
Text(
text = stringResource(id = card.text),
style = TextStyle(
fontSize = 20.sp,
fontSize = 26.sp,
lineHeight = 24.sp,
fontWeight = FontWeight(500),
color = Color.White,
Expand Down Expand Up @@ -385,7 +397,7 @@ fun LBCardShift(
fun LBDashboardCardPreview() {
LoryBluTheme {
LBCardDashboard(
getAllDashboardItems()[0],
getAllDashboardItems().first(),
modifier = Modifier.size(250.dp),
onclick = {}
)
Expand All @@ -397,7 +409,7 @@ fun LBDashboardCardPreview() {
fun LBLogbookCardPreview() {
LoryBluTheme {
LBCategoryCard(
CategoryItem.getAllCategory()[0],
CategoryItem.getAllCategory().first(),
modifier = Modifier.size(250.dp),
selected = true,
onclick = {}
Expand All @@ -410,7 +422,7 @@ fun LBLogbookCardPreview() {
fun LBShiftCardPreview() {
LoryBluTheme {
LBCardShift(
ShiftItem.getShiftItems()[0],
ShiftItem.getShiftItems().first(),
modifier = Modifier.size(250.dp),
clicked = false,
onclick = {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.loryblu.core.ui.components

import androidx.annotation.StringRes
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.loryblu.core.ui.R
import com.loryblu.core.ui.theme.LBErrorColor

@Composable
fun LBNegativeDialogButton(
@StringRes textRes: Int,
modifier: Modifier = Modifier,
onClick: () -> Unit,
) {
OutlinedButton(
onClick = onClick,
colors = ButtonDefaults.buttonColors(
contentColor = LBErrorColor,
containerColor = Color.Transparent
),
shape = RoundedCornerShape(8.dp),
border = BorderStroke(
width = 1.dp,
color = LBErrorColor
),
modifier = modifier.size(96.dp, 35.dp)
) {
Text(text = stringResource(id = textRes), fontSize = 17.sp)
}
}

@Preview
@Composable
fun LBNegativeDialogButtonPreview() {
LBNegativeDialogButton(
textRes = R.string.cancel,
onClick = { }
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.loryblu.core.ui.components

import androidx.annotation.StringRes
import androidx.compose.foundation.layout.size
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@Composable
fun LBTransparentButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
@StringRes textRes: Int
) {
TextButton(
onClick = onClick,
colors = ButtonDefaults.buttonColors(
contentColor = MaterialTheme.colorScheme.onSurface,
containerColor = Color.Transparent
),
modifier = modifier.size(96.dp, 35.dp)
) {
Text(text = stringResource(id = textRes), fontSize = 17.sp)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.loryblu.core.ui.components.extensions

import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.geometry.CornerRadius
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

fun Modifier.loryShadow(
offsetX: Dp = 0.dp,
offsetY: Dp = 0.dp,
shadowColor: Color = Color.Black.copy(alpha = 0.2f),
cornerRadius: Dp = 0.dp,
alpha: Float = 0.7f,
): Modifier {
return this.drawBehind {
drawRoundRect(
color = shadowColor,
topLeft = Offset(x = offsetX.toPx(), y = offsetY.toPx()),
size = size,
cornerRadius = CornerRadius(cornerRadius.toPx(), cornerRadius.toPx()),
alpha = alpha,
)
}
}
1 change: 1 addition & 0 deletions core/ui/src/main/java/com/loryblu/core/ui/theme/Color.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ val LBShadowGray = Color(0xff0F1326)
val LBMediumGray = Color(0xff616161)
val LBSmokeGray = Color(0xff49454F)
val LBErrorColor = Color(0xffD62C2C)
val LBLightPink = Color(0xffffD3D3)
val LBLoadingBackground = Color(0xA6808080)

// Card Colors
Expand Down
7 changes: 7 additions & 0 deletions core/ui/src/main/java/com/loryblu/core/ui/theme/Type.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package com.loryblu.core.ui.theme

import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
import com.loryblu.core.ui.R

// Set of Material typography styles to start with
val Typography = Typography(
Expand All @@ -31,4 +33,9 @@ val Typography = Typography(
letterSpacing = 0.5.sp
)
*/
)

val inter = FontFamily(
Font(R.font.inter_regular, weight = FontWeight.Normal),
Font(R.font.inter_bold, weight = FontWeight.Bold),
)
Binary file added core/ui/src/main/res/font/inter_bold.ttf
Binary file not shown.
Binary file added core/ui/src/main/res/font/inter_regular.ttf
Binary file not shown.
6 changes: 6 additions & 0 deletions core/util/src/main/java/com/loryblu/core/util/Screen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@ sealed class Screen(val route: String) {
data object EditTaskSummaryScreen: Screen(route = "edit_task_summary_screen/{TASK_ID}") {
fun editRoute(taskId: Int) = "edit_task_summary_screen/$taskId"
}

// WebView
data object WebViewScreen: Screen(route = "web_view_screen?url={URL}&title={TITLE}") {
fun editRoute(url: String, title: String) = "web_view_screen?url=$url&title=$title"
}

data object EditionConfirmedScreen: Screen(route = "edition_confirmed_screen")
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ internal class LoginApiImpl(

private fun handleErrorResponse(httpStatusCode: HttpStatusCode): SignInResult {
println("Error: ${httpStatusCode.description}")
return SignInResult.Error("Estamos com alguns problemas. Tente novamente mais tarde!")
// TODO: pass it to a string resources
return SignInResult.Error("Servidor indisponível. Tente novamente mais tarde.")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,18 @@ class GameTrack: DashboardItem(
isDisabled = true
)

class MusicTrack: DashboardItem(
idCard = 3,
text = R.string.music_track,
drawable = R.drawable.music_track,
isDisabled = true
)

fun getAllDashboardItems(): List<DashboardItem>{
return listOf(
Logbook(),
StoryTrack(),
GameTrack()
GameTrack(),
MusicTrack(),
)
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/dashboard/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<string name="logbook">Diário de bordo</string>
<string name="game_track">Trilha de jogos</string>
<string name="story_track">Trilha de histórias</string>
<string name="music_track">Trilha de música</string>
<string name="logout">SAIR</string>
<string name="welcome">Bem-Vindo</string>
</resources>
1 change: 1 addition & 0 deletions data/dashboard/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<string name="logbook">Logbook</string>
<string name="game_track">Game track</string>
<string name="story_track">Story track</string>
<string name="music_track">Music track</string>
<string name="logout">LOGOUT</string>
<string name="welcome">Welcome</string>
</resources>
Binary file modified data/logbook/src/main/res/drawable/logbook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fun LoginScreen(
var passwordState by rememberSaveable { mutableStateOf<PasswordInputValid>(PasswordInputValid.Empty) }
var emailState by rememberSaveable { mutableStateOf<EmailInputValid>(EmailInputValid.Empty) }
var showApiErrors by remember { mutableStateOf(false) }
var apiErrorMessage by rememberSaveable { mutableStateOf<String>("") }
var apiErrorMessage by rememberSaveable { mutableStateOf("") }
var rememberButtonChecked by rememberSaveable { mutableStateOf(false) }

val showEmailApiError by remember { mutableStateOf(false) }
Expand Down
Loading

0 comments on commit 95c2315

Please sign in to comment.