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
@Composable | |
fun SimpleTweetBox( | |
tweet: Tweet, | |
onClick: () -> Unit | |
) { | |
Box( // ... | |
) { | |
val user = tweet.user ?: "" | |
val imageUrl: String = tweet.images[0] | |
Column( // ... |
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
@Composable | |
fun SimpleTweetBox( | |
tweet: Tweet, | |
onClick: () -> Unit | |
) { | |
Box( | |
modifier = Modifier | |
.border( | |
width = 1.dp, | |
color = Color.LightGray, |
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
@Composable | |
fun StateUIValue(uiState: TweetsUIState) { | |
when (uiState) { | |
is TweetsUIState.ListResultsUIState -> TweetList(tweets = uiState.tweets) | |
is TweetsUIState.LoadingUIState -> CenteredText(msg = stringResource(R.string.loading_feed)) | |
is TweetsUIState.EmptyUIState -> CenteredText(msg = stringResource(R.string.query, uiState.query)) | |
is TweetsUIState.ErrorUIState -> CenteredText(msg = ”Error happened: $uiState.msg”) | |
is TweetsUIState.InitialIdleUIState -> TopText() | |
} | |
} |
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
@Composable | |
fun TweetBox(tweet: Tweet, onClick: () -> Unit ) { | |
Box( | |
modifier = Modifier | |
.border( | |
width = 1.dp, | |
color = Color.LightGray, | |
shape = RoundedCornerShape(16.dp) | |
) | |
.fillMaxWidth() |
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
@ExperimentalFoundationApi | |
@Composable | |
@Preview | |
fun TweetsList(tweets: List<Tweet>) { | |
LazyVerticalGrid( | |
modifier = Modifier.fillMaxWidth(), | |
cells = GridCells.Fixed(2) | |
){ | |
items( | |
count = tweets.size, |
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
@ActivityScope | |
class SearchUIStateHandler @Inject constructor() { | |
// ... State UI code | |
@Composable | |
fun StateUIValue(uiState: TweetsUIState) { | |
when (uiState) { | |
is TweetsUIState.ListResultsUIState -> TweetsList(tweets = uiState.tweets) | |
// other UI states | |
} | |
} |
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
@ActivityScope | |
class SearchUIStateHandler @Inject constructor() { | |
private var composeView: ComposeView? = null | |
private lateinit var stateFlow: StateFlow<TweetsUIState> | |
fun initStateFlowAndViews(stateFlowUI: StateFlow<TweetsUIState>) { | |
stateFlow = stateFlowUI | |
composeView?.setContent { | |
TweetsWithSearchTheme { |
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
public class TweetsListFragmentUI extends BaseUI { | |
// SearchComposablesUI is renamed to SearchUIStateHandler | |
@Inject SearchUIStateHandler searchUIStateHandler; | |
@Inject SearchViewDelegate viewDelegate; | |
// Remove SearchStateHandler instance | |
public void initStateFlowAndViews() { | |
// just needs the dependency of the StateFlow | |
searchUIStateHandler.initStateFlowAndViews(viewDelegate.getStateFlow()); | |
} |
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
@Composable | |
fun StatesUI(uiState: TweetsUIState) { | |
when (uiState) { | |
is TweetsUIState.XXXXXState -> // TODO ... | |
} | |
} |
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
@ActivityScope | |
class SearchComposablesUI @Inject constructor() { | |
private var composeView: ComposeView? = null | |
private var activity: SearchTweetActivity? = null | |
fun setComposeView(composeView: ComposeView, activity: SearchTweetActivity) { | |
this.composeView = composeView | |
this.activity = activity | |
} |
NewerOlder