Skip to content

Commit

Permalink
Merge branch 'main' into feature/about-footer-links-icon-add-animatio…
Browse files Browse the repository at this point in the history
…n-scale
  • Loading branch information
kosenda authored Sep 7, 2024
2 parents 7480191 + 8cec73f commit 3d999ba
Show file tree
Hide file tree
Showing 22 changed files with 325 additions and 161 deletions.
4 changes: 2 additions & 2 deletions app-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ android {
buildConfig = true
}
defaultConfig {
versionCode = 4
versionName = "1.1.0"
versionCode = 6
versionName = "1.2.0"
}
signingConfigs {
create("dev") {
Expand Down
4 changes: 3 additions & 1 deletion app-ios/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ let package = Package(
dependencies: [
.tca,
.kmpClient,
.theme
.theme,
.model,
.commonComponents,
]
),
.testTarget(
Expand Down
23 changes: 20 additions & 3 deletions app-ios/Sources/SponsorFeature/SponsorReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,29 @@ public struct SponsorReducer : Sendable {
var platinums = [Sponsor]()
var golds = [Sponsor]()
var supporters = [Sponsor]()
var url: IdentifiableURL?

public init() { }
}

public enum Action : Sendable {
case onAppear
public enum Action : Sendable, BindableAction {
case binding(BindingAction<State>)
case response(Result<[Sponsor], any Error>)
case view(View)

public enum View: Sendable {
case onAppear
case sponsorTapped(URL)
}
}

public var body: some ReducerOf<Self> {
BindingReducer()
Reduce { state, action in
enum CancelID { case connection }

switch action {
case .onAppear:
case .view(.onAppear):
return .run { send in
do {
for try await sponsors in try sponsorsData.streamSponsors() {
Expand All @@ -39,6 +47,11 @@ public struct SponsorReducer : Sendable {
}
}
.cancellable(id: CancelID.connection)

case let .view(.sponsorTapped(url)):
state.url = IdentifiableURL(url)
return .none

case .response(.success(let sponsors)):
var platinums = [Sponsor]()
var golds = [Sponsor]()
Expand All @@ -59,9 +72,13 @@ public struct SponsorReducer : Sendable {
state.golds = golds
state.supporters = supporters
return .none

case .response(.failure(let error)):
print(error)
return .none

case .binding:
return .none
}
}
}
Expand Down
21 changes: 13 additions & 8 deletions app-ios/Sources/SponsorFeature/SponsorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import ComposableArchitecture
import SwiftUI
import Theme
import Model
import CommonComponents

public struct SponsorView: View {
private let store: StoreOf<SponsorReducer>
@State private var selectedSponsorData: Sponsor?
@Bindable private var store: StoreOf<SponsorReducer>

public init(store: StoreOf<SponsorReducer>) {
self.store = store
Expand Down Expand Up @@ -39,10 +39,14 @@ public struct SponsorView: View {
}
.background(AssetColors.Surface.surface.swiftUIColor)
.onAppear {
store.send(.onAppear)
store.send(.view(.onAppear))
}
.navigationBarTitleDisplayMode(.large)
.navigationTitle(String(localized: "Sponsor", bundle: .module))
.sheet(item: $store.url, content: { url in
SafariView(url: url.id)
.ignoresSafeArea()
})
}

@ViewBuilder
Expand All @@ -53,15 +57,16 @@ public struct SponsorView: View {
}
LazyVGrid(columns: gridItems, spacing: 12) {
ForEach(items) { item in
Button {
selectedSponsorData = item
} label: {
ZStack {
Color.white.clipShape(RoundedRectangle(cornerRadius: 12))
ZStack {
Color.white.clipShape(RoundedRectangle(cornerRadius: 12))
Button {
store.send(.view(.sponsorTapped(item.link)))
} label: {
AsyncImage(url: item.logo) {
$0.image?
.resizable()
.scaledToFit()
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
.frame(height: imageHeight)
.padding(.vertical, 6)
Expand Down
13 changes: 12 additions & 1 deletion app-ios/Tests/SponsorFeatureTests/SponsorFeatureTests.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import XCTest
import ComposableArchitecture
import Model
@testable import SponsorFeature

final class SponsorFeatureTests: XCTestCase {
Expand All @@ -20,7 +21,7 @@ final class SponsorFeatureTests: XCTestCase {
}
}
}
await store.send(.onAppear)
await store.send(.view(.onAppear))
await store.receive(\.response.success) {
$0.platinums = [
.init(id: "Hoge", logo: .init(string: "https://avatars.githubusercontent.com/u/10727543?s=200&v=4")!, link: .init(string: "https://2024.droidkaigi.jp/")!, plan: .platinum)
Expand All @@ -34,4 +35,14 @@ final class SponsorFeatureTests: XCTestCase {
}
}

@MainActor
func testSponsorTapped() async throws {
let url = URL(string: "https://github.com/DroidKaigi/conference-app-2024")!
let store = TestStore(initialState: SponsorReducer.State()) {
SponsorReducer()
}
await store.send(.view(.sponsorTapped(url))) {
$0.url = IdentifiableURL(url)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public fun SessionsAllResponse.toTimetable(): Timetable {
} else {
apiSession.i18nDesc.toMultiLangText()
},
message = apiSession.message?.toMultiLangText(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import io.github.droidkaigi.confsched.droidkaigiui.animation.LocalFavoriteAnimat
import io.github.droidkaigi.confsched.droidkaigiui.previewOverride
import io.github.droidkaigi.confsched.model.TimetableItem
import io.github.droidkaigi.confsched.model.TimetableItem.Session
import io.github.droidkaigi.confsched.model.TimetableItem.Special
import org.jetbrains.compose.resources.stringResource

const val TimetableItemCardBookmarkButtonTestTag = "TimetableItemCardBookmarkButton"
Expand Down Expand Up @@ -170,25 +171,27 @@ fun TimetableItemCard(
}
}
}
if (timetableItem is Session) {
timetableItem.message?.let {
Row(
modifier = Modifier
.padding(top = 8.dp)
.height(IntrinsicSize.Min),
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
Icon(
Icons.Filled.Info,
contentDescription = stringResource(DroidKaigiUiRes.string.image),
tint = MaterialTheme.colorScheme.error,
)
Text(
text = it.currentLangTitle,
fontSize = 16.sp,
color = MaterialTheme.colorScheme.error,
)
}

when (timetableItem) {
is Session -> timetableItem.message
is Special -> timetableItem.message
}?.let {
Row(
modifier = Modifier
.padding(top = 8.dp)
.height(IntrinsicSize.Min),
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
Icon(
Icons.Filled.Info,
contentDescription = stringResource(DroidKaigiUiRes.string.image),
tint = MaterialTheme.colorScheme.error,
)
Text(
text = it.currentLangTitle,
fontSize = 16.sp,
color = MaterialTheme.colorScheme.error,
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import kotlin.coroutines.cancellation.CancellationException

interface ContributorsRepository {

@Throws(CancellationException::class)
@Throws(AppError::class, CancellationException::class)
suspend fun refresh()

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import kotlin.coroutines.cancellation.CancellationException

interface EventMapRepository {

@Throws(CancellationException::class)
@Throws(AppError::class, CancellationException::class)
suspend fun refresh()

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import kotlin.coroutines.cancellation.CancellationException
public interface SponsorsRepository {
public fun getSponsorStream(): Flow<PersistentList<Sponsor>>

@Throws(CancellationException::class)
@Throws(AppError::class, CancellationException::class)
public suspend fun refresh()

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface StaffRepository {

public fun staffs(): Flow<PersistentList<Staff>>

@Throws(CancellationException::class)
@Throws(AppError::class, CancellationException::class)
public suspend fun refresh()

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public fun Timetable.Companion.fake(): Timetable {
enTitle = "This is a description\nThis is a description\nThis is a description\n" +
"This is a description\nThis is a description\nThis is a description\n",
),
message = null,
),
)
for (day in -1..1) {
Expand Down Expand Up @@ -229,6 +230,10 @@ public fun Timetable.Companion.fake(): Timetable {
enTitle = "This is a description\nThis is a description\nThis is a description\n" +
"This is a description\nThis is a description\nThis is a description\n",
),
message = MultiLangText(
jaTitle = "このセッションは事情により中止となりました",
enTitle = "This session has been cancelled due to circumstances.",
),
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public sealed class TimetableItem {
override val levels: PersistentList<String>,
override val speakers: PersistentList<TimetableSpeaker>,
val description: MultiLangText,
val message: MultiLangText?,
) : TimetableItem()

private val startsDateString: String by lazy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ data class TimetableRoom(
val TimetableRoom.nameAndFloor: String
get() {
val basementFloorString = MultiLangText(jaTitle = "地下1階", enTitle = "B1F")
val floor1FString = MultiLangText(jaTitle = "1階", enTitle = "1F")
val floor = when (type) {
RoomType.RoomF -> basementFloorString.currentLangTitle
RoomType.RoomG -> basementFloorString.currentLangTitle
RoomType.RoomF -> floor1FString.currentLangTitle
RoomType.RoomG -> floor1FString.currentLangTitle
RoomType.RoomH -> basementFloorString.currentLangTitle
RoomType.RoomI -> "1F"
RoomType.RoomJ -> "1F"
RoomType.RoomI -> basementFloorString.currentLangTitle
RoomType.RoomJ -> basementFloorString.currentLangTitle
// Assume the room on the first day.
RoomType.RoomIJ -> "1F"
RoomType.RoomIJ -> basementFloorString.currentLangTitle
}
return "${name.currentLangTitle} ($floor)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Surface
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
Expand All @@ -24,12 +25,14 @@ import io.github.droidkaigi.confsched.about.section.AboutDroidKaigiDetail
import io.github.droidkaigi.confsched.about.section.AboutFooterLinks
import io.github.droidkaigi.confsched.about.section.aboutCredits
import io.github.droidkaigi.confsched.about.section.aboutOthers
import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme
import io.github.droidkaigi.confsched.droidkaigiui.component.AnimatedTextTopAppBar
import io.github.droidkaigi.confsched.model.AboutItem
import io.github.droidkaigi.confsched.model.AboutItem.Medium
import io.github.droidkaigi.confsched.model.AboutItem.X
import io.github.droidkaigi.confsched.model.AboutItem.YouTube
import org.jetbrains.compose.resources.stringResource
import org.jetbrains.compose.ui.tooling.preview.Preview

const val aboutScreenRoute = "about"

Expand Down Expand Up @@ -65,16 +68,34 @@ data class AboutUiState(
val versionName: String,
)

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AboutScreen(
onAboutItemClick: (AboutItem) -> Unit,
modifier: Modifier = Modifier,
contentPadding: PaddingValues = PaddingValues(),
onAboutItemClick: (AboutItem) -> Unit,
) {
val uiState = aboutScreenPresenter()
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
val snackbarHostState = remember { SnackbarHostState() }

AboutScreen(
uiState = uiState,
snackbarHostState = snackbarHostState,
contentPadding = contentPadding,
onAboutItemClick = onAboutItemClick,
modifier = modifier,
)
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AboutScreen(
uiState: AboutUiState,
snackbarHostState: SnackbarHostState,
onAboutItemClick: (AboutItem) -> Unit,
contentPadding: PaddingValues,
modifier: Modifier = Modifier,
) {
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
val layoutDirection = LocalLayoutDirection.current
val lazyListState = rememberLazyListState()

Expand Down Expand Up @@ -151,3 +172,20 @@ fun AboutScreen(
}
}
}

@Preview
@Composable
fun AboutScreenPreview() {
KaigiTheme {
Surface {
AboutScreen(
uiState = AboutUiState(
versionName = "1.0",
),
snackbarHostState = SnackbarHostState(),
contentPadding = PaddingValues(),
onAboutItemClick = {},
)
}
}
}
Loading

0 comments on commit 3d999ba

Please sign in to comment.