LocationItem: group departures by line (#1295)

* group departures by line if more than one line depart from given stop

* code cleanup

* preselect line with nextDeparture

* add horizontal divider to improve legibility

* change LineFilterChip styling

* sort by lineType, then by lineName, animateScrollIntoView

* Show departure in minutes on single tap

also:
- replace `remember(time)` with `key(time)` where applicable to
  keep "in ... minutes" up to date
- only animate lineFilterChips into view once per card composition
- show old list for up to two lines
- disable departure list `onLongPress`
- ditch `detectDragGestures` since it does not do anything anyway...
  somehow scrolling the departure list will also scroll the search bar.

* set containerColor to secondary in lineFilterChip to improve legibility for white-ish primary colors

* More color rigamarole

* OCD code tweaks

* Don't use extension functions

* Split LocationItem into multiple subcomponents

* Adjust line colors

* Always use filter chips view for departures

* Limit departures to 8 per line, make list not scrollable

* Adjust spacing

* Add transition

* Improve line sorting

* Fix line chip spacing

* detectTabGestures -> combinedClickable

---------

Co-authored-by: MM20 <15646950+MM2-0@users.noreply.github.com>
This commit is contained in:
Christoph
2025-04-01 18:02:29 +02:00
committed by GitHub
co-authored by MM20
parent 3788eed61d
commit 67a5fd25de
7 changed files with 668 additions and 370 deletions
@@ -1,6 +1,7 @@
package de.mm20.launcher2.ui.ktx
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import hct.Hct
import kotlin.math.atan2
import kotlin.math.roundToInt
@@ -20,6 +21,14 @@ fun Color.Companion.hct(hue: Float, chroma: Float, tone: Float): Color {
return Color(hct.toInt())
}
fun Color.atTone(tone: Int): Color {
return Color(
Hct.fromInt(this.toArgb()).apply {
this.tone = tone.toDouble()
}.toInt()
)
}
val Color.hue: Float
get() {
val r = this.red / 255f
@@ -28,3 +37,5 @@ val Color.hue: Float
// sqrt(3)
return atan2(1.7320508f * (g - b), 2f * r - g - b)
}
fun android.graphics.Color.toComposeColor() = Color(this.toArgb())
File diff suppressed because it is too large Load Diff
@@ -6,7 +6,6 @@ import de.mm20.launcher2.plugin.PluginType
import de.mm20.launcher2.plugins.PluginService
import de.mm20.launcher2.preferences.search.LocationSearchSettings
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.stateIn
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject