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

Fixed the session subtitle on the agenda view #222

Merged
merged 1 commit into from
Mar 28, 2024
Merged
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
Expand Up @@ -27,8 +27,12 @@ import androidx.compose.ui.unit.dp
import com.androidmakers.ui.common.EmojiUtils
import com.androidmakers.ui.model.UISession
import com.androidmakers.ui.theme.AMColor
import fr.androidmakers.domain.model.Session
import kotlinx.datetime.Instant
import kotlinx.datetime.toInstant
import org.jetbrains.compose.ui.tooling.preview.Preview
import kotlin.time.Duration
import kotlin.time.Duration.Companion.hours

@Composable
private fun maybeClickable(uiSession: UISession, onSessionClicked: ((UISession) -> Unit)): Modifier {
Expand Down Expand Up @@ -89,7 +93,7 @@ fun AgendaRow(
}

Text(
text = "", //uiSession.subtitle(LocalContext.current),
text = uiSession.subtitle(),
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier.padding(top = 4.dp)
)
Expand Down Expand Up @@ -127,21 +131,29 @@ fun AgendaRow(
},
)
}
/*
private fun UISession.subtitle(context: Context) = buildString {
val millis = endDate - startDate
val duration = TimeUtils.formatDuration(
context = context,
millis
)

append(duration)
private fun UISession.subtitle() = buildString {
append(formattedDuration())
append(" / $room")
val emoji = EmojiUtils.getLanguageInEmoji(language)
if (emoji != null) {
append(" / $emoji")
}
}*/
}

fun UISession.formattedDuration(): String {
val duration = endDate - startDate

return buildString {
if (duration.inWholeHours > 0) {
append(duration.inWholeHours)
append("h")
}

append((duration - duration.inWholeHours.hours).inWholeMinutes)
append("min")
}
}

@Preview
@Composable
Expand Down
Loading