Skip to content
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: 0 additions & 1 deletion JetLagged/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ dependencies {
implementation(libs.androidx.compose.ui.util)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.animation)
implementation(libs.androidx.compose.material.iconsExtended)
implementation(libs.androidx.compose.materialWindow)
implementation(libs.androidx.compose.ui.googlefonts)
implementation(libs.androidx.compose.ui.tooling.preview)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.example.jetlagged

import androidx.annotation.DrawableRes
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand All @@ -39,9 +40,6 @@ import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.SingleBed
import androidx.compose.material.icons.filled.Watch
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Icon
Expand All @@ -54,7 +52,7 @@ import androidx.compose.ui.Alignment.Companion.CenterVertically
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -86,7 +84,13 @@ fun BasicInformationalCard(modifier: Modifier = Modifier, borderColor: Color, co
}

@Composable
fun TwoLineInfoCard(borderColor: Color, firstLineText: String, secondLineText: String, icon: ImageVector, modifier: Modifier = Modifier) {
fun TwoLineInfoCard(
borderColor: Color,
firstLineText: String,
secondLineText: String,
@DrawableRes icon: Int,
modifier: Modifier = Modifier,
) {
BasicInformationalCard(
borderColor = borderColor,
modifier = modifier.size(200.dp),
Expand All @@ -107,7 +111,7 @@ fun TwoLineInfoCard(borderColor: Color, firstLineText: String, secondLineText: S
.align(CenterStart),
) {
Icon(
icon, contentDescription = null,
painter = painterResource(id = icon), contentDescription = null,
modifier = Modifier
.size(50.dp)
.align(CenterVertically),
Expand Down Expand Up @@ -135,7 +139,7 @@ fun TwoLineInfoCard(borderColor: Color, firstLineText: String, secondLineText: S
.align(Center),
) {
Icon(
icon, contentDescription = null,
painter = painterResource(id = icon), contentDescription = null,
modifier = Modifier
.size(50.dp)
.align(CenterHorizontally),
Expand Down Expand Up @@ -167,7 +171,7 @@ fun AverageTimeInBedCard(modifier: Modifier = Modifier) {
borderColor = JetLaggedTheme.extraColors.bed,
firstLineText = stringResource(R.string.ave_time_in_bed_heading),
secondLineText = "8h42min",
icon = Icons.Default.Watch,
icon = R.drawable.ic_watch,
modifier = modifier
.wrapContentWidth()
.heightIn(min = 156.dp),
Expand All @@ -182,7 +186,7 @@ fun AverageTimeAsleepCard(modifier: Modifier = Modifier) {
borderColor = JetLaggedTheme.extraColors.sleep,
firstLineText = stringResource(R.string.ave_time_sleep_heading),
secondLineText = "7h42min",
icon = Icons.Default.SingleBed,
icon = R.drawable.ic_single_bed,
modifier = modifier
.wrapContentWidth()
.heightIn(min = 156.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.example.jetlagged

import android.os.SystemClock
import androidx.activity.compose.PredictiveBackHandler
import androidx.annotation.DrawableRes
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.calculateTargetValue
import androidx.compose.animation.rememberSplineBasedDecay
Expand All @@ -30,11 +31,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Bedtime
import androidx.compose.material.icons.filled.Home
import androidx.compose.material.icons.filled.Leaderboard
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material3.Icon
import androidx.compose.material3.NavigationDrawerItem
import androidx.compose.material3.Surface
Expand All @@ -50,9 +46,9 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.pointer.util.VelocityTracker
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.lerp
import kotlin.coroutines.cancellation.CancellationException
Expand Down Expand Up @@ -113,7 +109,7 @@ fun HomeScreenDrawer(windowSizeClass: WindowSizeClass) {
)
}
closeDrawer(velocityTracker.calculateVelocity().x)
} catch (e: CancellationException) {
} catch (_: CancellationException) {
openDrawer(velocityTracker.calculateVelocity().x)
}
velocityTracker.resetTracking()
Expand Down Expand Up @@ -251,7 +247,7 @@ private fun HomeScreenDrawerContents(selectedScreen: Screen, onScreenSelected: (
Text(it.text)
},
icon = {
Icon(imageVector = it.icon, contentDescription = it.text)
Icon(painter = painterResource(id = it.icon), contentDescription = it.text)
},
selected = selectedScreen == it,
onClick = {
Expand All @@ -264,9 +260,9 @@ private fun HomeScreenDrawerContents(selectedScreen: Screen, onScreenSelected: (

private val DrawerWidth = 300.dp

private enum class Screen(val text: String, val icon: ImageVector) {
Home("Home", Icons.Default.Home),
SleepDetails("Sleep", Icons.Default.Bedtime),
Leaderboard("Leaderboard", Icons.Default.Leaderboard),
Settings("Settings", Icons.Default.Settings),
private enum class Screen(val text: String, @DrawableRes val icon: Int) {
Home("Home", R.drawable.ic_home),
SleepDetails("Sleep", R.drawable.ic_bedtime),
Leaderboard("Leaderboard", R.drawable.ic_leaderboard),
Settings("Settings", R.drawable.ic_settings),
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
Expand All @@ -40,7 +39,7 @@ import com.example.jetlagged.ui.theme.TitleBarStyle

@Preview
@Composable
fun JetLaggedHeader(onDrawerClicked: () -> Unit = {}, modifier: Modifier = Modifier) {
fun JetLaggedHeader(modifier: Modifier = Modifier, onDrawerClicked: () -> Unit = {}) {
Box(
modifier.height(150.dp),
) {
Expand All @@ -49,7 +48,7 @@ fun JetLaggedHeader(onDrawerClicked: () -> Unit = {}, modifier: Modifier = Modif
onClick = onDrawerClicked,
) {
Icon(
Icons.Default.Menu,
painter = painterResource(id = R.drawable.ic_menu),
contentDescription = stringResource(R.string.not_implemented),
)
}
Expand Down
9 changes: 9 additions & 0 deletions JetLagged/app/src/main/res/drawable/ic_bedtime.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M484,880Q400,880 326.5,848Q253,816 198.5,761.5Q144,707 112,633.5Q80,560 80,476Q80,330 173,218.5Q266,107 410,80Q392,179 421,273.5Q450,368 521,439Q592,510 686.5,539Q781,568 880,550Q854,694 742,787Q630,880 484,880Z"/>
</vector>
9 changes: 9 additions & 0 deletions JetLagged/app/src/main/res/drawable/ic_home.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M160,840L160,360L480,120L800,360L800,840L560,840L560,560L400,560L400,840L160,840Z"/>
</vector>
9 changes: 9 additions & 0 deletions JetLagged/app/src/main/res/drawable/ic_leaderboard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M80,840L80,360L300,360L300,840L80,840ZM370,840L370,120L590,120L590,840L370,840ZM660,840L660,440L880,440L880,840L660,840Z"/>
</vector>
9 changes: 9 additions & 0 deletions JetLagged/app/src/main/res/drawable/ic_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M120,720L120,640L840,640L840,720L120,720ZM120,520L120,440L840,440L840,520L120,520ZM120,320L120,240L840,240L840,320L120,320Z"/>
</vector>
9 changes: 9 additions & 0 deletions JetLagged/app/src/main/res/drawable/ic_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M370,880L354,752Q341,747 329.5,740Q318,733 307,725L188,775L78,585L181,507Q180,500 180,493.5Q180,487 180,480Q180,473 180,466.5Q180,460 181,453L78,375L188,185L307,235Q318,227 330,220Q342,213 354,208L370,80L590,80L606,208Q619,213 630.5,220Q642,227 653,235L772,185L882,375L779,453Q780,460 780,466.5Q780,473 780,480Q780,487 780,493.5Q780,500 778,507L881,585L771,775L653,725Q642,733 630,740Q618,747 606,752L590,880L370,880ZM482,620Q540,620 581,579Q622,538 622,480Q622,422 581,381Q540,340 482,340Q423,340 382.5,381Q342,422 342,480Q342,538 382.5,579Q423,620 482,620Z"/>
</vector>
9 changes: 9 additions & 0 deletions JetLagged/app/src/main/res/drawable/ic_single_bed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M280,760L240,760L214,680L160,680L160,479Q160,446 183.5,423Q207,400 240,400L240,400L240,280Q240,247 263.5,223.5Q287,200 320,200L640,200Q673,200 696.5,223.5Q720,247 720,280L720,400L720,400Q753,400 776.5,423.5Q800,447 800,480L800,680L746,680L720,760L680,760L654,680L306,680L280,760ZM520,400L640,400L640,280Q640,280 640,280Q640,280 640,280L520,280L520,400ZM320,400L440,400L440,280L320,280Q320,280 320,280Q320,280 320,280L320,400Z"/>
</vector>
9 changes: 9 additions & 0 deletions JetLagged/app/src/main/res/drawable/ic_watch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M360,880L306,698Q258,660 229,603Q200,546 200,480Q200,414 229,357Q258,300 306,262L360,80L600,80L654,262Q702,300 731,357Q760,414 760,480Q760,546 731,603Q702,660 654,698L600,880L360,880ZM480,680Q563,680 621.5,621.5Q680,563 680,480Q680,397 621.5,338.5Q563,280 480,280Q397,280 338.5,338.5Q280,397 280,480Q280,563 338.5,621.5Q397,680 480,680Z"/>
</vector>