Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: some minor fixes for easier customization #359

Merged
merged 6 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.stadiamaps.ferrostar.composeui.formatting

import android.icu.util.ULocale
import java.time.format.FormatStyle
import java.util.Locale
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.toJavaLocalDateTime
Expand All @@ -11,12 +12,11 @@ interface DateTimeFormatter {

class EstimatedArrivalDateTimeFormatter(
private var localeOverride: ULocale? = null,
private val unitStyle: FormatStyle = FormatStyle.SHORT
) : DateTimeFormatter {
override fun format(dateTime: LocalDateTime): String {
val locale = localeOverride?.let { Locale(it.language, it.country) } ?: Locale.getDefault()
val formatter =
java.time.format.DateTimeFormatter.ofLocalizedTime(java.time.format.FormatStyle.SHORT)
.withLocale(locale)
val formatter = java.time.format.DateTimeFormatter.ofLocalizedTime(unitStyle).withLocale(locale)
return formatter.format(dateTime.toJavaLocalDateTime())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ interface NavigationViewModel {
* interface that is reused across navigation sessions will probably need to craft their own view
* model.
*/
class DefaultNavigationViewModel(
open class DefaultNavigationViewModel(
private val ferrostarCore: FerrostarCore,
private val annotationPublisher: AnnotationPublisher<*> = NoOpAnnotationPublisher()
) : ViewModel(), NavigationViewModel {
Expand Down
Loading