Skip to content

Commit

Permalink
Add string ressources and clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
LunarX committed Aug 14, 2024
1 parent 16c6ed5 commit 5220829
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ import androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteType
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.ui.components.MainScreenFab
import com.infomaniak.swisstransfer.ui.components.MainScreenFabType
import com.infomaniak.swisstransfer.ui.screen.main.LocalNavType
Expand All @@ -42,10 +44,18 @@ fun SentScreen(
navigateToDetails: (transferId: Int) -> Unit,
) {
val viewmodel = viewModel<SentViewModel>()
if (viewmodel.transfers.isNotEmpty()) {
TransferScreen(navType = LocalNavType.current)
} else {
SentScreen(
isEmpty = viewmodel.transfers.isEmpty(),
navType = LocalNavType.current,
)
}

@Composable
private fun SentScreen(isEmpty: Boolean, navType: NavigationSuiteType) {
if (isEmpty) {
EmptyScreen()
} else {
TransferScreen(navType)
}
}

Expand All @@ -59,15 +69,15 @@ fun EmptyScreen() {
val maxWidth = 300.dp
Text(
modifier = Modifier.widthIn(max = maxWidth),
text = "Notre histoire commence ici",
text = stringResource(id = R.string.sentEmptyTitle),
style = SwissTransferTheme.typography.specificMedium32,
textAlign = TextAlign.Center,
)
Text(
modifier = Modifier
.widthIn(max = maxWidth)
.padding(top = Margin.Medium),
text = "Fait ton premier transfert !",
text = stringResource(id = R.string.firstTransferDescription),
style = SwissTransferTheme.typography.bodyRegular
)
MainScreenFab(
Expand Down Expand Up @@ -97,29 +107,24 @@ private fun TransferScreen(
@Composable
private fun SentScreenMobilePreview() {
SwissTransferTheme {
TransferScreen(
NavigationSuiteType.NavigationBar,
)
Surface {
SentScreen(
isEmpty = true,
navType = NavigationSuiteType.NavigationBar,
)
}
}
}

@PreviewTablet
@Composable
private fun SentScreenTabletPreview() {
SwissTransferTheme {
TransferScreen(
NavigationSuiteType.NavigationRail,
)
}
}

@PreviewMobile
@PreviewTablet
@Composable
private fun SentScreenPreview() {
SwissTransferTheme {
Surface {
SentScreen({})
SentScreen(
isEmpty = true,
navType = NavigationSuiteType.NavigationRail,
)
}
}
}
3 changes: 3 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<resources>
<string name="contentDescriptionCreateNewTransferButton">New transfer</string>
<string name="firstTransferDescription">Make your first transfer!</string>
<string name="receivedTitle">Received</string>
<string name="sentEmptyTitle">Our story begins here</string>
<string name="sentTitle">Sent</string>
<string name="settingsTitle">Settings</string>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<resources>
<string name="contentDescriptionCreateNewTransferButton">New transfer</string>
<string name="firstTransferDescription">Make your first transfer!</string>
<string name="receivedTitle">Received</string>
<string name="sentEmptyTitle">Our story begins here</string>
<string name="sentTitle">Sent</string>
<string name="settingsTitle">Settings</string>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<resources>
<string name="contentDescriptionCreateNewTransferButton">Nouveau transfert</string>
<string name="firstTransferDescription">Fais ton premier transfert !</string>
<string name="receivedTitle">Recu</string>
<string name="sentEmptyTitle">Notre histoire commence ici</string>
<string name="sentTitle">Envoyé</string>
<string name="settingsTitle">Paramètres</string>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<resources>
<string name="contentDescriptionCreateNewTransferButton">New transfer</string>
<string name="firstTransferDescription">Make your first transfer!</string>
<string name="receivedTitle">Received</string>
<string name="sentEmptyTitle">Our story begins here</string>
<string name="sentTitle">Sent</string>
<string name="settingsTitle">Settings</string>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
<resources>
<string name="appName" translatable="false">SwissTransfer</string>

<string name="contentDescriptionCreateNewTransferButton">New transfer</string>
<string name="firstTransferDescription">Make your first transfer!</string>
<string name="receivedTitle">Received</string>
<string name="sentEmptyTitle">Our story begins here</string>
<string name="sentTitle">Sent</string>
<string name="settingsTitle">Settings</string>
</resources>

0 comments on commit 5220829

Please sign in to comment.