-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Assisted Injection param in HiltViewModel (#67)
- Loading branch information
Showing
5 changed files
with
74 additions
and
17 deletions.
There are no files selected for viewing
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
8 changes: 8 additions & 0 deletions
8
app/src/main/kotlin/io/github/b4tchkn/konnpass/state/event/EventStateViewModelFactory.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,8 @@ | ||
package io.github.b4tchkn.konnpass.state.event | ||
|
||
import dagger.assisted.AssistedFactory | ||
|
||
@AssistedFactory | ||
interface EventStateViewModelFactory { | ||
fun create(param: EventStateViewModelParam): EventStateViewModel | ||
} |
46 changes: 43 additions & 3 deletions
46
app/src/main/kotlin/io/github/b4tchkn/konnpass/ui/screen/EventDetailScreen.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 |
---|---|---|
@@ -1,17 +1,57 @@ | ||
package io.github.b4tchkn.konnpass.ui.screen | ||
|
||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.automirrored.filled.ArrowBack | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TopAppBar | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.navigation.NavController | ||
import io.github.b4tchkn.konnpass.model.EventModel | ||
|
||
const val eventDetailScreenParamId = "eventId" | ||
const val eventDetailScreenRoute = "event_detail/{$eventDetailScreenParamId}" | ||
|
||
fun NavController.navigateToEventDetailScreen( | ||
event: EventModel, | ||
) { | ||
navigate( | ||
eventDetailScreenRoute.replace( | ||
"{$eventDetailScreenParamId}", | ||
event.eventId.toString(), | ||
), | ||
) | ||
} | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun EventDetailScreen(data: String?) { | ||
Scaffold { | ||
fun EventDetailScreen( | ||
eventId: String?, | ||
onBackPressed: () -> Unit, | ||
) { | ||
Scaffold( | ||
topBar = { | ||
TopAppBar( | ||
title = { Text(text = eventId ?: "") }, | ||
navigationIcon = { | ||
IconButton(onClick = onBackPressed) { | ||
Icon( | ||
imageVector = Icons.AutoMirrored.Filled.ArrowBack, | ||
contentDescription = "もどる", | ||
) | ||
} | ||
}, | ||
) | ||
}, | ||
) { | ||
Text( | ||
modifier = Modifier.padding(it), | ||
text = data ?: "None", | ||
text = eventId ?: "None", | ||
) | ||
} | ||
} |
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