Skip to content

Commit

Permalink
15 bug nothing here text misaligned (#16)
Browse files Browse the repository at this point in the history
* Use textAlign property to align text. Combine text elements into one Text component in NothingHereText. Accept parameter in NothingHereText function.

* Use font style from theme instead of hardcoded font size.
  • Loading branch information
NicksPatties authored Jul 15, 2022
1 parent 9aead4b commit 8c0638f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,28 @@ 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.compose.ui.unit.sp
import com.nickspatties.timeclock.R

@Composable
fun NothingHereText() {
fun NothingHereText(
text: String = stringResource(id = R.string.list_page_nothing_here)
) {
Column(
modifier = Modifier
.fillMaxHeight()
.fillMaxWidth()
.padding(
horizontal = 8.dp
),
.padding(horizontal = 8.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
val size = 24.sp
val color = MaterialTheme.colors.onSurface.copy(alpha = 0.33f)
Text(
text = stringResource(R.string.list_page_nothing_here),
fontSize = size,
color = color
)
Text(
text = stringResource(R.string.list_page_fill_this_list),
fontSize = size,
color = color
text = text,
style = MaterialTheme.typography.h6,
color = MaterialTheme.colors.onSurface.copy(alpha = 0.33f),
textAlign = TextAlign.Center
)
}
}
3 changes: 1 addition & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<string name="task_saved_toast">Task \"%s\" saved!</string>
<string name="task_text_field_label">What are you gonna do now?</string>
<string name="task_text_field_placeholder">Right now, I\'m gonna be…</string>
<string name="list_page_nothing_here">Looks like there\'s nothing here.</string>
<string name="list_page_fill_this_list">Record some events to fill this list!</string>
<string name="list_page_nothing_here">Looks like there\'s nothing here… Record some events to fill this list!</string>
<string name="list_page_in_progress">In progress…</string>
<string name="start_time">Start time</string>
<string name="end_time">End time</string>
Expand Down

0 comments on commit 8c0638f

Please sign in to comment.