Update sorting & view UI.
This commit is contained in:
parent
d8902dcd28
commit
c694d9b4d9
11 changed files with 75 additions and 101 deletions
|
|
@ -28,7 +28,7 @@ android {
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 1
|
versionCode = 1
|
||||||
versionName = "1.0"
|
versionName = "1.0.0"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
@ -38,9 +38,6 @@ android {
|
||||||
applicationIdSuffix = ".dev"
|
applicationIdSuffix = ".dev"
|
||||||
isDebuggable = true
|
isDebuggable = true
|
||||||
isMinifyEnabled = false
|
isMinifyEnabled = false
|
||||||
defaultConfig {
|
|
||||||
versionCode = 1
|
|
||||||
}
|
|
||||||
proguardFiles(
|
proguardFiles(
|
||||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
"proguard-rules.pro"
|
"proguard-rules.pro"
|
||||||
|
|
@ -50,9 +47,6 @@ android {
|
||||||
isDebuggable = false
|
isDebuggable = false
|
||||||
isMinifyEnabled = true
|
isMinifyEnabled = true
|
||||||
signingConfig = signingConfigs.getByName("pixelized")
|
signingConfig = signingConfigs.getByName("pixelized")
|
||||||
defaultConfig {
|
|
||||||
versionCode = getGitBuildNumber()
|
|
||||||
}
|
|
||||||
proguardFiles(
|
proguardFiles(
|
||||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
"proguard-rules.pro"
|
"proguard-rules.pro"
|
||||||
|
|
@ -110,19 +104,6 @@ dependencies {
|
||||||
ksp("com.google.dagger:hilt-compiler:2.57.2")
|
ksp("com.google.dagger:hilt-compiler:2.57.2")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
private fun getGitBuildNumber(
|
|
||||||
charset: Charset = Charset.defaultCharset(),
|
|
||||||
): Int {
|
|
||||||
return ByteArrayOutputStream().use { stream ->
|
|
||||||
rootProject.exec {
|
|
||||||
commandLine("git", "rev-list", "--count", "HEAD")
|
|
||||||
standardOutput = stream
|
|
||||||
}
|
|
||||||
stream.toString(charset).trim().toIntOrNull() ?: 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun SigningConfig.populatePixelizedSigningConfig() {
|
fun SigningConfig.populatePixelizedSigningConfig() {
|
||||||
storeFile = (project.properties["PIXELIZED_RELEASE_STORE_FILE"] as? String)?.let { file(it) }
|
storeFile = (project.properties["PIXELIZED_RELEASE_STORE_FILE"] as? String)?.let { file(it) }
|
||||||
storePassword = project.properties["PIXELIZED_RELEASE_STORE_PASSWORD"] as? String
|
storePassword = project.properties["PIXELIZED_RELEASE_STORE_PASSWORD"] as? String
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -1,37 +0,0 @@
|
||||||
{
|
|
||||||
"version": 3,
|
|
||||||
"artifactType": {
|
|
||||||
"type": "APK",
|
|
||||||
"kind": "Directory"
|
|
||||||
},
|
|
||||||
"applicationId": "com.pixelized.headache",
|
|
||||||
"variantName": "release",
|
|
||||||
"elements": [
|
|
||||||
{
|
|
||||||
"type": "SINGLE",
|
|
||||||
"filters": [],
|
|
||||||
"attributes": [],
|
|
||||||
"versionCode": 1,
|
|
||||||
"versionName": "1.0",
|
|
||||||
"outputFile": "app-release.apk"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"elementType": "File",
|
|
||||||
"baselineProfiles": [
|
|
||||||
{
|
|
||||||
"minApi": 28,
|
|
||||||
"maxApi": 30,
|
|
||||||
"baselineProfiles": [
|
|
||||||
"baselineProfiles/1/app-release.dm"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"minApi": 31,
|
|
||||||
"maxApi": 2147483647,
|
|
||||||
"baselineProfiles": [
|
|
||||||
"baselineProfiles/0/app-release.dm"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"minSdkVersionForDexing": 26
|
|
||||||
}
|
|
||||||
|
|
@ -62,6 +62,7 @@ class MonthSummaryFactory @Inject constructor() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.sortedByDescending { it.date }
|
||||||
.groupByMonth()
|
.groupByMonth()
|
||||||
.toSortedMap{s1, s2 ->
|
.toSortedMap{s1, s2 ->
|
||||||
when{
|
when{
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import androidx.compose.runtime.Stable
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.keepScreenOn
|
import androidx.compose.ui.keepScreenOn
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
|
@ -90,14 +91,9 @@ private fun MonthSummaryContent(
|
||||||
flingBehavior = flingBehavior,
|
flingBehavior = flingBehavior,
|
||||||
contentPadding = listPadding,
|
contentPadding = listPadding,
|
||||||
verticalArrangement = Arrangement.spacedBy(space = spacing),
|
verticalArrangement = Arrangement.spacedBy(space = spacing),
|
||||||
reverseLayout = false,
|
reverseLayout = true,
|
||||||
) {
|
) {
|
||||||
events.value.forEach { entry ->
|
events.value.forEach { entry ->
|
||||||
item {
|
|
||||||
MonthSummaryTitle(
|
|
||||||
item = entry.key,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
items(
|
items(
|
||||||
items = entry.value,
|
items = entry.value,
|
||||||
key = { item -> item.date },
|
key = { item -> item.date },
|
||||||
|
|
@ -107,6 +103,11 @@ private fun MonthSummaryContent(
|
||||||
onItem = onItem,
|
onItem = onItem,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
item {
|
||||||
|
MonthSummaryTitle(
|
||||||
|
item = entry.key,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,17 @@
|
||||||
package com.pixelized.headache.ui.page.summary.report
|
package com.pixelized.headache.ui.page.summary.report
|
||||||
|
|
||||||
import android.R
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.icu.text.DateFormat
|
import android.icu.text.DateFormat
|
||||||
import android.icu.text.SimpleDateFormat
|
import android.icu.text.SimpleDateFormat
|
||||||
import android.icu.util.Calendar
|
import android.icu.util.Calendar
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.border
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
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.height
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.offset
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
|
|
@ -153,13 +152,24 @@ private fun Month(
|
||||||
),
|
),
|
||||||
contentAlignment = Alignment.TopCenter,
|
contentAlignment = Alignment.TopCenter,
|
||||||
) {
|
) {
|
||||||
Text(
|
when (index == 0 && item.stats.size >= 2) {
|
||||||
style = MaterialTheme.typography.labelSmall,
|
true -> Text(
|
||||||
overflow = TextOverflow.Ellipsis,
|
modifier = Modifier.offset(y = (-14).dp),
|
||||||
maxLines = 1,
|
style = MaterialTheme.typography.labelSmall,
|
||||||
color = Color.White,
|
overflow = TextOverflow.Ellipsis,
|
||||||
text = stat.label,
|
maxLines = 1,
|
||||||
)
|
color = MaterialTheme.colorScheme.onSurface,
|
||||||
|
text = stat.label,
|
||||||
|
)
|
||||||
|
|
||||||
|
else -> Text(
|
||||||
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
maxLines = 1,
|
||||||
|
color = Color.White,
|
||||||
|
text = stat.label,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -227,8 +237,8 @@ private class ReportBoxPreviewProvider : PreviewParameterProvider<ReportBoxUio>
|
||||||
month(month = Calendar.JULY, headache = 7, pills = 3),
|
month(month = Calendar.JULY, headache = 7, pills = 3),
|
||||||
month(month = Calendar.AUGUST, headache = 8, pills = 5),
|
month(month = Calendar.AUGUST, headache = 8, pills = 5),
|
||||||
month(month = Calendar.SEPTEMBER, headache = 8, pills = 5),
|
month(month = Calendar.SEPTEMBER, headache = 8, pills = 5),
|
||||||
month(month = Calendar.OCTOBER),
|
month(month = Calendar.OCTOBER, headache = 15, pills = 15),
|
||||||
month(month = Calendar.NOVEMBER),
|
month(month = Calendar.NOVEMBER, headache = 9, pills = 7),
|
||||||
month(month = Calendar.DECEMBER),
|
month(month = Calendar.DECEMBER),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -38,17 +38,25 @@ class ReportFactory @Inject constructor() {
|
||||||
year = yearEntry.key
|
year = yearEntry.key
|
||||||
)
|
)
|
||||||
}.time,
|
}.time,
|
||||||
stats = listOf(
|
stats = listOfNotNull(
|
||||||
ReportBoxUio.Bar(
|
if (headache > 0) {
|
||||||
color = HeadacheColorPalette.Calendar.Headache,
|
ReportBoxUio.Bar(
|
||||||
label = "$headache",
|
color = HeadacheColorPalette.Calendar.Headache,
|
||||||
ratio = headache.toFloat() / dayInMonth.toFloat(),
|
label = "$headache",
|
||||||
),
|
ratio = headache.toFloat() / dayInMonth.toFloat(),
|
||||||
ReportBoxUio.Bar(
|
)
|
||||||
color = HeadacheColorPalette.Calendar.Pill,
|
} else {
|
||||||
label = "$pills",
|
null
|
||||||
ratio = pills.toFloat() / maxPillAmountPerMonth.toFloat(),
|
},
|
||||||
),
|
if (pills > 0) {
|
||||||
|
ReportBoxUio.Bar(
|
||||||
|
color = HeadacheColorPalette.Calendar.Pill,
|
||||||
|
label = "$pills",
|
||||||
|
ratio = pills.toFloat() / maxPillAmountPerMonth.toFloat(),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
},
|
||||||
).sortedByDescending { it.ratio },
|
).sortedByDescending { it.ratio },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@ private fun ReportContent(
|
||||||
state = state,
|
state = state,
|
||||||
flingBehavior = flingBehavior,
|
flingBehavior = flingBehavior,
|
||||||
contentPadding = paddingValues,
|
contentPadding = paddingValues,
|
||||||
|
reverseLayout = true,
|
||||||
verticalArrangement = Arrangement.spacedBy(space = contentSpace),
|
verticalArrangement = Arrangement.spacedBy(space = contentSpace),
|
||||||
) {
|
) {
|
||||||
items(
|
items(
|
||||||
|
|
@ -158,9 +159,9 @@ private class ReportPreviewProvider : PreviewParameterProvider<List<ReportBoxUio
|
||||||
month(month = Calendar.JUNE, headache = 12, pills = 13),
|
month(month = Calendar.JUNE, headache = 12, pills = 13),
|
||||||
month(month = Calendar.JULY, headache = 7, pills = 3),
|
month(month = Calendar.JULY, headache = 7, pills = 3),
|
||||||
month(month = Calendar.AUGUST, headache = 8, pills = 5),
|
month(month = Calendar.AUGUST, headache = 8, pills = 5),
|
||||||
month(month = Calendar.SEPTEMBER, headache = 8, pills = 5),
|
month(month = Calendar.SEPTEMBER, headache = 10, pills = 5),
|
||||||
month(month = Calendar.OCTOBER, headache = 0, pills = 0),
|
month(month = Calendar.OCTOBER, headache = 15, pills = 15),
|
||||||
month(month = Calendar.NOVEMBER, headache = 0, pills = 0),
|
month(month = Calendar.NOVEMBER, headache = 9, pills = 7),
|
||||||
month(month = Calendar.DECEMBER, headache = 0, pills = 0),
|
month(month = Calendar.DECEMBER, headache = 0, pills = 0),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,15 @@ class YearSummaryFactory @Inject constructor() {
|
||||||
): List<YearUio> {
|
): List<YearUio> {
|
||||||
val monthFirstDayCalendar = Calendar.getInstance().apply {
|
val monthFirstDayCalendar = Calendar.getInstance().apply {
|
||||||
firstDayOfWeek = Calendar.MONDAY
|
firstDayOfWeek = Calendar.MONDAY
|
||||||
setMinimalDaysInFirstWeek(1)
|
minimalDaysInFirstWeek = 1
|
||||||
}
|
}
|
||||||
val monthLastDayCalendar = Calendar.getInstance().apply {
|
val monthLastDayCalendar = Calendar.getInstance().apply {
|
||||||
firstDayOfWeek = Calendar.MONDAY
|
firstDayOfWeek = Calendar.MONDAY
|
||||||
setMinimalDaysInFirstWeek(1)
|
minimalDaysInFirstWeek = 1
|
||||||
}
|
}
|
||||||
val currentDayCalendar = Calendar.getInstance().apply {
|
val currentDayCalendar = Calendar.getInstance().apply {
|
||||||
firstDayOfWeek = Calendar.MONDAY
|
firstDayOfWeek = Calendar.MONDAY
|
||||||
setMinimalDaysInFirstWeek(1)
|
minimalDaysInFirstWeek = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
return events
|
return events
|
||||||
|
|
@ -73,6 +73,14 @@ class YearSummaryFactory @Inject constructor() {
|
||||||
date = monthFirstDayCalendar.time,
|
date = monthFirstDayCalendar.time,
|
||||||
weeks = weeks,
|
weeks = weeks,
|
||||||
)
|
)
|
||||||
|
}.sortedWith { s1, s2 ->
|
||||||
|
when {
|
||||||
|
s1.date.month / 3 < s2.date.month / 3 -> 1
|
||||||
|
s1.date.month / 3 > s2.date.month / 3 -> -1
|
||||||
|
s1.date.month < s2.date.month -> -1
|
||||||
|
s1.date.month > s2.date.month -> 1
|
||||||
|
else -> 0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -111,19 +111,10 @@ fun YearSummaryContent(
|
||||||
columns = GridCells.Adaptive(minSize = daySize * 7),
|
columns = GridCells.Adaptive(minSize = daySize * 7),
|
||||||
horizontalArrangement = Arrangement.spacedBy(space = space),
|
horizontalArrangement = Arrangement.spacedBy(space = space),
|
||||||
verticalArrangement = Arrangement.spacedBy(space = space),
|
verticalArrangement = Arrangement.spacedBy(space = space),
|
||||||
|
reverseLayout = true,
|
||||||
contentPadding = paddingValues,
|
contentPadding = paddingValues,
|
||||||
) {
|
) {
|
||||||
uio.value.forEachIndexed { index, (year, months) ->
|
uio.value.forEachIndexed { index, (year, months) ->
|
||||||
item(
|
|
||||||
span = { GridItemSpan(maxLineSpan) },
|
|
||||||
contentType = { "Title" },
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
modifier = Modifier.padding(top = 16.dp),
|
|
||||||
style = MaterialTheme.typography.displaySmall,
|
|
||||||
text = "$year",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
items(
|
items(
|
||||||
items = months,
|
items = months,
|
||||||
key = { it.date.time },
|
key = { it.date.time },
|
||||||
|
|
@ -137,6 +128,16 @@ fun YearSummaryContent(
|
||||||
onMonth = onMonth,
|
onMonth = onMonth,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
item(
|
||||||
|
span = { GridItemSpan(maxLineSpan) },
|
||||||
|
contentType = { "Title" },
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.padding(top = 16.dp),
|
||||||
|
style = MaterialTheme.typography.displaySmall,
|
||||||
|
text = "$year",
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue