Skip to content

Commit 9ddeaeb

Browse files
committed
Basic theming
1 parent f38c652 commit 9ddeaeb

File tree

14 files changed

+195
-73
lines changed

14 files changed

+195
-73
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
android:icon="@mipmap/ic_launcher"
3030
android:label="@string/app_name"
3131
android:supportsRtl="true"
32-
android:theme="@style/Theme.AndroidDevChallenge">
32+
android:theme="@style/Theme.MySoothe">
3333
<activity
3434
android:name="net.opatry.speedrun.emea.MainActivity"
3535
android:label="@string/app_name"
36-
android:theme="@style/Theme.AndroidDevChallenge.NoActionBar">
36+
android:theme="@style/Theme.MySoothe.NoActionBar">
3737
<intent-filter>
3838
<action android:name="android.intent.action.MAIN" />
3939

app/src/main/java/net/opatry/speedrun/emea/MainActivity.kt

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,45 +23,121 @@ package net.opatry.speedrun.emea
2323

2424
import android.os.Bundle
2525
import androidx.activity.compose.setContent
26+
import androidx.annotation.StringRes
2627
import androidx.appcompat.app.AppCompatActivity
28+
import androidx.compose.foundation.layout.Column
29+
import androidx.compose.foundation.layout.padding
30+
import androidx.compose.material.BottomNavigation
31+
import androidx.compose.material.BottomNavigationItem
32+
import androidx.compose.material.Card
33+
import androidx.compose.material.ContentAlpha
34+
import androidx.compose.material.Icon
35+
import androidx.compose.material.LocalContentColor
2736
import androidx.compose.material.MaterialTheme
37+
import androidx.compose.material.Scaffold
2838
import androidx.compose.material.Surface
2939
import androidx.compose.material.Text
40+
import androidx.compose.material.icons.Icons
41+
import androidx.compose.material.icons.filled.AccountCircle
42+
import androidx.compose.material.icons.filled.PlayArrow
43+
import androidx.compose.material.icons.filled.Search
44+
import androidx.compose.material.icons.filled.Spa
3045
import androidx.compose.runtime.Composable
46+
import androidx.compose.runtime.mutableStateOf
47+
import androidx.compose.runtime.remember
48+
import androidx.compose.ui.Modifier
49+
import androidx.compose.ui.graphics.vector.ImageVector
50+
import androidx.compose.ui.res.stringResource
3151
import androidx.compose.ui.tooling.preview.Preview
52+
import androidx.compose.ui.unit.dp
3253
import net.opatry.speedrun.emea.ui.theme.MyTheme
3354

3455
class MainActivity : AppCompatActivity() {
3556
override fun onCreate(savedInstanceState: Bundle?) {
3657
super.onCreate(savedInstanceState)
3758
setContent {
3859
MyTheme {
39-
MyApp()
60+
MySootheApp()
4061
}
4162
}
4263
}
4364
}
4465

