Skip to content

Commit

Permalink
Initial Bavaria Classic theme
Browse files Browse the repository at this point in the history
  • Loading branch information
hufman committed Mar 15, 2024
1 parent 4ca29ea commit 90cbd4c
Show file tree
Hide file tree
Showing 31 changed files with 640 additions and 110 deletions.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ kotlin {
@OptIn(ExperimentalComposeLibrary::class)
implementation(compose.components.resources)

// api(libs.moko.compose)
implementation(libs.kotlinx.datetime)
implementation(libs.voyager.navigator)
implementation(libs.voyager.screenModel)
Expand Down
34 changes: 16 additions & 18 deletions app/src/androidMain/java/io/bimmergestalt/headunit/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.activity.compose.setContent
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
Expand All @@ -24,6 +25,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import cafe.adriel.voyager.navigator.Navigator
Expand All @@ -32,8 +34,13 @@ import io.bimmergestalt.headunit.bcl.ServerService
import io.bimmergestalt.headunit.models.RHMIAppsModel
import io.bimmergestalt.headunit.models.ThemeSettings
import io.bimmergestalt.headunit.screens.HeadunitScreen
import io.bimmergestalt.headunit.screens.HomeScreen
import io.bimmergestalt.headunit.ui.components.Background
import io.bimmergestalt.headunit.ui.components.StaticTopBar
import io.bimmergestalt.headunit.ui.components.TopBar
import io.bimmergestalt.headunit.ui.screens.AppListScreen
import io.bimmergestalt.headunit.ui.screens.RHMIScreen
import io.bimmergestalt.headunit.ui.theme.Appearance
import io.bimmergestalt.headunit.ui.theme.HeadunitktAndroidTheme
import io.bimmergestalt.headunit.ui.theme.Theme
import io.bimmergestalt.headunit.utils.LaunchedEffectAndCollect
Expand Down Expand Up @@ -74,30 +81,21 @@ fun Contents() {
color = background
) {
// Greeting("Android")
Navigator(AppListScreen) { navigator ->
val homeScreen = if (Theme.appearance == Appearance.Material) AppListScreen else HomeScreen
Navigator(homeScreen) { navigator ->
Background(navigator)
SlideTransition(navigator) { screen ->
Scaffold(topBar = {
Row(verticalAlignment = Alignment.CenterVertically) {
if (screen != AppListScreen) {
IconButton(onClick = {navigator.pop()}) {
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null)
}
} else {
IconButton(onClick = {}, enabled = false) {
Icon(Icons.Filled.Home, contentDescription = null)
}
}
if (screen is HeadunitScreen) {
Text(screen.title, modifier = Modifier.padding(6.dp, 6.dp),
color= Theme.colorScheme.onBackground, style = Theme.typography.titleMedium)
}
Scaffold(containerColor = Color.Transparent, topBar = { TopBar(navigator, screen) }) { padding ->
val appearancePadding = when(Theme.appearance) {
Appearance.Material -> padding
Appearance.Bavaria -> PaddingValues(start=100.dp, top = padding.calculateTopPadding())
}
}) { padding ->
Box(modifier = Modifier.padding(padding)) {
Box(modifier = Modifier.padding(appearancePadding)) {
screen.Content()
}
}
}
StaticTopBar(navigator = navigator)

LaunchedEffectAndCollect(flow = RHMIAppsModel.incomingEvents) { incomingEvent ->
Log.i("MainActivity", "Examining incomingEvent $incomingEvent")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package io.bimmergestalt.headunit.ui.components
import androidx.compose.material3.Slider
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import io.bimmergestalt.headunit.models.RHMIAppInfo
import io.bimmergestalt.idriveconnectkit.rhmi.RHMIModel

@Composable
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import io.bimmergestalt.headunit.ui.components.AppList
import io.bimmergestalt.headunit.ui.components.AppListEntry
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.imageResource
import org.jetbrains.compose.resources.painterResource


object AppListScreen: Screen {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class RHMIScreen(val app: RHMIAppInfo, val stateId: Int): HeadunitScreen {
get() = "RHMIScreen(app=${app.appId}, stateId=$stateId)"

override val title: String
@Composable
get() {
return if (state is RHMIState.CalendarMonthState) {
val dateInt = state.getDateModel()?.asRaIntModel()?.value ?: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="152.86dp"
android:height="468.72dp"
android:viewportWidth="66.9"
android:viewportHeight="124.02">
<path
android:pathData="M65.92,0.71 L2.37,0.4C6.21,11.19 18.02,40.52 17.63,69.83 17.38,87.88 3.77,115.57 0.37,124.52L66.5,123.62"
android:strokeLineJoin="bevel"
android:strokeWidth="0.79375"
android:fillType="evenOdd"
android:strokeLineCap="square">
<aapt:attr name="android:fillColor">
<gradient
android:centerX="-1.83"
android:centerY="60.92"
android:gradientRadius="60.6"
android:type="radial">
<item android:offset="0" android:color="#FF6A6A6A"/>
<item android:offset="1" android:color="#006D6D6D"/>
</gradient>
</aapt:attr>
<aapt:attr name="android:strokeColor">
<gradient
android:startX="6.16"
android:startY="-0.44"
android:endX="5.58"
android:endY="125.07"
android:type="linear">
<item android:offset="0" android:color="#00ABABAB"/>
<item android:offset="0.56" android:color="#FFAAAAAA"/>
<item android:offset="1" android:color="#00FFFFFF"/>
</gradient>
</aapt:attr>
</path>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="250dp"
android:height="48dp"
android:viewportWidth="105.83"
android:viewportHeight="100">
<path
android:pathData="M0,0 L0,100H105.83V0"
android:strokeLineJoin="bevel"
android:strokeWidth="4"
android:fillType="evenOdd"
android:strokeLineCap="square">
<aapt:attr name="android:fillColor">
<gradient
android:centerX="50.6"
android:centerY="100.28"
android:gradientRadius="45"
android:type="radial">
<item android:offset="0" android:color="#B0909090"/>
<item android:offset="0.88" android:color="#58434343"/>
<item android:offset="1" android:color="#00000000"/>
</gradient>
</aapt:attr>
<aapt:attr name="android:strokeColor">
<gradient
android:startX="4"
android:startY="6.35"
android:endX="100"
android:endY="6.35"
android:type="linear">
<item android:offset="0" android:color="#00ABABAB"/>
<item android:offset="0.1" android:color="#FFABABAB"/>
<item android:offset="0.9" android:color="#FFABABAB"/>
<item android:offset="1" android:color="#00ABABAB"/>
</gradient>
</aapt:attr>
</path>
</vector>
49 changes: 49 additions & 0 deletions app/src/commonMain/composeResources/drawable/bavaria_tray.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="200dp"
android:height="40dp"
android:viewportWidth="60.375"
android:viewportHeight="12.7">
<path
android:pathData="M3.067,0.217 L7.873,11.4"
android:strokeLineJoin="bevel"
android:strokeWidth="0.793999"
android:fillColor="#00000000"
android:fillType="evenOdd"
android:strokeLineCap="round">
<aapt:attr name="android:strokeColor">
<gradient
android:startX="3.169"
android:startY="0.626"
android:endX="7.35"
android:endY="9.943"
android:type="linear">
<item android:offset="0" android:color="#0B000000"/>
<item android:offset="0.051" android:color="#FF484848"/>
<item android:offset="1" android:color="#FF373737"/>
</gradient>
</aapt:attr>
</path>
<path
android:pathData="m2.658,0.613 l4.243,9.867c0.566,1.317 1.593,1.748 2.709,1.748 H58.319"
android:strokeLineJoin="bevel"
android:strokeWidth="0.794"
android:fillColor="#00000000"
android:fillType="evenOdd"
android:strokeLineCap="round">
<aapt:attr name="android:strokeColor">
<gradient
android:startX="2.137"
android:startY="6.533"
android:endX="58.716"
android:endY="6.533"
android:type="linear">
<item android:offset="0" android:color="#FF979797"/>
<item android:offset="0.09" android:color="#FF8F8F8F"/>
<item android:offset="0.124" android:color="#FF5B5B5B"/>
<item android:offset="0.79" android:color="#FF4A4A4A"/>
<item android:offset="1" android:color="#005D5D5D"/>
</gradient>
</aapt:attr>
</path>
</vector>
12 changes: 12 additions & 0 deletions app/src/commonMain/composeResources/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<resources>
<string name="app_name">Headunit</string>
<string name="lbl_main_menu">Main menu</string>
<string name="lbl_main_multimedia">Multimedia</string>
<string name="lbl_main_radio">Radio</string>
<string name="lbl_main_telephone">Telephone</string>
<string name="lbl_main_navigation">Navigation</string>
<string name="lbl_main_office">Office</string>
<string name="lbl_main_connecteddrive">ConnectedDrive</string>
<string name="lbl_main_vehicle_information">Vehicle Information</string>
<string name="lbl_main_settings">Settings</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ object CalendarApp: HeadunitScreen {
private var selectedDate by mutableStateOf(Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()).date)

override val title: String
@Composable
get() = LocalDate.Format {
monthName(MonthNames.ENGLISH_FULL)
chars(", ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import kotlinx.datetime.format.Padding

class CalendarAppDay(val date: LocalDate, val events: List<CalendarEvent>): HeadunitScreen {
override val title: String
@Composable
get() = LocalDate.Format {
monthName(MonthNames.ENGLISH_FULL)
chars(" ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object ThemeSettings {
ColorTheme.Leaves,
)

var appearance by mutableStateOf(Appearance.Material)
var appearance by mutableStateOf(Appearance.Bavaria)
val availableAppearances = listOf(
Appearance.Material,
Appearance.Bavaria,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package io.bimmergestalt.headunit.screens

import androidx.compose.runtime.Composable
import cafe.adriel.voyager.core.screen.Screen

interface HeadunitScreen: Screen {
@get:Composable
val title: String
}
Loading

0 comments on commit 90cbd4c

Please sign in to comment.