1
1
package app.app.samplekmp.app.auth.onboarding
2
2
3
- import androidx.compose.animation.core.animateDpAsState
4
- import androidx.compose.foundation.background
5
- import androidx.compose.foundation.layout.Arrangement
6
- import androidx.compose.foundation.layout.Box
7
- import androidx.compose.foundation.layout.Column
8
- import androidx.compose.foundation.layout.Row
9
- import androidx.compose.foundation.layout.Spacer
10
- import androidx.compose.foundation.layout.fillMaxSize
11
- import androidx.compose.foundation.layout.fillMaxWidth
12
- import androidx.compose.foundation.layout.height
13
- import androidx.compose.foundation.layout.padding
14
- import androidx.compose.foundation.layout.size
15
- import androidx.compose.foundation.layout.widthIn
16
- import androidx.compose.foundation.pager.HorizontalPager
17
- import androidx.compose.foundation.pager.rememberPagerState
18
- import androidx.compose.foundation.shape.CircleShape
19
- import androidx.compose.material3.Button
20
- import androidx.compose.material3.ButtonDefaults
21
- import androidx.compose.material3.LocalContentColor
22
- import androidx.compose.material3.MaterialTheme
23
- import androidx.compose.material3.Scaffold
24
- import androidx.compose.material3.Text
25
- import androidx.compose.material3.TextButton
26
3
import androidx.compose.runtime.Composable
27
- import androidx.compose.runtime.CompositionLocalProvider
28
- import androidx.compose.runtime.getValue
29
- import androidx.compose.ui.Alignment
30
- import androidx.compose.ui.Modifier
31
- import androidx.compose.ui.draw.clip
32
- import androidx.compose.ui.graphics.Brush
33
- import androidx.compose.ui.graphics.Color
34
- import androidx.compose.ui.layout.ContentScale
35
- import androidx.compose.ui.text.style.TextAlign
36
- import app.app.samplekmp.resources.Space16
37
- import app.app.samplekmp.resources.Space2
38
- import app.app.samplekmp.resources.Space24
39
- import app.app.samplekmp.resources.Space4
40
- import app.app.samplekmp.resources.Space6
41
- import app.app.samplekmp.resources.Space600
42
- import app.app.samplekmp.resources.Space8
43
- import app.app.samplekmp.resources.Weight1
44
- import coil3.compose.AsyncImage
45
4
46
5
@Composable
47
6
fun OnboardingScreen (
@@ -53,129 +12,3 @@ fun OnboardingScreen(
53
12
onSignUpClick = onSignUpClick
54
13
)
55
14
}
56
-
57
- @Composable
58
- fun OnboardingScaffold (
59
- onSignInClick : () -> Unit ,
60
- onSignUpClick : () -> Unit
61
- ) {
62
- val pages = listOf (
63
- mapOf (
64
- " title" to " Welcome to Wheels" ,
65
- " subtitle" to " Let's find you a bike" ,
66
- " image" to " https://images.unsplash.com/photo-1475666675596-cca2035b3d79" ,
67
- ), mapOf (
68
- " title" to " Find a bike in any town" ,
69
- " subtitle" to " With over 5,000 spots world wide, we always got you covered" ,
70
- " image" to " https://images.unsplash.com/photo-1605028241606-ca01277aa15c" ,
71
- ), mapOf (
72
- " title" to " Safety above all" ,
73
- " subtitle" to " Travel with peace of mind, thanks to our safety features" ,
74
- " image" to " https://images.unsplash.com/photo-1517305349393-aad1f0ee4328" ,
75
- )
76
- )
77
- val pagerState = rememberPagerState { pages.size }
78
-
79
- Scaffold {
80
- Column (
81
- modifier = Modifier .background(Color .Black )
82
- ) {
83
- HorizontalPager (
84
- state = pagerState, modifier = Modifier .weight(Weight1 )
85
- ) { page ->
86
- val item = pages[page]
87
- val title = item.getValue(" title" )
88
- val subtitle = item.getValue(" subtitle" )
89
- val image = item.getValue(" image" )
90
- Box (
91
- modifier = Modifier .fillMaxSize(),
92
- contentAlignment = Alignment .Center
93
- ) {
94
- AsyncImage (
95
- model = image,
96
- modifier = Modifier .fillMaxSize().background(Color .Black ),
97
- contentDescription = null ,
98
- contentScale = ContentScale .Crop
99
- )
100
- Box (
101
- modifier = Modifier
102
- .fillMaxSize()
103
- .background(Brush .verticalGradient(listOf (Color .Transparent , Color .Black )))
104
- )
105
- Column (
106
- modifier = Modifier
107
- .align(Alignment .BottomCenter )
108
- .padding(Space24 )
109
- .widthIn(max = Space600 )
110
- .fillMaxWidth(),
111
- ) {
112
- CompositionLocalProvider (
113
- value = LocalContentColor provides Color .White
114
- ) {
115
- Text (
116
- text = title,
117
- style = MaterialTheme .typography.headlineLarge,
118
- textAlign = TextAlign .Start
119
- )
120
- Spacer (modifier = Modifier .height(Space4 ))
121
- Text (
122
- text = subtitle,
123
- style = MaterialTheme .typography.headlineSmall,
124
- textAlign = TextAlign .Start
125
- )
126
- }
127
- }
128
- }
129
- }
130
- Row (
131
- horizontalArrangement = Arrangement .spacedBy(Space6 ),
132
- verticalAlignment = Alignment .CenterVertically ,
133
- modifier = Modifier .align(Alignment .CenterHorizontally )
134
- ) {
135
- val currentPage = pagerState.currentPage
136
- repeat(pages.size) { iteration ->
137
- val color = if (currentPage == iteration) Color .White else Color .Gray
138
- val size by animateDpAsState(if (currentPage == iteration) Space8 else Space6 )
139
- Box (
140
- modifier = Modifier .size(Space8 ),
141
- contentAlignment = Alignment .Center
142
- ) {
143
- Box (
144
- modifier = Modifier
145
- .clip(CircleShape )
146
- .background(color)
147
- .size(size)
148
- )
149
- }
150
- }
151
- }
152
- Spacer (
153
- modifier = Modifier .height(Space24 )
154
- )
155
- Column (
156
- verticalArrangement = Arrangement .spacedBy(Space2 ),
157
- modifier = Modifier
158
- .align(Alignment .CenterHorizontally )
159
- .padding(horizontal = Space16 )
160
- .padding(bottom = Space16 ).widthIn(max = Space600 )
161
- ) {
162
- Button (
163
- onClick = onSignUpClick,
164
- modifier = Modifier .fillMaxWidth()
165
- ) {
166
- Text (
167
- text = " Create account" ,
168
- modifier = Modifier .padding(vertical = Space8 )
169
- )
170
- }
171
- TextButton (
172
- onClick = onSignInClick,
173
- modifier = Modifier .fillMaxWidth(),
174
- colors = ButtonDefaults .textButtonColors(contentColor = Color .White )
175
- ) {
176
- Text (text = " Log in" )
177
- }
178
- }
179
- }
180
- }
181
- }
0 commit comments