Skip to content

Commit

Permalink
commonize options design
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed May 12, 2024
1 parent 39d46f3 commit 6880b0f
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,9 @@ fun MediaListStatus.stringRes(isManga: Boolean) = when (this) {
else -> SharedRes.strings.add
}

fun MediaListStatus.stringRes(type: MediaType) = this.stringRes(type == MediaType.MANGA)
fun MediaListStatus.stringRes(type: MediaType) = this.stringRes(type == MediaType.MANGA)

fun MediaType.stringRes() = when (this) {
MediaType.MANGA -> SharedRes.strings.manga
else -> SharedRes.strings.anime
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.maxkeppeker.sheets.core.models.base.Header
import com.maxkeppeker.sheets.core.models.base.IconSource
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.option.OptionDialog
import com.maxkeppeler.sheets.option.models.DisplayMode
Expand Down Expand Up @@ -56,6 +58,10 @@ fun CharacterSection(
),
config = OptionConfig(
mode = DisplayMode.LIST,
),
header = Header.Default(
icon = IconSource(imageVector = Icons.Filled.PersonPin),
title = stringResource(SharedRes.strings.char_language)
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.maxkeppeker.sheets.core.models.base.Header
import com.maxkeppeker.sheets.core.models.base.IconSource
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.option.OptionDialog
Expand Down Expand Up @@ -79,6 +80,13 @@ fun ColorSection(
config = OptionConfig(
mode = DisplayMode.GRID_VERTICAL,
gridColumns = 4
),
header = Header.Default(
icon = IconSource(
imageVector = Icons.Filled.Circle,
tint = MaterialTheme.colorScheme.primary
),
title = stringResource(SharedRes.strings.profile_color)
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.maxkeppeker.sheets.core.models.base.Header
import com.maxkeppeker.sheets.core.models.base.IconSource
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.option.OptionDialog
import com.maxkeppeler.sheets.option.models.DisplayMode
Expand Down Expand Up @@ -56,6 +58,10 @@ fun TitleSection(
),
config = OptionConfig(
mode = DisplayMode.LIST,
),
header = Header.Default(
icon = IconSource(imageVector = Icons.Rounded.Title),
title = stringResource(SharedRes.strings.title_language),
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ fun FABContent(
RatingDialog(
state = ratingState,
initialValue = rating,
type = type,
onRating = {
component.rate(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ import com.maxkeppeker.sheets.core.models.base.UseCaseState
import com.maxkeppeler.sheets.rating.models.RatingBody
import com.maxkeppeler.sheets.rating.models.RatingConfig
import com.maxkeppeler.sheets.rating.models.RatingSelection
import dev.datlag.aniflow.SharedRes
import dev.datlag.aniflow.anilist.type.MediaType
import dev.datlag.aniflow.common.stringRes
import dev.icerock.moko.resources.compose.stringResource
import io.github.aakira.napier.Napier

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun RatingDialog(
state: UseCaseState,
initialValue: Int,
type: MediaType,
onRating: (Int) -> Unit,
) {
com.maxkeppeler.sheets.rating.RatingDialog(
Expand All @@ -31,10 +36,12 @@ fun RatingDialog(
onRating(rating)
}
),
body = RatingBody.Custom(body = { }),
body = RatingBody.Default(
bodyText = stringResource(SharedRes.strings.rating_text, stringResource(type.stringRes()))
),
header = Header.Default(
icon = IconSource(imageVector = Icons.Rounded.Star),
title = "Rating"
title = stringResource(SharedRes.strings.rating)
)
)
}
4 changes: 4 additions & 0 deletions composeApp/src/commonMain/moko-resources/base/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,8 @@
<string name="polar">Polar</string>
<string name="patreon">Patreon</string>
<string name="sponsor">Sponsor</string>
<string name="rating">Rating</string>
<string name="rating_text">Rate this %s between 0-5</string>
<string name="anime">Anime</string>
<string name="manga">Manga</string>
</resources>

0 comments on commit 6880b0f

Please sign in to comment.