-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathHomeScreen.kt
216 lines (212 loc) · 8.25 KB
/
HomeScreen.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
package com.d10ng.compose.demo.pages
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.d10ng.compose.demo.R
import com.d10ng.compose.demo.pages.destinations.AvatarScreenDestination
import com.d10ng.compose.demo.pages.destinations.BadgeScreenDestination
import com.d10ng.compose.demo.pages.destinations.ButtonScreenDestination
import com.d10ng.compose.demo.pages.destinations.CellScreenDestination
import com.d10ng.compose.demo.pages.destinations.CheckButtonScreenDestination
import com.d10ng.compose.demo.pages.destinations.CheckboxScreenDestination
import com.d10ng.compose.demo.pages.destinations.DialogScreenDestination
import com.d10ng.compose.demo.pages.destinations.FieldScreenDestination
import com.d10ng.compose.demo.pages.destinations.ImagePreviewScreenDestination
import com.d10ng.compose.demo.pages.destinations.IndexBarScreenDestination
import com.d10ng.compose.demo.pages.destinations.NavBarScreenDestination
import com.d10ng.compose.demo.pages.destinations.NotifyScreenDestination
import com.d10ng.compose.demo.pages.destinations.PopoverScreenDestination
import com.d10ng.compose.demo.pages.destinations.PullRefreshScreenDestination
import com.d10ng.compose.demo.pages.destinations.SearchScreenDestination
import com.d10ng.compose.demo.pages.destinations.SheetScreenDestination
import com.d10ng.compose.demo.pages.destinations.StepperScreenDestination
import com.d10ng.compose.demo.pages.destinations.StepsScreenDestination
import com.d10ng.compose.demo.pages.destinations.SwitchScreenDestination
import com.d10ng.compose.demo.pages.destinations.TagScreenDestination
import com.d10ng.compose.demo.pages.destinations.ToastScreenDestination
import com.d10ng.compose.ui.AppColor
import com.d10ng.compose.ui.AppShape
import com.d10ng.compose.ui.AppText
import com.d10ng.compose.ui.PageTransitions
import com.d10ng.compose.ui.base.Cell
import com.d10ng.compose.ui.base.CellGroup
import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.annotation.RootNavGraph
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import com.ramcosta.composedestinations.spec.Direction
/**
* 首页
* @Author d10ng
* @Date 2023/9/4 13:54
*/
@RootNavGraph(start = true)
@Destination(style = PageTransitions::class)
@Composable
fun HomeScreen(
nav: DestinationsNavigator
) {
HomeScreenView(
onClick = {
nav.navigate(it) { launchSingleTop = true }
}
)
}
@Composable
private fun HomeScreenView(
onClick: (Direction) -> Unit = {},
) {
Column(
modifier = Modifier
.fillMaxSize()
.background(AppColor.Neutral.bg)
.statusBarsPadding()
.verticalScroll(rememberScrollState())
) {
// 标题
Row(
modifier = Modifier
.fillMaxWidth()
.padding(19.dp),
verticalAlignment = Alignment.CenterVertically
) {
Icon(
painter = painterResource(id = R.drawable.ic_launcher_foreground),
contentDescription = null,
tint = AppColor.Main.primary,
modifier = Modifier
.height(64.dp)
.background(Color.White, AppShape.RC.v24)
)
Column(
modifier = Modifier
.fillMaxWidth()
.padding(start = 19.dp)
) {
Text(text = "DLJetpackComposeUtil", style = AppText.Bold.Title.large)
Text(
text = "Jetpack Compose UI 组件库(仿Vant)",
style = AppText.Normal.Body.small,
modifier = Modifier.padding(top = 4.dp)
)
}
}
CellGroup(title = "基础组件", inset = true) {
Cell(
title = "Button 按钮",
link = true,
onClick = { onClick(ButtonScreenDestination) })
Cell(
title = "Cell 单元格",
link = true,
onClick = { onClick(CellScreenDestination) })
Cell(
title = "Toast 轻提示",
link = true,
border = false,
onClick = { onClick(ToastScreenDestination) })
}
CellGroup(title = "表单组件", inset = true) {
Cell(
title = "Checkbox 复选框",
link = true,
onClick = { onClick(CheckboxScreenDestination) })
Cell(
title = "Field 输入框",
link = true,
onClick = { onClick(FieldScreenDestination) })
Cell(
title = "Switch 开关",
link = true,
onClick = { onClick(SwitchScreenDestination) })
Cell(
title = "CheckButton 选择按钮",
link = true,
onClick = { onClick(CheckButtonScreenDestination) })
Cell(
title = "Stepper 步进器",
link = true,
onClick = { onClick(StepperScreenDestination) })
Cell(
title = "Search 搜索",
link = true,
onClick = { onClick(SearchScreenDestination) })
}
CellGroup(title = "反馈组件", inset = true) {
Cell(
title = "Dialog 弹出框",
link = true,
onClick = { onClick(DialogScreenDestination) })
Cell(
title = "Sheet 操作面板",
link = true,
onClick = { onClick(SheetScreenDestination) })
Cell(
title = "Notify 消息提示",
link = true,
onClick = { onClick(NotifyScreenDestination) })
Cell(
title = "PullRefresh 下拉刷新",
link = true,
onClick = { onClick(PullRefreshScreenDestination) })
}
CellGroup(title = "展示组件", inset = true) {
Cell(
title = "Tag 标签",
link = true,
onClick = { onClick(TagScreenDestination) })
Cell(
title = "Badge 徽标",
link = true,
onClick = { onClick(BadgeScreenDestination) })
Cell(
title = "Avatar 头像",
link = true,
onClick = { onClick(AvatarScreenDestination) })
Cell(
title = "Steps 步骤条",
link = true,
onClick = { onClick(StepsScreenDestination) })
Cell(
title = "Popover 气泡弹出框",
link = true,
onClick = { onClick(PopoverScreenDestination) })
Cell(
title = "ImagePreview 图片预览",
link = true,
onClick = { onClick(ImagePreviewScreenDestination) })
}
CellGroup(title = "导航组件", inset = true) {
Cell(
title = "NavBar 导航栏",
link = true,
onClick = { onClick(NavBarScreenDestination) })
Cell(
title = "IndexBar 索引栏",
link = true,
onClick = { onClick(IndexBarScreenDestination) })
}
Box(modifier = Modifier.height(32.dp))
}
}
@Preview
@Composable
private fun HomeScreenViewPreview() {
HomeScreenView()
}