Compare commits
18 Commits
2.2-Beta2
...
feature/gr
| Author | SHA1 | Date | |
|---|---|---|---|
| d81e197d8c | |||
| 7c940eacb0 | |||
| 410c948882 | |||
| 4cccc26849 | |||
| ac615560ae | |||
| 6fe4e1f790 | |||
| ff5495249f | |||
| 217370079d | |||
| add100146d | |||
| ceebe92f8b | |||
| 4f87321e2c | |||
| 81c540c2a5 | |||
| a45043424e | |||
| 18326e952f | |||
| a099659b2c | |||
| 61745c95a4 | |||
| 164cf6900f | |||
| 89ab0afaf5 |
75
.drone.yml
75
.drone.yml
@@ -1,75 +0,0 @@
|
|||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: Android
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: prepare signing
|
|
||||||
image: busybox
|
|
||||||
environment:
|
|
||||||
STOREPASSWORD:
|
|
||||||
from_secret: StorePassword
|
|
||||||
KEYPASSWORD:
|
|
||||||
from_secret: KeyPassword
|
|
||||||
commands:
|
|
||||||
- touch keystore.properties
|
|
||||||
- echo "storePassword=$STOREPASSWORD" >> keystore.properties
|
|
||||||
- echo "keyPassword=$KEYPASSWORD" >> keystore.properties
|
|
||||||
- echo "keyAlias=key0" >> keystore.properties
|
|
||||||
- echo "storeFile=../AndroidKey" >> keystore.properties
|
|
||||||
|
|
||||||
- name: generate versionCode
|
|
||||||
image: busybox
|
|
||||||
commands:
|
|
||||||
- touch version.properties
|
|
||||||
- let timestamp=$(date +%s)/10
|
|
||||||
- echo "versionCode=$timestamp" >> version.properties
|
|
||||||
|
|
||||||
- name: build
|
|
||||||
image: mingc/android-build-box
|
|
||||||
commands:
|
|
||||||
- ./gradlew test
|
|
||||||
- ./gradlew assembleRelease
|
|
||||||
- ./gradlew bundleRelease
|
|
||||||
|
|
||||||
- name: deploy latest build
|
|
||||||
image: curlimages/curl
|
|
||||||
environment:
|
|
||||||
SEAFILE_API_KEY:
|
|
||||||
from_secret: SeafileApiKey
|
|
||||||
APK_FILE: app/build/outputs/apk/release/app-release.apk
|
|
||||||
BUNDLE_FILE: app/build/outputs/bundle/release/app-release.aab
|
|
||||||
SEAFILE_REPO: 6debeef9-121e-46ba-acc7-81e109fdcbdd
|
|
||||||
commands:
|
|
||||||
- 'UPLOAD_URL=$(curl -H "Authorization: Token $SEAFILE_API_KEY" https://seafile.zobrist.me/api2/repos/$SEAFILE_REPO/upload-link/ | tr -d "\"")'
|
|
||||||
- echo $UPLOAD_URL
|
|
||||||
- 'curl -H "Authorization: Token $SEAFILE_API_KEY" -F file=@$APK_FILE -F parent_dir=/ -F relative_path=latest/ -F replace=1 "$UPLOAD_URL"'
|
|
||||||
- 'curl -H "Authorization: Token $SEAFILE_API_KEY" -F file=@$BUNDLE_FILE -F parent_dir=/ -F relative_path=latest/ -F replace=1 "$UPLOAD_URL"'
|
|
||||||
|
|
||||||
- name: deploy tagged build
|
|
||||||
image: curlimages/curl
|
|
||||||
environment:
|
|
||||||
SEAFILE_API_KEY:
|
|
||||||
from_secret: SeafileApiKey
|
|
||||||
APK_FILE: app/build/outputs/apk/release/app-release.apk
|
|
||||||
BUNDLE_FILE: app/build/outputs/bundle/release/app-release.aab
|
|
||||||
SEAFILE_REPO: 6debeef9-121e-46ba-acc7-81e109fdcbdd
|
|
||||||
commands:
|
|
||||||
- 'UPLOAD_URL=$(curl -H "Authorization: Token $SEAFILE_API_KEY" https://seafile.zobrist.me/api2/repos/$SEAFILE_REPO/upload-link/ | tr -d "\"")'
|
|
||||||
- 'curl -H "Authorization: Token $SEAFILE_API_KEY" -F file=@$APK_FILE -F parent_dir=/ -F relative_path=tagged/$DRONE_TAG/ -F replace=1 "$UPLOAD_URL"'
|
|
||||||
- 'curl -H "Authorization: Token $SEAFILE_API_KEY" -F file=@$BUNDLE_FILE -F parent_dir=/ -F relative_path=tagged/$DRONE_TAG/ -F replace=1 "$UPLOAD_URL"'
|
|
||||||
- 'curl -d "operation=rename&newname=app-release$DRONE_TAG.apk" -H "Authorization: Token $SEAFILE_API_KEY" https://seafile.zobrist.me/api2/repos/$SEAFILE_REPO/file/?p=/tagged/$DRONE_TAG/app-release.apk'
|
|
||||||
- 'curl -d "operation=rename&newname=app-release$DRONE_TAG.aab" -H "Authorization: Token $SEAFILE_API_KEY" https://seafile.zobrist.me/api2/repos/$SEAFILE_REPO/file/?p=/tagged/$DRONE_TAG/app-release.aab'
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
- name: slack notification
|
|
||||||
image: plugins/slack
|
|
||||||
settings:
|
|
||||||
webhook:
|
|
||||||
from_secret: SlackWebhook
|
|
||||||
when:
|
|
||||||
status:
|
|
||||||
- failure
|
|
||||||
- success
|
|
||||||
48
.gitea/workflows/buildAndroid.yaml
Normal file
48
.gitea/workflows/buildAndroid.yaml
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
name: Build Android
|
||||||
|
on: [pull_request, push]
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest-android
|
||||||
|
steps:
|
||||||
|
- name: Checkout the code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Prepare signing
|
||||||
|
run: |
|
||||||
|
touch keystore.properties
|
||||||
|
echo "storePassword=${{ secrets.STOREPASSWORD }}" >> keystore.properties
|
||||||
|
echo "keyPassword=${{ secrets.KEYPASSWORD }}" >> keystore.properties
|
||||||
|
echo "keyAlias=key0" >> keystore.properties
|
||||||
|
echo "storeFile=../AndroidKey" >> keystore.properties
|
||||||
|
|
||||||
|
- name: Generate versionCode
|
||||||
|
run: |
|
||||||
|
touch version.properties
|
||||||
|
let timestamp=$(date +%s)/10
|
||||||
|
echo "versionCode=$timestamp" >> version.properties
|
||||||
|
|
||||||
|
- name: Test the app
|
||||||
|
run: ./gradlew test
|
||||||
|
|
||||||
|
- name: Build apk
|
||||||
|
run: ./gradlew assembleRelease
|
||||||
|
|
||||||
|
- name: Build abb
|
||||||
|
run: ./gradlew bundleRelease
|
||||||
|
|
||||||
|
- name: Deploy latest to Nextcloud
|
||||||
|
run: |
|
||||||
|
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/apk/release/app-release.apk" "https://nextcloud.zobrist.me/remote.php/dav/files/deploy/TichuCounter/latest/app-release.apk"
|
||||||
|
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/bundle/release/app-release.aab" "https://nextcloud.zobrist.me/remote.php/dav/files/deploy/TichuCounter/latest/app-release.aab"
|
||||||
|
|
||||||
|
- name: Deploy tagged build to Nextcloud
|
||||||
|
run: |
|
||||||
|
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/apk/release/app-release.apk" "https://nextcloud.zobrist.me/remote.php/dav/files/deploy/TichuCounter/tagged/app-release-${GITHUB_REF_NAME##*/}.apk"
|
||||||
|
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/bundle/release/app-release.aab" "https://nextcloud.zobrist.me/remote.php/dav/files/deploy/TichuCounter/tagged/app-release-${GITHUB_REF_NAME##*/}.aab"
|
||||||
|
|
||||||
|
- uses: https://github.com/ravsamhq/notify-slack-action@v2
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
status: ${{ job.status }} # required
|
||||||
|
env:
|
||||||
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
|
||||||
@@ -91,17 +91,17 @@ dependencies {
|
|||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
implementation 'androidx.core:core-ktx:1.10.1'
|
implementation 'androidx.core:core-ktx:1.10.1'
|
||||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||||
implementation "androidx.compose.material3:material3:1.1.0"
|
implementation "androidx.compose.material3:material3:1.1.1"
|
||||||
implementation 'com.google.android.play:core-ktx:1.8.1'
|
implementation 'com.google.android.play:core-ktx:1.8.1'
|
||||||
implementation 'com.google.android.play:core-ktx:1.8.1'
|
implementation 'com.google.android.play:core-ktx:1.8.1'
|
||||||
implementation 'com.google.code.gson:gson:2.9.0'
|
implementation 'com.google.code.gson:gson:2.9.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
|
implementation 'androidx.navigation:navigation-fragment-ktx:2.6.0'
|
||||||
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
|
implementation 'androidx.navigation:navigation-ui-ktx:2.6.0'
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1'
|
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1'
|
||||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
|
||||||
implementation 'androidx.fragment:fragment-ktx:1.5.7'
|
implementation 'androidx.fragment:fragment-ktx:1.6.0'
|
||||||
implementation 'androidx.preference:preference-ktx:1.2.0'
|
implementation 'androidx.preference:preference-ktx:1.2.0'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.3.0'
|
implementation 'androidx.recyclerview:recyclerview:1.3.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
|
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
|
||||||
@@ -111,7 +111,7 @@ dependencies {
|
|||||||
implementation "androidx.compose.ui:ui:1.4.3"
|
implementation "androidx.compose.ui:ui:1.4.3"
|
||||||
implementation "androidx.compose.ui:ui-tooling-preview:1.4.3"
|
implementation "androidx.compose.ui:ui-tooling-preview:1.4.3"
|
||||||
implementation "androidx.compose.runtime:runtime-livedata:1.4.3"
|
implementation "androidx.compose.runtime:runtime-livedata:1.4.3"
|
||||||
implementation "androidx.navigation:navigation-compose:2.5.3"
|
implementation "androidx.navigation:navigation-compose:2.6.0"
|
||||||
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1"
|
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1"
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||||
@@ -121,12 +121,13 @@ dependencies {
|
|||||||
debugImplementation "androidx.compose.ui:ui-tooling:1.4.3"
|
debugImplementation "androidx.compose.ui:ui-tooling:1.4.3"
|
||||||
debugImplementation "androidx.compose.ui:ui-test-manifest:1.4.3"
|
debugImplementation "androidx.compose.ui:ui-test-manifest:1.4.3"
|
||||||
kapt "com.google.dagger:hilt-compiler:2.44"
|
kapt "com.google.dagger:hilt-compiler:2.44"
|
||||||
implementation "androidx.room:room-runtime:2.5.1"
|
implementation "androidx.room:room-runtime:2.5.2"
|
||||||
annotationProcessor "androidx.room:room-compiler:2.5.1"
|
annotationProcessor "androidx.room:room-compiler:2.5.2"
|
||||||
kapt "androidx.room:room-compiler:2.5.1"
|
kapt "androidx.room:room-compiler:2.5.2"
|
||||||
implementation "androidx.room:room-ktx:2.5.1"
|
implementation "androidx.room:room-ktx:2.5.2"
|
||||||
implementation "androidx.multidex:multidex:2.0.1"
|
implementation "androidx.multidex:multidex:2.0.1"
|
||||||
api "androidx.navigation:navigation-fragment-ktx:2.5.3"
|
api "androidx.navigation:navigation-fragment-ktx:2.6.0"
|
||||||
|
implementation "com.patrykandpatrick.vico:compose-m3:1.6.5"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow references to generated code
|
// Allow references to generated code
|
||||||
|
|||||||
@@ -6,14 +6,33 @@ import androidx.activity.compose.setContent
|
|||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.*
|
import androidx.compose.material.icons.outlined.Calculate
|
||||||
import androidx.compose.material.icons.outlined.*
|
import androidx.compose.material.icons.outlined.Info
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material.icons.outlined.Keyboard
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.material.icons.outlined.List
|
||||||
|
import androidx.compose.material.icons.outlined.MoreVert
|
||||||
|
import androidx.compose.material.icons.outlined.Redo
|
||||||
|
import androidx.compose.material.icons.outlined.Settings
|
||||||
|
import androidx.compose.material.icons.outlined.Undo
|
||||||
|
import androidx.compose.material3.DrawerState
|
||||||
|
import androidx.compose.material3.DrawerValue
|
||||||
|
import androidx.compose.material3.FloatingActionButton
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.ModalNavigationDrawer
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.material3.rememberDrawerState
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.navigation.NavHostController
|
import androidx.navigation.NavHostController
|
||||||
import androidx.navigation.compose.NavHost
|
import androidx.navigation.compose.NavHost
|
||||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||||
@@ -22,12 +41,23 @@ import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
|||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import me.zobrist.tichucounter.domain.*
|
import me.zobrist.tichucounter.domain.DrawerItem
|
||||||
|
import me.zobrist.tichucounter.domain.ISystemSettingsListener
|
||||||
|
import me.zobrist.tichucounter.domain.KeepScreenOn
|
||||||
|
import me.zobrist.tichucounter.domain.Language
|
||||||
|
import me.zobrist.tichucounter.domain.Route
|
||||||
|
import me.zobrist.tichucounter.domain.SettingsAdapter
|
||||||
|
import me.zobrist.tichucounter.domain.Theme
|
||||||
|
import me.zobrist.tichucounter.domain.TopBarAction
|
||||||
|
import me.zobrist.tichucounter.domain.TopBarState
|
||||||
|
import me.zobrist.tichucounter.domain.composable
|
||||||
|
import me.zobrist.tichucounter.domain.navigate
|
||||||
import me.zobrist.tichucounter.ui.AppTheme
|
import me.zobrist.tichucounter.ui.AppTheme
|
||||||
import me.zobrist.tichucounter.ui.MainViewModel
|
import me.zobrist.tichucounter.ui.MainViewModel
|
||||||
import me.zobrist.tichucounter.ui.about.AboutView
|
import me.zobrist.tichucounter.ui.about.AboutView
|
||||||
import me.zobrist.tichucounter.ui.composables.DropDownMenu
|
import me.zobrist.tichucounter.ui.composables.DropDownMenu
|
||||||
import me.zobrist.tichucounter.ui.counter.*
|
import me.zobrist.tichucounter.ui.counter.Counter
|
||||||
|
import me.zobrist.tichucounter.ui.counter.CounterViewModel
|
||||||
import me.zobrist.tichucounter.ui.history.HistoryList
|
import me.zobrist.tichucounter.ui.history.HistoryList
|
||||||
import me.zobrist.tichucounter.ui.history.HistoryViewModel
|
import me.zobrist.tichucounter.ui.history.HistoryViewModel
|
||||||
import me.zobrist.tichucounter.ui.layout.DrawerContent
|
import me.zobrist.tichucounter.ui.layout.DrawerContent
|
||||||
@@ -37,7 +67,7 @@ import me.zobrist.tichucounter.ui.settings.SettingsViewModel
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class MainActivity : AppCompatActivity(), ISettingsChangeListener {
|
class MainActivity : AppCompatActivity(), ISystemSettingsListener {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var settingsAdapter: SettingsAdapter
|
lateinit var settingsAdapter: SettingsAdapter
|
||||||
@@ -156,6 +186,7 @@ class MainActivity : AppCompatActivity(), ISettingsChangeListener {
|
|||||||
floatingActionButton = {
|
floatingActionButton = {
|
||||||
if (showFab) {
|
if (showFab) {
|
||||||
FloatingActionButton(
|
FloatingActionButton(
|
||||||
|
modifier = Modifier.padding(end = 75.dp),
|
||||||
onClick = { fabAction() }) {
|
onClick = { fabAction() }) {
|
||||||
Icon(Icons.Outlined.Keyboard, null)
|
Icon(Icons.Outlined.Keyboard, null)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,19 +14,26 @@ enum class Language(val value: LocaleListCompat) {
|
|||||||
GERMAN(LocaleListCompat.forLanguageTags("de"))
|
GERMAN(LocaleListCompat.forLanguageTags("de"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class CounterMode { LIST, GRAPH }
|
||||||
|
|
||||||
enum class KeepScreenOn(val value: Boolean) { ON(true), OFF(false) }
|
enum class KeepScreenOn(val value: Boolean) { ON(true), OFF(false) }
|
||||||
|
|
||||||
interface ISettingsChangeListener {
|
interface ISystemSettingsListener {
|
||||||
fun onLanguageChanged(language: Language)
|
fun onLanguageChanged(language: Language)
|
||||||
fun onThemeChanged(theme: Theme)
|
fun onThemeChanged(theme: Theme)
|
||||||
fun onScreenOnChanged(keepOn: KeepScreenOn)
|
fun onScreenOnChanged(keepOn: KeepScreenOn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IDisplaySettingsListener {
|
||||||
|
fun onCounterModeChanged(counterMode: CounterMode)
|
||||||
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class SettingsAdapter @Inject constructor(@ApplicationContext private val context: Context) {
|
class SettingsAdapter @Inject constructor(@ApplicationContext private val context: Context) {
|
||||||
|
|
||||||
private val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
private val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
private var listenerList = mutableListOf<ISettingsChangeListener>()
|
private var systemSettingsListeners = mutableListOf<ISystemSettingsListener>()
|
||||||
|
private var displaySettingsListeners = mutableListOf<IDisplaySettingsListener>()
|
||||||
|
|
||||||
var language: Language
|
var language: Language
|
||||||
private set
|
private set
|
||||||
@@ -37,37 +44,58 @@ class SettingsAdapter @Inject constructor(@ApplicationContext private val contex
|
|||||||
var keepScreenOn: KeepScreenOn
|
var keepScreenOn: KeepScreenOn
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
var counterMode: CounterMode
|
||||||
|
private set
|
||||||
|
|
||||||
init {
|
init {
|
||||||
language = try {
|
language = try {
|
||||||
enumValueOf(sharedPreferences.getString(Language::class.simpleName, null)!!)
|
enumValueOf(sharedPreferences.getString(Language::class.simpleName, null)!!)
|
||||||
} catch (_: NullPointerException) {
|
} catch (_: Exception) {
|
||||||
Language.DEFAULT
|
Language.DEFAULT
|
||||||
}
|
}
|
||||||
|
|
||||||
theme = try {
|
theme = try {
|
||||||
enumValueOf(sharedPreferences.getString(Theme::class.simpleName, null)!!)
|
enumValueOf(sharedPreferences.getString(Theme::class.simpleName, null)!!)
|
||||||
} catch (_: java.lang.Exception) {
|
} catch (_: Exception) {
|
||||||
Theme.DEFAULT
|
Theme.DEFAULT
|
||||||
}
|
}
|
||||||
|
|
||||||
keepScreenOn = try {
|
keepScreenOn = try {
|
||||||
enumValueOf(sharedPreferences.getString(KeepScreenOn::class.simpleName, null)!!)
|
enumValueOf(sharedPreferences.getString(KeepScreenOn::class.simpleName, null)!!)
|
||||||
} catch (_: java.lang.Exception) {
|
} catch (_: Exception) {
|
||||||
KeepScreenOn.OFF
|
KeepScreenOn.OFF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
counterMode = try {
|
||||||
|
enumValueOf(sharedPreferences.getString(CounterMode::class.simpleName, null)!!)
|
||||||
|
} catch (_: Exception) {
|
||||||
|
CounterMode.LIST
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun registerOnChangeListener(listener: ISettingsChangeListener) {
|
fun registerOnChangeListener(listener: IDisplaySettingsListener) {
|
||||||
listenerList.add(listener)
|
displaySettingsListeners.add(listener)
|
||||||
|
|
||||||
|
listener.onCounterModeChanged(counterMode)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun unregisterOnChangeListener(listener: IDisplaySettingsListener?) {
|
||||||
|
if (listener != null) {
|
||||||
|
displaySettingsListeners.remove(listener)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun registerOnChangeListener(listener: ISystemSettingsListener) {
|
||||||
|
systemSettingsListeners.add(listener)
|
||||||
|
|
||||||
listener.onThemeChanged(theme)
|
listener.onThemeChanged(theme)
|
||||||
listener.onLanguageChanged(language)
|
listener.onLanguageChanged(language)
|
||||||
listener.onScreenOnChanged(keepScreenOn)
|
listener.onScreenOnChanged(keepScreenOn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun unregisterOnChangeListener(listener: ISettingsChangeListener?) {
|
fun unregisterOnChangeListener(listener: ISystemSettingsListener?) {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listenerList.remove(listener)
|
systemSettingsListeners.remove(listener)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,6 +117,12 @@ class SettingsAdapter @Inject constructor(@ApplicationContext private val contex
|
|||||||
notifyListeners(setting)
|
notifyListeners(setting)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setCounterMode(counterMode: CounterMode) {
|
||||||
|
this.counterMode = counterMode
|
||||||
|
updatePreference(CounterMode::class.simpleName, counterMode.name)
|
||||||
|
notifyListeners(counterMode)
|
||||||
|
}
|
||||||
|
|
||||||
private fun updatePreference(name: String?, value: String) {
|
private fun updatePreference(name: String?, value: String) {
|
||||||
val editor = sharedPreferences.edit()
|
val editor = sharedPreferences.edit()
|
||||||
editor.putString(name, value)
|
editor.putString(name, value)
|
||||||
@@ -96,21 +130,27 @@ class SettingsAdapter @Inject constructor(@ApplicationContext private val contex
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun notifyListeners(language: Language) {
|
private fun notifyListeners(language: Language) {
|
||||||
listenerList.forEach {
|
systemSettingsListeners.forEach {
|
||||||
it.onLanguageChanged(language)
|
it.onLanguageChanged(language)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun notifyListeners(theme: Theme) {
|
private fun notifyListeners(theme: Theme) {
|
||||||
listenerList.forEach {
|
systemSettingsListeners.forEach {
|
||||||
it.onThemeChanged(theme)
|
it.onThemeChanged(theme)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun notifyListeners(keepScreenOn: KeepScreenOn) {
|
private fun notifyListeners(keepScreenOn: KeepScreenOn) {
|
||||||
listenerList.forEach {
|
systemSettingsListeners.forEach {
|
||||||
it.onScreenOnChanged(keepScreenOn)
|
it.onScreenOnChanged(keepScreenOn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun notifyListeners(counterMode: CounterMode) {
|
||||||
|
displaySettingsListeners.forEach {
|
||||||
|
it.onCounterModeChanged(counterMode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,31 @@
|
|||||||
package me.zobrist.tichucounter.ui.counter
|
package me.zobrist.tichucounter.ui.counter
|
||||||
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.outlined.ShowChart
|
||||||
|
import androidx.compose.material.icons.outlined.TableRows
|
||||||
|
import androidx.compose.material3.FloatingActionButton
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.focus.FocusRequester
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.platform.LocalConfiguration
|
import androidx.compose.ui.platform.LocalConfiguration
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
import me.zobrist.tichucounter.data.entity.Round
|
import me.zobrist.tichucounter.data.entity.Round
|
||||||
|
import me.zobrist.tichucounter.domain.CounterMode
|
||||||
import me.zobrist.tichucounter.ui.AppTheme
|
import me.zobrist.tichucounter.ui.AppTheme
|
||||||
|
|
||||||
|
|
||||||
@@ -50,10 +62,13 @@ fun Landscape(viewModel: ICounterViewModel) {
|
|||||||
viewModel.totalScoreB
|
viewModel.totalScoreB
|
||||||
)
|
)
|
||||||
|
|
||||||
RoundListView(
|
RoundView(
|
||||||
viewModel.roundScoreList,
|
Modifier.weight(1f),
|
||||||
Modifier.weight(1f)
|
viewModel.counterMode,
|
||||||
|
viewModel.roundScoreList
|
||||||
)
|
)
|
||||||
|
{ viewModel.changeCounterMode() }
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!viewModel.keyboardHidden) {
|
if (!viewModel.keyboardHidden) {
|
||||||
Column(Modifier.weight(1f)) {
|
Column(Modifier.weight(1f)) {
|
||||||
@@ -81,10 +96,12 @@ fun Portrait(viewModel: ICounterViewModel) {
|
|||||||
viewModel.totalScoreB
|
viewModel.totalScoreB
|
||||||
)
|
)
|
||||||
|
|
||||||
RoundListView(
|
RoundView(
|
||||||
viewModel.roundScoreList,
|
Modifier.weight(1f),
|
||||||
Modifier.weight(1f)
|
viewModel.counterMode,
|
||||||
|
viewModel.roundScoreList
|
||||||
)
|
)
|
||||||
|
{ viewModel.changeCounterMode() }
|
||||||
|
|
||||||
if (!viewModel.keyboardHidden) {
|
if (!viewModel.keyboardHidden) {
|
||||||
KeyBoardView(viewModel = viewModel)
|
KeyBoardView(viewModel = viewModel)
|
||||||
@@ -92,6 +109,41 @@ fun Portrait(viewModel: ICounterViewModel) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun RoundView(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
counterMode: CounterMode,
|
||||||
|
rounds: List<Round>,
|
||||||
|
changeCounterMode: () -> Unit
|
||||||
|
) {
|
||||||
|
Box(modifier) {
|
||||||
|
if (counterMode == CounterMode.LIST) {
|
||||||
|
RoundListView(
|
||||||
|
rounds,
|
||||||
|
Modifier.fillMaxHeight()
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
RoundGraphView(
|
||||||
|
rounds,
|
||||||
|
Modifier.fillMaxHeight()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
FloatingActionButton(
|
||||||
|
modifier = Modifier
|
||||||
|
.align(Alignment.BottomEnd)
|
||||||
|
.padding(15.dp),
|
||||||
|
onClick = { changeCounterMode() }) {
|
||||||
|
Icon(getIcon(counterMode), null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getIcon(counterMode: CounterMode): ImageVector {
|
||||||
|
return when (counterMode) {
|
||||||
|
CounterMode.LIST -> Icons.Outlined.ShowChart
|
||||||
|
CounterMode.GRAPH -> Icons.Outlined.TableRows
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Preview(name = "Light Mode")
|
@Preview(name = "Light Mode")
|
||||||
@Preview(name = "Dark Mode", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = true)
|
@Preview(name = "Dark Mode", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = true)
|
||||||
@@ -123,6 +175,7 @@ internal class PreviewViewModel : ICounterViewModel {
|
|||||||
listOf("TeamA", "asdffd", "TeamB", "really really long Team Name that is way too long")
|
listOf("TeamA", "asdffd", "TeamB", "really really long Team Name that is way too long")
|
||||||
override val teamNameSuggestionsB: List<String> =
|
override val teamNameSuggestionsB: List<String> =
|
||||||
listOf("TeamA", "asdffd", "TeamB", "really really long Team Name that is way too long")
|
listOf("TeamA", "asdffd", "TeamB", "really really long Team Name that is way too long")
|
||||||
|
override val counterMode: CounterMode = CounterMode.GRAPH
|
||||||
|
|
||||||
override fun focusLastInput() {
|
override fun focusLastInput() {
|
||||||
}
|
}
|
||||||
@@ -155,6 +208,9 @@ internal class PreviewViewModel : ICounterViewModel {
|
|||||||
override fun updateNameB(value: String) {
|
override fun updateNameB(value: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun changeCounterMode() {
|
||||||
|
}
|
||||||
|
|
||||||
override fun updateFocusStateA(state: Boolean) {
|
override fun updateFocusStateA(state: Boolean) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ import kotlinx.coroutines.Job
|
|||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import me.zobrist.tichucounter.data.entity.Round
|
import me.zobrist.tichucounter.data.entity.Round
|
||||||
|
import me.zobrist.tichucounter.domain.CounterMode
|
||||||
|
import me.zobrist.tichucounter.domain.IDisplaySettingsListener
|
||||||
|
import me.zobrist.tichucounter.domain.SettingsAdapter
|
||||||
import me.zobrist.tichucounter.domain.Tichu
|
import me.zobrist.tichucounter.domain.Tichu
|
||||||
import me.zobrist.tichucounter.domain.digitCount
|
import me.zobrist.tichucounter.domain.digitCount
|
||||||
import me.zobrist.tichucounter.domain.getTotalPoints
|
import me.zobrist.tichucounter.domain.getTotalPoints
|
||||||
@@ -57,16 +60,19 @@ interface ICounterViewModel : IKeyBoardViewModel {
|
|||||||
val teamNameB: String
|
val teamNameB: String
|
||||||
val teamNameSuggestionsA: List<String>
|
val teamNameSuggestionsA: List<String>
|
||||||
val teamNameSuggestionsB: List<String>
|
val teamNameSuggestionsB: List<String>
|
||||||
|
val counterMode: CounterMode
|
||||||
|
|
||||||
fun updateNameA(value: String)
|
fun updateNameA(value: String)
|
||||||
fun updateNameB(value: String)
|
fun updateNameB(value: String)
|
||||||
|
fun changeCounterMode()
|
||||||
}
|
}
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class CounterViewModel @Inject constructor(
|
class CounterViewModel @Inject constructor(
|
||||||
private val gameRepository: GameRepository
|
private val gameRepository: GameRepository,
|
||||||
|
private val settingsAdapter: SettingsAdapter
|
||||||
) :
|
) :
|
||||||
ViewModel(), ICounterViewModel {
|
ViewModel(), ICounterViewModel, IDisplaySettingsListener {
|
||||||
|
|
||||||
override var roundScoreList by mutableStateOf(emptyList<Round>())
|
override var roundScoreList by mutableStateOf(emptyList<Round>())
|
||||||
private set
|
private set
|
||||||
@@ -113,6 +119,17 @@ class CounterViewModel @Inject constructor(
|
|||||||
override var teamNameSuggestionsB by mutableStateOf(listOf<String>())
|
override var teamNameSuggestionsB by mutableStateOf(listOf<String>())
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
override var counterMode by mutableStateOf(CounterMode.LIST)
|
||||||
|
private set
|
||||||
|
|
||||||
|
init {
|
||||||
|
settingsAdapter.registerOnChangeListener(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCleared() {
|
||||||
|
settingsAdapter.unregisterOnChangeListener(this)
|
||||||
|
}
|
||||||
|
|
||||||
override var activeValue: String
|
override var activeValue: String
|
||||||
get() {
|
get() {
|
||||||
return if (isBFocused) {
|
return if (isBFocused) {
|
||||||
@@ -157,8 +174,6 @@ class CounterViewModel @Inject constructor(
|
|||||||
init {
|
init {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
gameRepository.getActiveGameFlow().collect {
|
gameRepository.getActiveGameFlow().collect {
|
||||||
if (it != null) {
|
|
||||||
|
|
||||||
val score = it.getTotalPoints()
|
val score = it.getTotalPoints()
|
||||||
|
|
||||||
roundScoreList = it.rounds
|
roundScoreList = it.rounds
|
||||||
@@ -169,8 +184,6 @@ class CounterViewModel @Inject constructor(
|
|||||||
teamNameB = it.game.nameB
|
teamNameB = it.game.nameB
|
||||||
|
|
||||||
buildTeamNameSuggestions()
|
buildTeamNameSuggestions()
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,6 +302,14 @@ class CounterViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun changeCounterMode() {
|
||||||
|
val nextMode = when (settingsAdapter.counterMode) {
|
||||||
|
CounterMode.LIST -> CounterMode.GRAPH
|
||||||
|
CounterMode.GRAPH -> CounterMode.LIST
|
||||||
|
}
|
||||||
|
settingsAdapter.setCounterMode(nextMode)
|
||||||
|
}
|
||||||
|
|
||||||
override fun updateFocusStateA(state: Boolean) {
|
override fun updateFocusStateA(state: Boolean) {
|
||||||
isAFocused = state
|
isAFocused = state
|
||||||
if (state) {
|
if (state) {
|
||||||
@@ -362,4 +383,8 @@ class CounterViewModel @Inject constructor(
|
|||||||
|
|
||||||
return filtered.sorted().sortedBy { it.length }.take(10)
|
return filtered.sorted().sortedBy { it.length }.take(10)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onCounterModeChanged(counterMode: CounterMode) {
|
||||||
|
this.counterMode = counterMode
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,40 @@
|
|||||||
package me.zobrist.tichucounter.ui.counter
|
package me.zobrist.tichucounter.ui.counter
|
||||||
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import androidx.compose.animation.core.*
|
import androidx.compose.animation.core.RepeatMode
|
||||||
|
import androidx.compose.animation.core.animateFloat
|
||||||
|
import androidx.compose.animation.core.infiniteRepeatable
|
||||||
|
import androidx.compose.animation.core.rememberInfiniteTransition
|
||||||
|
import androidx.compose.animation.core.tween
|
||||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||||
import androidx.compose.foundation.interaction.collectIsPressedAsState
|
import androidx.compose.foundation.interaction.collectIsPressedAsState
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.IntrinsicSize
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.layout.wrapContentWidth
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.Backspace
|
import androidx.compose.material.icons.outlined.Backspace
|
||||||
import androidx.compose.material.icons.outlined.Check
|
import androidx.compose.material.icons.outlined.Check
|
||||||
import androidx.compose.material.icons.outlined.KeyboardHide
|
import androidx.compose.material.icons.outlined.KeyboardHide
|
||||||
import androidx.compose.material.icons.outlined.SwapHoriz
|
import androidx.compose.material.icons.outlined.SwapHoriz
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.Divider
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.material3.ElevatedButton
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.LocalTextStyle
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TextField
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.focus.FocusRequester
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
|
|||||||
@@ -0,0 +1,104 @@
|
|||||||
|
package me.zobrist.tichucounter.ui.counter
|
||||||
|
|
||||||
|
import android.content.res.Configuration
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.toArgb
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import com.patrykandpatrick.vico.compose.axis.vertical.startAxis
|
||||||
|
import com.patrykandpatrick.vico.compose.chart.Chart
|
||||||
|
import com.patrykandpatrick.vico.compose.chart.line.lineChart
|
||||||
|
import com.patrykandpatrick.vico.compose.chart.scroll.rememberChartScrollSpec
|
||||||
|
import com.patrykandpatrick.vico.core.axis.formatter.DecimalFormatAxisValueFormatter
|
||||||
|
import com.patrykandpatrick.vico.core.chart.line.LineChart
|
||||||
|
import com.patrykandpatrick.vico.core.chart.values.AxisValuesOverrider
|
||||||
|
import com.patrykandpatrick.vico.core.entry.FloatEntry
|
||||||
|
import com.patrykandpatrick.vico.core.entry.composed.ComposedChartEntryModelProducer.Companion.composedChartEntryModelOf
|
||||||
|
import com.patrykandpatrick.vico.core.entry.entryModelOf
|
||||||
|
import me.zobrist.tichucounter.data.entity.Round
|
||||||
|
import me.zobrist.tichucounter.ui.AppTheme
|
||||||
|
import kotlin.math.ceil
|
||||||
|
import kotlin.math.floor
|
||||||
|
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun RoundGraphView(rounds: List<Round>, modifier: Modifier = Modifier) {
|
||||||
|
|
||||||
|
val points = getPoints(rounds)
|
||||||
|
|
||||||
|
val range = getRange(points.first, points.second, 50)
|
||||||
|
|
||||||
|
val specA = LineChart.LineSpec(MaterialTheme.colorScheme.primary.toArgb())
|
||||||
|
val specB = LineChart.LineSpec(MaterialTheme.colorScheme.secondary.toArgb())
|
||||||
|
|
||||||
|
|
||||||
|
Chart(
|
||||||
|
chart = lineChart(
|
||||||
|
lines = listOf(specA, specB),
|
||||||
|
axisValuesOverrider = AxisValuesOverrider.fixed(
|
||||||
|
minY = range.first,
|
||||||
|
maxY = range.second
|
||||||
|
)
|
||||||
|
),
|
||||||
|
model = composedChartEntryModelOf(
|
||||||
|
listOf(
|
||||||
|
entryModelOf(points.first),
|
||||||
|
entryModelOf(points.second)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
startAxis = startAxis(
|
||||||
|
maxLabelCount = 10,
|
||||||
|
valueFormatter = DecimalFormatAxisValueFormatter("#")
|
||||||
|
),
|
||||||
|
chartScrollSpec = rememberChartScrollSpec(isScrollEnabled = false),
|
||||||
|
modifier = modifier
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getPoints(rounds: List<Round>): Pair<List<FloatEntry>, List<FloatEntry>> {
|
||||||
|
val a = mutableListOf(FloatEntry(0f, 0f))
|
||||||
|
val b = mutableListOf(FloatEntry(0f, 0f))
|
||||||
|
|
||||||
|
var sumA = 0
|
||||||
|
var sumB = 0
|
||||||
|
|
||||||
|
rounds.forEachIndexed { index, round ->
|
||||||
|
sumA += round.scoreA
|
||||||
|
sumB += round.scoreB
|
||||||
|
a.add(FloatEntry((index + 1).toFloat(), sumA.toFloat()))
|
||||||
|
b.add(FloatEntry((index + 1).toFloat(), sumB.toFloat()))
|
||||||
|
}
|
||||||
|
return Pair(a, b)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getRange(a: List<FloatEntry>, b: List<FloatEntry>, step: Int): Pair<Float, Float> {
|
||||||
|
|
||||||
|
val min = (a + b).minBy { it.y }
|
||||||
|
val max = (a + b).maxBy { it.y }
|
||||||
|
|
||||||
|
val lo = floor(min.y / step) * step
|
||||||
|
val hi = ceil(max.y / step) * step
|
||||||
|
|
||||||
|
return Pair(lo, hi)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview(name = "Light Mode")
|
||||||
|
@Preview(name = "Dark Mode", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = true)
|
||||||
|
@Composable
|
||||||
|
fun RoundGraphViewPreview() {
|
||||||
|
val rounds = listOf(
|
||||||
|
Round(1, 10, -10),
|
||||||
|
Round(1, 5, 95),
|
||||||
|
Round(1, 100, 0),
|
||||||
|
Round(1, 125, -25),
|
||||||
|
Round(1, 50, 50)
|
||||||
|
)
|
||||||
|
|
||||||
|
AppTheme {
|
||||||
|
Surface {
|
||||||
|
RoundGraphView(rounds, Modifier)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,7 +21,7 @@ import me.zobrist.tichucounter.data.entity.Round
|
|||||||
import me.zobrist.tichucounter.ui.AppTheme
|
import me.zobrist.tichucounter.ui.AppTheme
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun RoundListView(rounds: List<Round>, modifier: Modifier) {
|
fun RoundListView(rounds: List<Round>, modifier: Modifier = Modifier) {
|
||||||
val lazyListState = rememberLazyListState()
|
val lazyListState = rememberLazyListState()
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package me.zobrist.tichucounter.ui.counter
|
package me.zobrist.tichucounter.ui.counter
|
||||||
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.LocalTextStyle
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.TextFieldDefaults
|
||||||
|
import androidx.compose.material3.surfaceColorAtElevation
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
|||||||
@@ -1,20 +1,28 @@
|
|||||||
package me.zobrist.tichucounter.ui.layout
|
package me.zobrist.tichucounter.ui.layout
|
||||||
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.*
|
import androidx.compose.material.icons.outlined.Calculate
|
||||||
import androidx.compose.material.icons.outlined.*
|
import androidx.compose.material.icons.outlined.List
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material.icons.outlined.Settings
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.material3.Divider
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.ModalDrawerSheet
|
||||||
|
import androidx.compose.material3.NavigationDrawerItem
|
||||||
|
import androidx.compose.material3.NavigationDrawerItemDefaults
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import me.zobrist.tichucounter.R
|
import me.zobrist.tichucounter.R
|
||||||
import me.zobrist.tichucounter.domain.*
|
import me.zobrist.tichucounter.domain.DrawerItem
|
||||||
|
import me.zobrist.tichucounter.domain.Route
|
||||||
import me.zobrist.tichucounter.ui.AppTheme
|
import me.zobrist.tichucounter.ui.AppTheme
|
||||||
import me.zobrist.tichucounter.ui.counter.*
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DrawerContent(
|
fun DrawerContent(
|
||||||
|
|||||||
Reference in New Issue
Block a user