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: Duplication #136

Merged
merged 2 commits into from
Sep 19, 2023
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
Expand Up @@ -2,6 +2,7 @@ package movie.metropolis.app.di

import dagger.Module
import dagger.Provides
import dagger.Reusable
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityRetainedComponent
import movie.metropolis.app.presentation.booking.BookingsFacade
Expand All @@ -14,6 +15,7 @@ import movie.wear.WearService
class FacadeModule {

@Provides
@Reusable
fun booking(
service: WearService
): BookingsFacade {
Expand Down
18 changes: 16 additions & 2 deletions app/src/main/java/movie/metropolis/app/di/FacadeModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package movie.metropolis.app.di

import dagger.Module
import dagger.Provides
import dagger.Reusable
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityRetainedComponent
import movie.calendar.CalendarList
Expand Down Expand Up @@ -75,6 +76,7 @@ import movie.rating.MetadataProvider
class FacadeModule {

@Provides
@Reusable
fun booking(
booking: UserBookingFeature,
share: TicketShareRegistry,
Expand All @@ -90,6 +92,7 @@ class FacadeModule {
}

@Provides
@Reusable
fun cinemas(event: EventCinemaFeature): CinemasFacade {
var facade: CinemasFacade
facade = CinemasFacadeFromFeature(event)
Expand All @@ -98,10 +101,11 @@ class FacadeModule {
}

@Provides
@Reusable
fun cinema(
cinemas: EventCinemaFeature,
showings: EventShowingsFeature.Factory
) = CinemaFacade.Factory {
): CinemaFacade.Factory = CinemaFacade.Factory {
var facade: CinemaFacade
facade = CinemaFacadeFromFeature(it, cinemas, showings)
facade = CinemaFacadeRecover(facade)
Expand All @@ -110,13 +114,14 @@ class FacadeModule {
}

@Provides
@Reusable
fun movie(
showings: EventShowingsFeature.Factory,
detail: EventDetailFeature,
favorite: FavoriteFeature,
analyzer: ImageAnalyzer,
rating: MetadataProvider
) = MovieFacade.Factory {
): MovieFacade.Factory = MovieFacade.Factory {
var facade: MovieFacade
facade = MovieFacadeFromFeature(it, showings, detail, favorite)
facade = MovieFacadePoster(facade, analyzer)
Expand All @@ -128,6 +133,7 @@ class FacadeModule {
}

@Provides
@Reusable
fun listing(
preview: EventPreviewFeature.Factory,
favorite: FavoriteFeature,
Expand All @@ -152,6 +158,7 @@ class FacadeModule {
}

@Provides
@Reusable
fun profile(
cinema: EventCinemaFeature,
user: UserDataFeature,
Expand All @@ -165,6 +172,7 @@ class FacadeModule {
}

@Provides
@Reusable
fun login(
user: UserCredentialFeature,
setup: SetupFeature,
Expand All @@ -176,6 +184,7 @@ class FacadeModule {
}

@Provides
@Reusable
fun order(
user: UserCredentialFeature,
booking: BookingFacade
Expand All @@ -188,6 +197,7 @@ class FacadeModule {
}

@Provides
@Reusable
fun settings(
prefs: EventPreference,
calendars: CalendarList
Expand All @@ -200,11 +210,13 @@ class FacadeModule {
}

@Provides
@Reusable
fun home(user: UserCredentialFeature): HomeFacade {
return HomeFacadeFromFeature(user)
}

@Provides
@Reusable
fun share(
share: TicketShareRegistry,
user: UserBookingFeature
Expand All @@ -218,6 +230,7 @@ class FacadeModule {
}

@Provides
@Reusable
fun setup(
feature: SetupFeature
): SetupFacade {
Expand All @@ -227,6 +240,7 @@ class FacadeModule {
}

@Provides
@Reusable
fun orderComplete(
facade: BillingFacade
): OrderCompleteFacade {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.Reusable
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
Expand All @@ -20,6 +21,7 @@ interface NotificationModule {
companion object {

@Provides
@Reusable
fun provider(
@ApplicationContext
context: Context
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/movie/metropolis/app/di/PlatformModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package movie.metropolis.app.di
import android.content.Context
import dagger.Module
import dagger.Provides
import dagger.Reusable
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityRetainedComponent
import dagger.hilt.android.qualifiers.ApplicationContext
Expand All @@ -14,6 +15,7 @@ import movie.metropolis.app.feature.billing.BillingFacadeImpl
class PlatformModule {

@Provides
@Reusable
fun billing(
@ApplicationContext context: Context
): BillingFacade {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ import movie.metropolis.app.screen.booking.component.TicketItemEmpty
import movie.metropolis.app.screen.booking.component.TicketItemError
import movie.metropolis.app.screen.booking.component.TicketItemExpired
import movie.metropolis.app.screen.booking.component.TicketItemLoading
import movie.metropolis.app.screen.home.component.HomeScreenToolbar
import movie.style.AppButton
import movie.style.state.ImmutableList
import movie.style.theme.Theme

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun BookingScreen(
padding: PaddingValues,
behavior: TopAppBarScrollBehavior,
onMovieClick: (String) -> Unit,
profileIcon: @Composable () -> Unit,
viewModel: BookingViewModel = hiltViewModel(),
actions: ActivityActions = LocalActivityActions.current
) {
Expand All @@ -43,19 +44,18 @@ fun BookingScreen(
val scope = rememberCoroutineScope()
var isReaderActive by rememberSaveable { mutableStateOf(false) }
BookingScreenContent(
padding = padding,
behavior = behavior,
active = active,
expired = expired,
profileIcon = profileIcon,
onRefreshClick = viewModel::refresh,
onMovieClick = onMovieClick,
onShareClick = {
scope.launch {
actions.actionShare(viewModel.saveAsFile(it))
}
},
onCameraClick = { isReaderActive = true }
)
}
) { isReaderActive = true }
ReaderDialog(
isVisible = isReaderActive,
onVisibilityChanged = { isReaderActive = it },
Expand All @@ -66,15 +66,23 @@ fun BookingScreen(
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
@Composable
private fun BookingScreenContent(
padding: PaddingValues,
active: Loadable<ImmutableList<BookingView.Active>>,
expired: Loadable<ImmutableList<BookingView.Expired>>,
behavior: TopAppBarScrollBehavior,
profileIcon: @Composable () -> Unit,
onRefreshClick: () -> Unit = {},
onMovieClick: (String) -> Unit = {},
onShareClick: (BookingView.Active) -> Unit = {},
onCameraClick: () -> Unit = {}
) {
) = Scaffold(
topBar = {
HomeScreenToolbar(
profileIcon = profileIcon,
behavior = behavior,
title = { Text(stringResource(id = R.string.tickets)) }
)
}
) { padding ->
Column(
modifier = Modifier
.nestedScroll(behavior.nestedScrollConnection)
Expand Down Expand Up @@ -159,10 +167,10 @@ private fun BookingScreenContent(
private fun Preview() {
Theme {
BookingScreenContent(
padding = PaddingValues(),
active = Loadable.loading(),
expired = Loadable.loading(),
behavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()
behavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(),
profileIcon = {}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.*
import androidx.compose.ui.input.nestedscroll.*
import androidx.compose.ui.res.*
import androidx.compose.ui.tooling.preview.*
import androidx.compose.ui.tooling.preview.datasource.*
import androidx.compose.ui.unit.*
import androidx.hilt.navigation.compose.hiltViewModel
import movie.metropolis.app.R
import movie.metropolis.app.feature.location.rememberLocation
import movie.metropolis.app.model.CinemaView
import movie.metropolis.app.presentation.Loadable
Expand All @@ -25,14 +27,15 @@ import movie.metropolis.app.screen.cinema.component.CinemaItemError
import movie.metropolis.app.screen.cinema.component.CinemaItemLoading
import movie.metropolis.app.screen.cinema.component.CinemaViewParameter
import movie.metropolis.app.screen.detail.plus
import movie.metropolis.app.screen.home.component.HomeScreenToolbar
import movie.style.layout.PreviewLayout

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun CinemasScreen(
padding: PaddingValues,
onClickCinema: (String) -> Unit,
state: LazyListState,
profileIcon: @Composable () -> Unit,
behavior: TopAppBarScrollBehavior,
viewModel: CinemasViewModel = hiltViewModel()
) {
Expand All @@ -44,7 +47,7 @@ fun CinemasScreen(
CinemasScreen(
items = items,
behavior = behavior,
padding = padding,
profileIcon = profileIcon,
onClickCinema = onClickCinema,
state = state
)
Expand All @@ -54,11 +57,19 @@ fun CinemasScreen(
@Composable
private fun CinemasScreen(
items: Loadable<List<CinemaView>>,
padding: PaddingValues,
behavior: TopAppBarScrollBehavior,
profileIcon: @Composable () -> Unit,
onClickCinema: (String) -> Unit,
state: LazyListState = rememberLazyListState()
) {
) = Scaffold(
topBar = {
HomeScreenToolbar(
profileIcon = profileIcon,
behavior = behavior,
title = { Text(stringResource(id = R.string.cinemas)) }
)
}
) { padding ->
LazyColumn(
modifier = Modifier
.nestedScroll(behavior.nestedScrollConnection)
Expand Down Expand Up @@ -100,7 +111,7 @@ private fun CinemaItemPreview(
) = PreviewLayout(padding = PaddingValues()) {
CinemasScreen(
items = items,
padding = PaddingValues(),
profileIcon = {},
behavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(),
onClickCinema = {}
)
Expand Down
Loading