45-
// Start building your app here!
66+
private enum class MainTabs(
67+
@StringRes val titleRes: Int,
68+
val icon: ImageVector
69+
) {
70+
Home(R.string.nav_home, Icons.Default.Spa),
71+
// FIXME FAB
72+
Run(R.string.nav_run, Icons.Default.PlayArrow),
73+
Profile(R.string.nav_profile, Icons.Default.AccountCircle)
74+
}
75+
76+
@Composable
77+
fun MySootheApp(signedIn: Boolean = true) {
78+
if (!signedIn) {
79+
LoginScreen()
80+
} else {
81+
MainScreen()
82+
}
83+
}
84+
85+
@Composable
86+
fun LoginScreen() {
87+
Text("TODO LOGIN")
88+
}
89+
4690
@Composable
47-
fun MyApp() {
91+
fun MainScreen() {
92+
93+
val (selectedTab, setSelectedTab) = remember { mutableStateOf(MainTabs.Home) }
94+
val tabs = MainTabs.values()
95+
4896
Surface(color = MaterialTheme.colors.background) {
49-
Text(text = "Ready... Set... GO!")
97+
Scaffold(
98+
topBar = {},
99+
bottomBar = {
100+
BottomNavigation(
101+
backgroundColor = MaterialTheme.colors.background,
102+
elevation = 8.dp
103+
) {
104+
tabs.forEach { navItem ->
105+
BottomNavigationItem(
106+
icon = { Icon(navItem.icon, null) },
107+
label = { Text(stringResource(navItem.titleRes)) },
108+
selected = selectedTab == navItem,
109+
selectedContentColor = MaterialTheme.colors.onBackground,
110+
unselectedContentColor = MaterialTheme.colors.onBackground.copy(alpha = ContentAlpha.medium),
111+
onClick = { setSelectedTab(navItem) }
112+
)
113+
}
114+
}
115+
}
116+
) {
117+
Card(Modifier.padding(24.dp)) {
118+
Column {
119+
Icon(Icons.Default.Search, null)
120+
Icon(Icons.Default.Spa, null)
121+
Icon(Icons.Default.AccountCircle, null)
122+
Icon(Icons.Default.PlayArrow, null)
123+
}
124+
}
125+
}
50126
}
51127
}
52128

53129
@Preview("Light Theme", widthDp = 360, heightDp = 640)
54130
@Composable
55131
fun LightPreview() {
56132
MyTheme {
57-
MyApp()
133+
MySootheApp()
58134
}
59135
}
60136

61137
@Preview("Dark Theme", widthDp = 360, heightDp = 640)
62138
@Composable
63139
fun DarkPreview() {
64140
MyTheme(darkTheme = true) {
65-
MyApp()
141+
MySootheApp()
66142
}
67143
}

app/src/main/java/net/opatry/speedrun/emea/ui/theme/Color.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ package net.opatry.speedrun.emea.ui.theme
2323

2424
import androidx.compose.ui.graphics.Color
2525

26-
val purple200 = Color(0xFFBB86FC)
27-
val purple500 = Color(0xFF6200EE)
28-
val purple700 = Color(0xFF3700B3)
29-
val teal200 = Color(0xFF03DAC5)
26+
val Gray900 = Color(0xFF333333)
27+
val Gray800 = Gray900.copy(alpha = .8f)
28+
val Rust600 = Color(0xFF886363)
29+
val Rust300 = Color(0xFFE1AFAF)
30+
val Taupe100 = Color(0xFFF0EAE2)
31+
val Taupe800 = Color(0xFF655454)
32+
val White150 = Color.White.copy(alpha = .15f)
33+
val White800 = Color.White.copy(alpha = .8f)
34+
val White850 = Color.White.copy(alpha = .85f)
35+

app/src/main/java/net/opatry/speedrun/emea/ui/theme/Shape.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ import androidx.compose.ui.unit.dp
2727

2828
val shapes = Shapes(
2929
small = RoundedCornerShape(4.dp),
30-
medium = RoundedCornerShape(4.dp),
30+
medium = RoundedCornerShape(16.dp),
3131
large = RoundedCornerShape(0.dp)
3232
)

app/src/main/java/net/opatry/speedrun/emea/ui/theme/Theme.kt

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,28 @@ import androidx.compose.material.MaterialTheme
2626
import androidx.compose.material.darkColors
2727
import androidx.compose.material.lightColors
2828
import androidx.compose.runtime.Composable
29+
import androidx.compose.ui.graphics.Color
2930

3031
private val DarkColorPalette = darkColors(
31-
primary = purple200,
32-
primaryVariant = purple700,
33-
secondary = teal200
32+
primary = Color.White,
33+
secondary = Rust300,
34+
background = Gray900,
35+
surface = White150,
36+
onPrimary = Color.White,
37+
onSecondary = Color.Black,
38+
onBackground = Taupe100,
39+
onSurface = White800,
3440
)
3541

3642
private val LightColorPalette = lightColors(
37-
primary = purple500,
38-
primaryVariant = purple700,
39-
secondary = teal200
40-
41-
/* Other default colors to override
42-
background = Color.White,
43-
surface = Color.White,
43+
primary = Gray900,
44+
secondary = Rust600,
45+
background = Taupe100,
46+
surface = White850,
4447
onPrimary = Color.White,
45-
onSecondary = Color.Black,
46-
onBackground = Color.Black,
47-
onSurface = Color.Black,
48-
*/
48+
onSecondary = Color.White,
49+
onBackground = Taupe800,
50+
onSurface = Gray800,
4951
)
5052

5153
@Composable

app/src/main/java/net/opatry/speedrun/emea/ui/theme/Type.kt

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,61 @@ package net.opatry.speedrun.emea.ui.theme
2323

2424
import androidx.compose.material.Typography
2525
import androidx.compose.ui.text.TextStyle
26+
import androidx.compose.ui.text.font.Font
2627
import androidx.compose.ui.text.font.FontFamily
2728
import androidx.compose.ui.text.font.FontWeight
2829
import androidx.compose.ui.unit.sp
30+
import net.opatry.speedrun.emea.R
31+
32+
val KulimPark = FontFamily(
33+
Font(R.font.kulimpark_regular),
34+
Font(R.font.kulimpark_light, FontWeight.Light)
35+
)
36+
37+
val Lato = FontFamily(
38+
Font(R.font.lato_regular),
39+
Font(R.font.lato_bold, FontWeight.Bold)
40+
)
2941

3042
// Set of Material typography styles to start with
3143
val typography = Typography(
44+
h1 = TextStyle(
45+
fontFamily = KulimPark,
46+
fontWeight = FontWeight.Light,
47+
fontSize = 28.sp,
48+
letterSpacing = 1.15.sp,
49+
),
50+
h2 = TextStyle(
51+
fontFamily = Lato,
52+
fontWeight = FontWeight.Bold,
53+
fontSize = 15.sp,
54+
letterSpacing = 1.15.sp,
55+
// TODO CAPS ??
56+
),
57+
h3 = TextStyle(
58+
fontFamily = Lato,
59+
fontWeight = FontWeight.Bold,
60+
fontSize = 14.sp,
61+
letterSpacing = 0.sp,
62+
),
3263
body1 = TextStyle(
33-
fontFamily = FontFamily.Default,
64+
fontFamily = Lato,
3465
fontWeight = FontWeight.Normal,
35-
fontSize = 16.sp
36-
)
37-
/* Other default text styles to override
66+
fontSize = 14.sp,
67+
letterSpacing = 0.sp,
68+
),
3869
button = TextStyle(
39-
fontFamily = FontFamily.Default,
40-
fontWeight = FontWeight.W500,
41-
fontSize = 14.sp
70+
fontFamily = Lato,
71+
fontWeight = FontWeight.Bold,
72+
fontSize = 14.sp,
73+
letterSpacing = 1.15.sp,
74+
// TODO CAPS ??
4275
),
4376
caption = TextStyle(
4477
fontFamily = FontFamily.Default,
4578
fontWeight = FontWeight.Normal,
46-
fontSize = 12.sp
79+
fontSize = 12.sp,
80+
letterSpacing = 1.15.sp,
81+
// TODO CAPS ??
4782
)
48-
*/
4983
)
57.6 KB
Binary file not shown.
58.2 KB
Binary file not shown.
71.6 KB
Binary file not shown.
73.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)