mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 22:23:39 +00:00
Add EmptyView Previews to HomeActivity
This commit is contained in:
parent
f3d90e3adb
commit
f0e09b5607
@ -171,7 +171,7 @@ fun EnterAccountId(
|
||||
modifier = Modifier
|
||||
.animateContentSize()
|
||||
.contentDescription(R.string.AccessibilityId_help_desk_link)
|
||||
// .padding(horizontal = LocalDimensions.current.marginMedium)
|
||||
.padding(horizontal = LocalDimensions.current.marginMedium)
|
||||
.fillMaxWidth(),
|
||||
) { onHelp() }
|
||||
|
||||
|
@ -107,6 +107,7 @@ private fun InviteFriend(
|
||||
color = LocalColors.current.textSecondary,
|
||||
modifier = Modifier.padding(horizontal = 8.dp)
|
||||
)
|
||||
|
||||
Row(horizontalArrangement = spacedBy(20.dp)) {
|
||||
SlimOutlineButton(
|
||||
stringResource(R.string.share),
|
||||
|
@ -45,16 +45,16 @@ class NewConversationFragment : BottomSheetDialogFragment(), NewConversationDele
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog =
|
||||
BottomSheetDialog(requireContext(), R.style.Theme_Session_BottomSheet).apply {
|
||||
setOnShowListener { _ ->
|
||||
findViewById<View>(com.google.android.material.R.id.design_bottom_sheet)?.let {
|
||||
it.modifyLayoutParams<LayoutParams> { height = defaultPeekHeight }
|
||||
BottomSheetBehavior.from(it).apply {
|
||||
skipCollapsed = true
|
||||
state = BottomSheetBehavior.STATE_EXPANDED
|
||||
}
|
||||
findViewById<View>(com.google.android.material.R.id.design_bottom_sheet)?.apply {
|
||||
modifyLayoutParams<LayoutParams> { height = defaultPeekHeight }
|
||||
}?.let { BottomSheetBehavior.from(it) }?.apply {
|
||||
skipCollapsed = true
|
||||
state = BottomSheetBehavior.STATE_EXPANDED
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onNewMessageSelected() {
|
||||
replaceFragment(NewMessageFragment().also { it.delegate = this })
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||
import org.session.libsession.messaging.contacts.Contact
|
||||
import org.session.libsession.messaging.jobs.JobQueue
|
||||
import org.session.libsession.messaging.sending_receiving.MessageSender
|
||||
import org.session.libsession.snode.SnodeAPI
|
||||
@ -207,7 +206,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
// Set up seed reminder view
|
||||
lifecycleScope.launchWhenStarted {
|
||||
binding.seedReminderView.setThemedContent {
|
||||
if (!textSecurePreferences.getHasViewedSeed()) SeedReminder()
|
||||
if (!textSecurePreferences.getHasViewedSeed()) SeedReminder { start<RecoveryPasswordActivity>() }
|
||||
}
|
||||
}
|
||||
// Set up recycler view
|
||||
@ -361,104 +360,6 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewMessageDetails(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
) {
|
||||
PreviewTheme(colors) {
|
||||
SeedReminder()
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SeedReminder() {
|
||||
Column {
|
||||
// Color Strip
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.height(4.dp)
|
||||
.background(LocalColors.current.primary)
|
||||
)
|
||||
Row(
|
||||
Modifier
|
||||
.background(LocalColors.current.backgroundSecondary)
|
||||
.padding(
|
||||
horizontal = LocalDimensions.current.marginSmall,
|
||||
vertical = LocalDimensions.current.marginExtraSmall
|
||||
)
|
||||
) {
|
||||
Column(Modifier.weight(1f)) {
|
||||
Row {
|
||||
Text(
|
||||
stringResource(R.string.save_your_recovery_password),
|
||||
style = h8
|
||||
)
|
||||
Spacer(Modifier.requiredWidth(LocalDimensions.current.itemSpacingExtraSmall))
|
||||
SessionShieldIcon()
|
||||
}
|
||||
Text(
|
||||
stringResource(R.string.save_your_recovery_password_to_make_sure_you_don_t_lose_access_to_your_account),
|
||||
style = small
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.width(LocalDimensions.current.marginExtraExtraSmall))
|
||||
SlimOutlineButton(
|
||||
text = stringResource(R.string.continue_2),
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterVertically)
|
||||
.contentDescription(R.string.AccessibilityId_reveal_recovery_phrase_button),
|
||||
onClick = { start<RecoveryPasswordActivity>() }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun EmptyView(newAccount: Boolean) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 50.dp)
|
||||
.padding(bottom = 12.dp)
|
||||
) {
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
Icon(
|
||||
painter = painterResource(id = if (newAccount) R.drawable.emoji_tada_large else R.drawable.ic_logo_large),
|
||||
contentDescription = null,
|
||||
tint = Color.Unspecified
|
||||
)
|
||||
if (newAccount) {
|
||||
Text(
|
||||
stringResource(R.string.onboardingAccountCreated),
|
||||
style = h4,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Text(
|
||||
stringResource(R.string.welcome_to_session),
|
||||
style = base,
|
||||
color = LocalColors.current.primary,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
}
|
||||
|
||||
Divider(modifier = Modifier.padding(vertical = LocalDimensions.current.marginExtraSmall))
|
||||
|
||||
Text(
|
||||
stringResource(R.string.conversationsNone),
|
||||
style = h8,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.padding(bottom = 12.dp))
|
||||
Text(
|
||||
stringResource(R.string.onboardingHitThePlusButton),
|
||||
style = small,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Spacer(modifier = Modifier.weight(2f))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInputFocusChanged(hasFocus: Boolean) {
|
||||
setSearchShown(hasFocus || binding.globalSearchInputLayout.query.value.isNotEmpty())
|
||||
}
|
||||
@ -773,9 +674,120 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
// endregion
|
||||
}
|
||||
|
||||
data class NameIdContact(val name: String?, val id: String, val contact: Contact): Comparable<NameIdContact> {
|
||||
override fun compareTo(other: NameIdContact): Int = comparator.compare(this, other)
|
||||
companion object {
|
||||
val comparator = compareBy<NameIdContact>({ it.name }, { it.id })
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewSeedReminder(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
) {
|
||||
PreviewTheme(colors) {
|
||||
SeedReminder {}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SeedReminder(startRecoveryPasswordActivity: () -> Unit) {
|
||||
Column {
|
||||
// Color Strip
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.height(4.dp)
|
||||
.background(LocalColors.current.primary)
|
||||
)
|
||||
Row(
|
||||
Modifier
|
||||
.background(LocalColors.current.backgroundSecondary)
|
||||
.padding(
|
||||
horizontal = LocalDimensions.current.marginSmall,
|
||||
vertical = LocalDimensions.current.marginExtraSmall
|
||||
)
|
||||
) {
|
||||
Column(Modifier.weight(1f)) {
|
||||
Row {
|
||||
Text(
|
||||
stringResource(R.string.save_your_recovery_password),
|
||||
style = h8
|
||||
)
|
||||
Spacer(Modifier.requiredWidth(LocalDimensions.current.itemSpacingExtraSmall))
|
||||
SessionShieldIcon()
|
||||
}
|
||||
Text(
|
||||
stringResource(R.string.save_your_recovery_password_to_make_sure_you_don_t_lose_access_to_your_account),
|
||||
style = small
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.width(LocalDimensions.current.marginExtraExtraSmall))
|
||||
SlimOutlineButton(
|
||||
text = stringResource(R.string.continue_2),
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterVertically)
|
||||
.contentDescription(R.string.AccessibilityId_reveal_recovery_phrase_button),
|
||||
onClick = { startRecoveryPasswordActivity() }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewEmptyView(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
) {
|
||||
PreviewTheme(colors) {
|
||||
EmptyView(newAccount = false)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewEmptyViewNew(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
) {
|
||||
PreviewTheme(colors) {
|
||||
EmptyView(newAccount = true)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun EmptyView(newAccount: Boolean) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 50.dp)
|
||||
.padding(bottom = 12.dp)
|
||||
) {
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
Icon(
|
||||
painter = painterResource(id = if (newAccount) R.drawable.emoji_tada_large else R.drawable.ic_logo_large),
|
||||
contentDescription = null,
|
||||
tint = Color.Unspecified
|
||||
)
|
||||
if (newAccount) {
|
||||
Text(
|
||||
stringResource(R.string.onboardingAccountCreated),
|
||||
style = h4,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Text(
|
||||
stringResource(R.string.welcome_to_session),
|
||||
style = base,
|
||||
color = LocalColors.current.primary,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
}
|
||||
|
||||
Divider(modifier = Modifier.padding(vertical = LocalDimensions.current.marginExtraSmall))
|
||||
|
||||
Text(
|
||||
stringResource(R.string.conversationsNone),
|
||||
style = h8,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.padding(bottom = 12.dp))
|
||||
Text(
|
||||
stringResource(R.string.onboardingHitThePlusButton),
|
||||
style = small,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Spacer(modifier = Modifier.weight(2f))
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ data class ThemeState (
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <reified T: Activity> Activity.show() = Intent(this, T::class.java).also(::startActivity).also { overridePendingTransition(R.anim.slide_from_bottom, R.anim.fade_scale_out) }
|
||||
inline fun <reified T: Activity> Activity.push() = Intent(this, T::class.java).also(::startActivity).also { overridePendingTransition(R.anim.slide_from_right, R.anim.fade_scale_out) }
|
||||
inline fun <reified T: Activity> Context.start() = Intent(this, T::class.java).also(::startActivity)
|
||||
inline fun <reified T: Activity> Context.start(modify: Intent.() -> Unit) = Intent(this, T::class.java).also(modify).also(::startActivity)
|
||||
inline fun <reified T: Activity> Activity.show() = Intent(this, T::class.java).also(::startActivity).let { overridePendingTransition(R.anim.slide_from_bottom, R.anim.fade_scale_out) }
|
||||
inline fun <reified T: Activity> Activity.push() = Intent(this, T::class.java).also(::startActivity).let { overridePendingTransition(R.anim.slide_from_right, R.anim.fade_scale_out) }
|
||||
inline fun <reified T: Activity> Context.start() = Intent(this, T::class.java).let(::startActivity)
|
||||
inline fun <reified T: Activity> Context.start(modify: Intent.() -> Unit) = Intent(this, T::class.java).also(modify).let(::startActivity)
|
||||
|
Loading…
x
Reference in New Issue
Block a user