@@ -2,20 +2,37 @@ package fr.antoineverin.worktime.ui.screen
2
2
3
3
import androidx.compose.foundation.layout.Arrangement
4
4
import androidx.compose.foundation.layout.Column
5
+ import androidx.compose.foundation.layout.Row
5
6
import androidx.compose.foundation.layout.Spacer
7
+ import androidx.compose.foundation.layout.fillMaxHeight
8
+ import androidx.compose.foundation.layout.fillMaxWidth
6
9
import androidx.compose.foundation.layout.height
10
+ import androidx.compose.foundation.layout.padding
11
+ import androidx.compose.foundation.layout.size
12
+ import androidx.compose.foundation.layout.width
13
+ import androidx.compose.foundation.layout.wrapContentHeight
14
+ import androidx.compose.material.icons.Icons
15
+ import androidx.compose.material.icons.filled.List
16
+ import androidx.compose.material.icons.filled.Surfing
17
+ import androidx.compose.material.icons.filled.Work
7
18
import androidx.compose.material3.Button
19
+ import androidx.compose.material3.Icon
8
20
import androidx.compose.material3.Text
9
21
import androidx.compose.runtime.Composable
10
22
import androidx.compose.runtime.LaunchedEffect
11
23
import androidx.compose.ui.Alignment
12
24
import androidx.compose.ui.Modifier
13
25
import androidx.compose.ui.graphics.Color
26
+ import androidx.compose.ui.text.font.Font
27
+ import androidx.compose.ui.text.font.FontFamily
28
+ import androidx.compose.ui.text.font.FontWeight
29
+ import androidx.compose.ui.text.style.TextAlign
14
30
import androidx.compose.ui.unit.dp
15
31
import androidx.compose.ui.unit.sp
16
32
import androidx.hilt.navigation.compose.hiltViewModel
17
33
import fr.antoineverin.worktime.LIST_ENTRIES
18
34
import fr.antoineverin.worktime.LIST_VACATION
35
+ import fr.antoineverin.worktime.R
19
36
import fr.antoineverin.worktime.ui.viewmodel.MainScreenViewModel
20
37
import java.time.Duration
21
38
import java.time.YearMonth
@@ -27,40 +44,109 @@ import kotlin.math.absoluteValue
27
44
fun MainScreen (
28
45
navigate : (String ) -> Unit ,
29
46
viewModel : MainScreenViewModel = hiltViewModel()
30
- ) {
47
+ )
48
+ {
31
49
Column (
32
- verticalArrangement = Arrangement .Center ,
33
- horizontalAlignment = Alignment .CenterHorizontally
50
+ verticalArrangement = Arrangement .SpaceBetween ,
51
+ horizontalAlignment = Alignment .CenterHorizontally ,
52
+ modifier = Modifier .fillMaxHeight()
34
53
) {
35
- CurrentPeriod (period = YearMonth .now())
36
- Spacer (modifier = Modifier .height(24 .dp))
37
- TimeSpentSummary (
38
- hoursSpent = viewModel.getTimeDone(),
39
- hoursObjective = viewModel.getHoursObjective()
54
+ Text (
55
+ text = " 42 Pointinette" ,
56
+ fontSize = 50 .sp,
57
+ fontFamily = FontFamily (Font (R .font.roboto_black)),
58
+ fontWeight = FontWeight .Bold ,
59
+ modifier = Modifier
60
+ .padding(bottom = 10 .dp)
61
+ .padding(top = 10 .dp),
62
+ style = androidx.compose.ui.text.TextStyle (
63
+ textAlign = TextAlign .Center ,
64
+ )
40
65
)
41
- if (viewModel.getCurrentDayTimeSpent() != null ) {
42
- Spacer (modifier = Modifier .height(24 .dp))
43
- Text (text = " Today you've worked:" )
44
- Text (text = viewModel.getCurrentDayTimeSpent()!! )
45
- }
46
- Spacer (modifier = Modifier .height(24 .dp))
47
- if (viewModel.getTimeDone() != null
48
- && viewModel.getTimeDone()!! .toHours() < viewModel.getHoursObjective())
49
- HoursPrediction (
50
- remainingDifference = viewModel.getRemainingHoursDifference(),
51
- remainingHours = viewModel.getRemainingHoursPerDay()
66
+ Column (
67
+ horizontalAlignment = Alignment .CenterHorizontally ,
68
+ modifier = Modifier
69
+ ) {
70
+ CurrentPeriod (period = YearMonth .now())
71
+ Spacer (modifier = Modifier .height(34 .dp))
72
+ TimeSpentSummary (
73
+ hoursSpent = viewModel.getTimeDone(),
74
+ hoursObjective = viewModel.getHoursObjective()
52
75
)
53
- Spacer (modifier = Modifier .height(24 .dp))
54
- Button (onClick = { viewModel.addEntry(navigate) }) {
55
- Text (text = " Work!" )
56
- }
57
- Spacer (modifier = Modifier .height(24 .dp))
58
- Button (onClick = { navigate(LIST_ENTRIES ) }) {
59
- Text (text = " List entries" )
76
+ if (viewModel.getCurrentDayTimeSpent() != null ) {
77
+ Spacer (modifier = Modifier .height(34 .dp))
78
+ Text (
79
+ text = " Today you've worked :" ,
80
+ fontWeight = FontWeight .Bold ,
81
+ )
82
+ Text (text = viewModel.getCurrentDayTimeSpent()!! )
83
+ }
84
+ Spacer (modifier = Modifier .height(34 .dp))
85
+ Text (
86
+ text = " You have to do :" ,
87
+ fontWeight = FontWeight .Bold ,
88
+ )
89
+ val remainingHours = viewModel.getRemainingHoursPerDay()
90
+ if (remainingHours != null )
91
+ Text (
92
+ text = " ${remainingHours.toHours()} h " +
93
+ " ${remainingHours.toMinutes() % 60 } m per days"
94
+ )
95
+ val remainingDifference = viewModel.getRemainingHoursDifference()
96
+ if (remainingDifference != null )
97
+ Text (
98
+ text = " ${remainingDifference.toHours()} h " +
99
+ " ${remainingDifference.toMinutes().absoluteValue % 60 } m" ,
100
+ color = if (remainingDifference.isNegative) Color .Red else Color .Green ,
101
+ fontSize = 13 .sp
102
+ )
60
103
}
61
- Spacer (modifier = Modifier .height(24 .dp))
62
- Button (onClick = { navigate(LIST_VACATION ) }) {
63
- Text (text = " List vacations" )
104
+ Column (
105
+ Modifier .fillMaxWidth().wrapContentHeight(),
106
+ horizontalAlignment = Alignment .CenterHorizontally
107
+ ) {
108
+ Button (
109
+ onClick = { viewModel.addEntry(navigate) },
110
+ modifier = Modifier
111
+ .size(width = 350 .dp, height = 100 .dp),
112
+ ) {
113
+ Row (verticalAlignment = Alignment .CenterVertically ) {
114
+ Icon (
115
+ imageVector = Icons .Default .Work ,
116
+ contentDescription = null ,
117
+ modifier = Modifier .size(55 .dp)
118
+ )
119
+ Spacer (modifier = Modifier .width(8 .dp))
120
+ Text (
121
+ text = " Work!" ,
122
+ fontSize = 50 .sp,
123
+ )
124
+ }
125
+ }
126
+ Spacer (modifier = Modifier .height(14 .dp))
127
+ Row {
128
+ Button (onClick = { navigate(LIST_VACATION ) }) {
129
+ Row (verticalAlignment = Alignment .CenterVertically ) {
130
+ Icon (imageVector = Icons .Default .Surfing , contentDescription = null )
131
+ Spacer (modifier = Modifier .width(8 .dp))
132
+ Text (
133
+ text = " List Vacations" ,
134
+ fontWeight = FontWeight .Bold ,
135
+ )
136
+ }
137
+ }
138
+ Spacer (modifier = Modifier .width(16 .dp))
139
+ Button (onClick = { navigate(LIST_ENTRIES ) }) {
140
+ Row (verticalAlignment = Alignment .CenterVertically ) {
141
+ Icon (imageVector = Icons .Default .List , contentDescription = null )
142
+ Spacer (modifier = Modifier .width(8 .dp))
143
+ Text (
144
+ text = " List entries" ,
145
+ fontWeight = FontWeight .Bold ,
146
+ )
147
+ }
148
+ }
149
+ }
64
150
}
65
151
}
66
152
@@ -72,7 +158,11 @@ fun MainScreen(
72
158
@Composable
73
159
private fun CurrentPeriod (period : YearMonth ) {
74
160
Column (horizontalAlignment = Alignment .CenterHorizontally ) {
75
- Text (text = " Current Period" )
161
+ Text (
162
+ text = " Current Period :" ,
163
+ fontSize = 20 .sp,
164
+ fontWeight = FontWeight .Bold ,
165
+ )
76
166
Text (text = " " + period.month.getDisplayName(TextStyle .FULL , Locale .FRANCE ) + " " + period.year)
77
167
}
78
168
}
@@ -87,25 +177,10 @@ private fun TimeSpentSummary(
87
177
Text (text = " ..." )
88
178
else
89
179
Text (text = " " + hoursSpent.toHours() + " h " + hoursSpent.toMinutes() % 60 + " m" )
90
- Text (text = " /" )
91
- Text (text = " " + hoursObjective + " h" )
92
- }
93
- }
94
-
95
- @Composable
96
- private fun HoursPrediction (
97
- remainingDifference : Duration ? ,
98
- remainingHours : Duration ?
99
- ) {
100
- if (remainingDifference != null )
101
180
Text (
102
- text = " ${remainingDifference.toHours()} h " +
103
- " ${remainingDifference.toMinutes().absoluteValue % 60 } m" ,
104
- color = if (remainingDifference.isNegative) Color .Red else Color .Green ,
105
- fontSize = 13 .sp
181
+ text = " ↓" ,
182
+ fontSize = 25 .sp,
106
183
)
107
- if (remainingHours != null )
108
- Text (text = " Should do ${remainingHours.toHours()} h " +
109
- " ${remainingHours.toMinutes() % 60 } m / days" )
110
- Text (text = " hours maybe false" , fontSize = 10 .sp)
184
+ Text (text = " " + hoursObjective + " h" )
185
+ }
111
186
}
0 commit comments