@@ -22,97 +22,91 @@ import dev.davwheat.railway.gateline_errors.ui.theme.AppTheme
22
22
import dev.davwheat.railway.gateline_errors.ui.theme.LcdDisplayFont
23
23
24
24
@Composable
25
- fun ErrorCodeDetail (
26
- modifier : Modifier = Modifier ,
27
- errorCode : Rejection ,
28
- ) {
29
- Column (
30
- modifier,
31
- verticalArrangement = Arrangement .spacedBy(8 .dp),
32
- ) {
33
- Text (
34
- stringResource(R .string.seek_assistance, errorCode.code),
35
- modifier = Modifier .fillMaxWidth(),
36
- fontFamily = LcdDisplayFont ,
37
- fontSize = 28 .sp,
38
- color = MaterialTheme .colorScheme.onSurfaceVariant,
39
- textAlign = TextAlign .Center ,
40
- )
41
-
42
- errorCode.textCode?.let { code ->
43
- DataPair (
44
- heading = " Text Error" ,
45
- text = { _modifier , style, align ->
46
- Text (
47
- modifier = _modifier ,
48
- text = code,
49
- style = style,
25
+ fun ErrorCodeDetail (modifier : Modifier = Modifier , errorCode : Rejection ) {
26
+ Column (modifier, verticalArrangement = Arrangement .spacedBy(8 .dp)) {
27
+ Text (
28
+ stringResource(R .string.seek_assistance, errorCode.code),
29
+ modifier = Modifier .fillMaxWidth(),
50
30
fontFamily = LcdDisplayFont ,
31
+ fontSize = 28 .sp,
51
32
color = MaterialTheme .colorScheme.onSurfaceVariant,
52
- fontSize = 18 .sp,
53
- textAlign = align,
54
- )
55
- },
56
- modifier = Modifier .align(Alignment .CenterHorizontally ),
57
- align = TextAlign .Center ,
58
- )
59
- }
33
+ textAlign = TextAlign .Center ,
34
+ )
60
35
61
- DataPair (heading = " Definition" ) { _modifier , style, align ->
62
- Text (
63
- modifier = _modifier ,
64
- text = errorCode.definition,
65
- style = style,
66
- textAlign = align,
67
- fontWeight = FontWeight .Bold ,
68
- )
69
- }
36
+ errorCode.textCode?.let { code ->
37
+ DataPair (
38
+ heading = " Text Error" ,
39
+ text = { _modifier , style, align ->
40
+ Text (
41
+ modifier = _modifier ,
42
+ text = code,
43
+ style = style,
44
+ fontFamily = LcdDisplayFont ,
45
+ color = MaterialTheme .colorScheme.onSurfaceVariant,
46
+ fontSize = 18 .sp,
47
+ textAlign = align,
48
+ )
49
+ },
50
+ modifier = Modifier .align(Alignment .CenterHorizontally ),
51
+ align = TextAlign .Center ,
52
+ )
53
+ }
70
54
71
- DataPair (heading = " Explanation" , text = errorCode.helpText)
55
+ DataPair (heading = " Definition" ) { _modifier , style, align ->
56
+ Text (
57
+ modifier = _modifier ,
58
+ text = errorCode.definition,
59
+ style = style,
60
+ textAlign = align,
61
+ fontWeight = FontWeight .Bold ,
62
+ )
63
+ }
72
64
73
- errorCode.laymansReason?. let { DataPair (heading = " Possible reason(s) " , text = it) }
65
+ DataPair (heading = " Explanation " , text = errorCode.helpText)
74
66
75
- DataPair (heading = " Action needed" , text = errorCode.actionByStaff)
76
- }
67
+ errorCode.laymansReason?.let { DataPair (heading = " Possible reason(s)" , text = it) }
68
+
69
+ DataPair (heading = " Action needed" , text = errorCode.actionByStaff)
70
+ }
77
71
}
78
72
79
73
@Composable
80
74
private fun DataPair (
81
- modifier : Modifier = Modifier ,
82
- align : TextAlign = TextAlign .Start ,
83
- heading : String ,
84
- text : String ,
75
+ modifier : Modifier = Modifier ,
76
+ align : TextAlign = TextAlign .Start ,
77
+ heading : String ,
78
+ text : String ,
85
79
) {
86
- DataPair (
87
- modifier = modifier,
88
- heading = heading,
89
- text = { _modifier , style, _ ->
90
- Text (modifier = _modifier , text = text, style = style, textAlign = align)
91
- },
92
- align = align,
93
- )
80
+ DataPair (
81
+ modifier = modifier,
82
+ heading = heading,
83
+ text = { _modifier , style, _ ->
84
+ Text (modifier = _modifier , text = text, style = style, textAlign = align)
85
+ },
86
+ align = align,
87
+ )
94
88
}
95
89
96
90
@Composable
97
91
private fun DataPair (
98
- modifier : Modifier = Modifier ,
99
- align : TextAlign = TextAlign .Start ,
100
- heading : String ,
101
- text : @Composable (modifier: Modifier , defaultStyle: TextStyle , textAlign: TextAlign ) -> Unit ,
92
+ modifier : Modifier = Modifier ,
93
+ align : TextAlign = TextAlign .Start ,
94
+ heading : String ,
95
+ text : @Composable (modifier: Modifier , defaultStyle: TextStyle , textAlign: TextAlign ) -> Unit ,
102
96
) {
103
- Column (modifier = modifier, verticalArrangement = Arrangement .spacedBy(4 .dp)) {
104
- Text (
105
- modifier = Modifier .fillMaxWidth(),
106
- text = heading,
107
- style = MaterialTheme .typography.bodySmall,
108
- textAlign = align,
109
- )
110
- text(Modifier .fillMaxWidth(), MaterialTheme .typography.bodyMedium, align)
111
- }
97
+ Column (modifier = modifier, verticalArrangement = Arrangement .spacedBy(4 .dp)) {
98
+ Text (
99
+ modifier = Modifier .fillMaxWidth(),
100
+ text = heading,
101
+ style = MaterialTheme .typography.bodySmall,
102
+ textAlign = align,
103
+ )
104
+ text(Modifier .fillMaxWidth(), MaterialTheme .typography.bodyMedium, align)
105
+ }
112
106
}
113
107
114
108
@Preview(showBackground = true )
115
109
@Composable
116
110
private fun ErrorCodeDetailPreview () {
117
- AppTheme { ErrorCodeDetail (errorCode = ErrorCodes [1 ]!! ) }
111
+ AppTheme { ErrorCodeDetail (errorCode = ErrorCodes [1 ]!! ) }
118
112
}
0 commit comments