Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 59dc681f authored by Arnau Mora's avatar Arnau Mora Committed by GitHub
Browse files

AccountsActivity: disable sync button when there are no accounts (#473)



Signed-off-by: default avatarArnau Mora <arnyminerz@proton.me>
parent d22da0d2
Loading
Loading
Loading
Loading
+17 −11
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
@@ -135,11 +134,13 @@ class AccountsActivity: AppCompatActivity() {
                model.syncAllAccounts()
            })

            val accounts by model.accountInfos.observeAsState()

            MdcTheme {
                Scaffold(
                    scaffoldState = scaffoldState,
                    drawerContent = drawerContent(scope, scaffoldState),
                    topBar = topBar(scope, scaffoldState),
                    topBar = topBar(scope, scaffoldState, accounts?.isNotEmpty() == true),
                    floatingActionButton = floatingActionButton(),
                    snackbarHost = snackbarHost(snackbarHostState, scope)
                ) { padding ->
@@ -147,7 +148,10 @@ class AccountsActivity: AppCompatActivity() {
                        Modifier
                            .fillMaxSize()
                            .padding(padding)
                            .pullRefresh(pullRefreshState)
                            .pullRefresh(
                                state = pullRefreshState,
                                enabled = accounts?.isNotEmpty() == true
                            )
                            .verticalScroll(rememberScrollState())
                    ) {

@@ -198,9 +202,8 @@ class AccountsActivity: AppCompatActivity() {
                            )

                            // account list
                            val accounts = model.accountInfos.observeAsState()
                            AccountList(
                                accounts = accounts.value ?: emptyList(),
                                accounts = accounts ?: emptyList(),
                                onClickAccount = { account ->
                                    val activity = this@AccountsActivity
                                    val intent = Intent(activity, AccountActivity::class.java)
@@ -267,7 +270,8 @@ class AccountsActivity: AppCompatActivity() {
    @Composable
    private fun topBar(
        scope: CoroutineScope,
        scaffoldState: ScaffoldState
        scaffoldState: ScaffoldState,
        accountsNotEmpty: Boolean
    ): @Composable (() -> Unit) = {
        TopAppBar(
            navigationIcon = {
@@ -289,6 +293,7 @@ class AccountsActivity: AppCompatActivity() {
                Text(stringResource(R.string.app_name))
            },
            actions = {
                if (accountsNotEmpty) {
                    IconButton(onClick = { model.syncAllAccounts() }) {
                        Icon(
                            painterResource(R.drawable.ic_sync),
@@ -296,6 +301,7 @@ class AccountsActivity: AppCompatActivity() {
                        )
                    }
                }
            }
        )
    }