-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #982 from raseln/raseln/implement_contributors_cou…
…nt_ui [ContributorsScreen] Display the total number of persons in ContributorsScreen
- Loading branch information
Showing
10 changed files
with
193 additions
and
1 deletion.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
app-ios/Sources/ContributorFeature/ContributorsCountItem.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import SwiftUI | ||
import Theme | ||
|
||
struct ContributorsCountItem: View { | ||
let totalContributor: Int | ||
let duration: Double = 1.0 | ||
@State private var tracker = 0 | ||
|
||
var body: some View { | ||
VStack(alignment: .leading) { | ||
|
||
Text(String(localized: "Total", bundle: .module)) | ||
.textStyle(.titleMedium) | ||
.foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor) | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
|
||
HStack { | ||
Text("\(tracker)") | ||
.textStyle(.headlineLarge) | ||
.foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor) | ||
.onAppear() { | ||
animate() | ||
} | ||
|
||
Text(String(localized: "Person", bundle: .module)) | ||
.textStyle(.headlineSmall) | ||
.foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor) | ||
} | ||
|
||
Spacer() | ||
.frame(height: 16) | ||
Divider() | ||
} | ||
} | ||
|
||
func animate() { | ||
let interval = duration / Double(totalContributor) | ||
Timer.scheduledTimer(withTimeInterval: interval, repeats: true) { time in | ||
tracker += 1 | ||
if tracker == totalContributor { | ||
time.invalidate() | ||
} | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
ContributorsCountItem(totalContributor: 112) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
feature/contributors/src/commonMain/composeResources/values-ja/strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="contributor_title">コントリビューター</string> | ||
<string name="contributor_total">合計</string> | ||
<string name="contributor_person">人</string> | ||
</resources> |
2 changes: 2 additions & 0 deletions
2
feature/contributors/src/commonMain/composeResources/values/strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="contributor_title">Contributor</string> | ||
<string name="contributor_total">Total</string> | ||
<string name="contributor_person">persons</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...ain/kotlin/io/github/droidkaigi/confsched/contributors/component/ContributorsCountItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package io.github.droidkaigi.confsched.contributors.component | ||
|
||
import androidx.compose.animation.core.EaseOutQuart | ||
import androidx.compose.animation.core.animateIntAsState | ||
import androidx.compose.animation.core.tween | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.HorizontalDivider | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import conference_app_2024.feature.contributors.generated.resources.contributor_person | ||
import conference_app_2024.feature.contributors.generated.resources.contributor_total | ||
import io.github.droidkaigi.confsched.contributors.ContributorsRes | ||
import org.jetbrains.compose.resources.stringResource | ||
|
||
@Composable | ||
internal fun ContributorsCountItem( | ||
totalContributor: Int, | ||
modifier: Modifier = Modifier, | ||
) { | ||
var targetValue by remember { mutableStateOf(0) } | ||
val animatedTotalContributor by animateIntAsState( | ||
targetValue = targetValue, | ||
animationSpec = tween( | ||
delayMillis = 300, | ||
durationMillis = 1000, | ||
easing = EaseOutQuart, | ||
), | ||
) | ||
LaunchedEffect(totalContributor) { | ||
targetValue = totalContributor | ||
} | ||
Column( | ||
modifier = modifier | ||
.padding(horizontal = 16.dp, vertical = 10.dp), | ||
) { | ||
Text( | ||
text = stringResource(ContributorsRes.string.contributor_total), | ||
style = MaterialTheme.typography.titleMedium, | ||
) | ||
Row( | ||
horizontalArrangement = Arrangement.spacedBy(6.dp), | ||
verticalAlignment = Alignment.Bottom, | ||
) { | ||
Text( | ||
text = "$animatedTotalContributor", | ||
style = MaterialTheme.typography.headlineLarge, | ||
) | ||
Text( | ||
text = stringResource(ContributorsRes.string.contributor_person), | ||
style = MaterialTheme.typography.headlineSmall, | ||
) | ||
} | ||
Spacer(modifier = Modifier.height(16.dp)) | ||
HorizontalDivider() | ||
} | ||
} |