repose-material 0.19.2

Material components for Repose
Documentation
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
use repose_core::*;

/// Default values for surface component.
pub struct SurfaceDefaults;

impl SurfaceDefaults {
    pub fn color() -> Color {
        theme().surface
    }
    pub const SHAPE_RADIUS: f32 = 0.0;
    pub const TONAL_ELEVATION: f32 = 0.0;
}

/// Default values for toggle button components.
pub struct ToggleButtonDefaults;

impl ToggleButtonDefaults {
    pub const HEIGHT: f32 = 40.0;
    pub const HORIZONTAL_PADDING: f32 = 24.0;
    pub const SHAPE_RADIUS: f32 = 20.0;
    pub fn content_color() -> Color {
        theme().on_surface_variant
    }
    pub fn checked_container_color() -> Color {
        theme().primary
    }
    pub fn checked_content_color() -> Color {
        theme().on_primary
    }
    pub fn tonal_content_color() -> Color {
        theme().on_surface_variant
    }
    pub fn tonal_checked_container_color() -> Color {
        theme().secondary_container
    }
    pub fn tonal_checked_content_color() -> Color {
        theme().on_secondary_container
    }
    pub fn outlined_content_color() -> Color {
        theme().on_surface_variant
    }
    pub fn outlined_border_color() -> Color {
        theme().outline
    }
    pub fn outlined_checked_container_color() -> Color {
        theme().secondary_container
    }
    pub fn outlined_checked_content_color() -> Color {
        theme().on_secondary_container
    }
    pub fn elevated_content_color() -> Color {
        theme().primary
    }
    pub fn elevated_checked_container_color() -> Color {
        theme().surface_container_low
    }
    pub fn elevated_checked_content_color() -> Color {
        theme().primary
    }
    pub fn state_colors_default() -> StateColors {
        let th = theme();
        StateColors {
            default: Color::TRANSPARENT,
            hovered: th.on_surface.with_alpha_f32(0.08),
            pressed: th.on_surface.with_alpha_f32(0.12),
            disabled: th.on_surface.with_alpha_f32(0.12),
        }
    }
    pub fn state_elevation_default() -> StateElevation {
        StateElevation {
            default: 0.0,
            hovered: 1.0,
            pressed: 0.0,
            disabled: 0.0,
        }
    }
    pub fn elevated_state_elevation() -> StateElevation {
        let th = theme();
        StateElevation {
            default: th.elevation.level1,
            hovered: th.elevation.level2,
            pressed: th.elevation.level1,
            disabled: 0.0,
        }
    }
}

/// Default values for progress indicator components.
pub struct ProgressIndicatorDefaults;

impl ProgressIndicatorDefaults {
    pub fn linear_color() -> Color {
        theme().primary
    }
    pub fn linear_track_color() -> Color {
        theme().secondary_container
    }
    pub const LINEAR_INDICATOR_HEIGHT: f32 = 4.0;
    pub const LINEAR_INDICATOR_GAP_SIZE: f32 = 4.0;
    pub const LINEAR_TRACK_STOP_SIZE: f32 = 4.0;

    pub fn circular_color() -> Color {
        theme().primary
    }
    pub fn circular_track_color() -> Color {
        theme().secondary_container
    }
    pub const CIRCULAR_INDICATOR_SIZE: f32 = 40.0;
    pub const CIRCULAR_STROKE_WIDTH: f32 = 4.0;
}

/// Default values for button components.
pub struct ButtonDefaults;

impl ButtonDefaults {
    pub fn content_color() -> Color {
        theme().on_primary
    }
    pub fn container_color() -> Color {
        theme().primary
    }
    pub fn tonal_container_color() -> Color {
        theme().secondary_container
    }
    pub fn tonal_content_color() -> Color {
        theme().on_secondary_container
    }
    pub fn elevated_container_color() -> Color {
        theme().surface_container_low
    }
    pub fn elevated_content_color() -> Color {
        theme().primary
    }
    pub fn outlined_content_color() -> Color {
        theme().on_surface_variant
    }
    pub fn outlined_border_color() -> Color {
        theme().outline_variant
    }
    pub fn text_content_color() -> Color {
        theme().primary
    }
    pub const HEIGHT: f32 = 40.0;
    pub const HORIZONTAL_PADDING: f32 = 24.0;
    pub const TEXT_HORIZONTAL_PADDING: f32 = 12.0;
    pub const SHAPE_RADIUS: f32 = 20.0;
    pub fn state_colors_default() -> StateColors {
        let th = theme();
        StateColors {
            default: Color::TRANSPARENT,
            hovered: th.on_surface.with_alpha_f32(0.08),
            pressed: th.on_surface.with_alpha_f32(0.12),
            disabled: th.on_surface.with_alpha_f32(0.12),
        }
    }
    pub fn state_elevation_default() -> StateElevation {
        StateElevation {
            default: 0.0,
            hovered: 1.0,
            pressed: 0.0,
            disabled: 0.0,
        }
    }
    pub fn elevated_state_elevation() -> StateElevation {
        let th = theme();
        StateElevation {
            default: th.elevation.level1,
            hovered: th.elevation.level2,
            pressed: th.elevation.level1,
            disabled: 0.0,
        }
    }
}

/// Default values for snackbar components.
pub struct SnackbarDefaults;

impl SnackbarDefaults {
    pub const MIN_HEIGHT: f32 = 48.0;
    pub const MIN_WIDTH: f32 = 280.0;
    pub const MAX_WIDTH: f32 = 600.0;
    pub const SHAPE_RADIUS: f32 = 4.0;
    pub fn container_color() -> Color {
        theme().inverse_surface
    }
    pub fn content_color() -> Color {
        theme().inverse_on_surface
    }
    pub fn action_color() -> Color {
        theme().inverse_primary
    }
}

/// Default values for card components.
pub struct CardDefaults;

impl CardDefaults {
    pub fn filled_container_color() -> Color {
        theme().surface_container_highest
    }
    pub fn elevated_container_color() -> Color {
        theme().surface_container_low
    }
    pub fn outlined_container_color() -> Color {
        theme().surface
    }
    pub fn outlined_border_color() -> Color {
        theme().outline_variant
    }
    pub const SHAPE_RADIUS: f32 = 12.0;
    pub const ELEVATION: f32 = 0.0;
}

/// Default values for dialog components.
pub struct DialogDefaults;

impl DialogDefaults {
    pub fn container_color() -> Color {
        theme().surface_container_high
    }
    pub const SHAPE_RADIUS: f32 = 28.0;
    pub const MIN_WIDTH: f32 = 280.0;
    pub const MAX_WIDTH: f32 = 560.0;
    pub const HORIZONTAL_PADDING: f32 = 24.0;
}

/// Default values for icon button components.
pub struct IconButtonDefaults;

impl IconButtonDefaults {
    pub const CONTAINER_SIZE: f32 = 48.0;
    pub const FILLED_CONTAINER_SIZE: f32 = 40.0;
    pub fn content_color() -> Color {
        theme().on_surface_variant
    }
    pub fn filled_content_color() -> Color {
        theme().on_primary
    }
    pub fn filled_container_color() -> Color {
        theme().primary
    }
    pub fn filled_tonal_content_color() -> Color {
        theme().on_secondary_container
    }
    pub fn filled_tonal_container_color() -> Color {
        theme().secondary_container
    }
    pub fn state_colors_default() -> StateColors {
        let th = theme();
        StateColors {
            default: Color::TRANSPARENT,
            hovered: th.on_surface.with_alpha_f32(0.08),
            pressed: th.on_surface.with_alpha_f32(0.12),
            disabled: Color::TRANSPARENT,
        }
    }
}

/// Default values for checkbox.
pub struct CheckboxDefaults;

impl CheckboxDefaults {
    pub const TOUCH_TARGET_SIZE: f32 = 40.0;
    pub const BOX_SIZE: f32 = 18.0;
    pub const STROKE_WIDTH: f32 = 2.0;
    pub const CORNER_RADIUS: f32 = 2.0;
    pub const CHECK_ICON_SIZE: f32 = 14.0;
    pub fn checked_color() -> Color {
        theme().primary
    }
    pub fn unchecked_color() -> Color {
        theme().on_surface_variant
    }
    pub fn checkmark_color() -> Color {
        theme().on_primary
    }
}

/// Default values for radio button.
pub struct RadioButtonDefaults;

impl RadioButtonDefaults {
    pub const TOUCH_TARGET_SIZE: f32 = 40.0;
    pub const OUTER_RADIUS: f32 = 10.0;
    pub const DOT_RADIUS: f32 = 5.0;
    pub const STROKE_WIDTH: f32 = 2.0;
    pub fn selected_color() -> Color {
        theme().primary
    }
    pub fn unselected_color() -> Color {
        theme().on_surface_variant
    }
}

/// Default values for switch.
pub struct SwitchDefaults;

impl SwitchDefaults {
    pub const TRACK_WIDTH: f32 = 52.0;
    pub const TRACK_HEIGHT: f32 = 32.0;
    pub const THUMB_CHECKED_SIZE: f32 = 24.0;
    pub const THUMB_UNCHECKED_SIZE: f32 = 16.0;
    pub fn checked_track_color() -> Color {
        theme().primary
    }
    pub fn unchecked_track_color() -> Color {
        theme().surface_container_highest
    }
    pub fn checked_thumb_color() -> Color {
        theme().on_primary
    }
    pub fn unchecked_thumb_color() -> Color {
        theme().outline
    }
    pub fn unchecked_border_color() -> Color {
        theme().outline
    }
}

/// Default values for slider.
pub struct SliderDefaults;

impl SliderDefaults {
    pub const TRACK_HEIGHT: f32 = 4.0;
    pub const THUMB_SIZE: f32 = 20.0;
    pub fn active_track_color() -> Color {
        theme().primary
    }
    pub fn inactive_track_color() -> Color {
        theme().secondary_container
    }
    pub fn thumb_color() -> Color {
        theme().primary
    }
}

/// Default values for divider.
pub struct DividerDefaults;

impl DividerDefaults {
    pub const THICKNESS: f32 = 1.0;
    pub fn color() -> Color {
        theme().outline_variant
    }
}

/// Default values for badge.
pub struct BadgeDefaults;

impl BadgeDefaults {
    pub const DOT_SIZE: f32 = 6.0;
    pub const LABEL_MIN_WIDTH: f32 = 16.0;
    pub const LABEL_HEIGHT: f32 = 16.0;
    pub fn color() -> Color {
        theme().error
    }
    pub fn label_color() -> Color {
        theme().on_error
    }
}

/// Default values for list item.
pub struct ListItemDefaults;

impl ListItemDefaults {
    pub const ONE_LINE_HEIGHT: f32 = 56.0;
    pub const TWO_LINE_HEIGHT: f32 = 72.0;
    pub const THREE_LINE_HEIGHT: f32 = 88.0;
    pub const HORIZONTAL_PADDING: f32 = 16.0;
    pub const TRAILING_PADDING: f32 = 24.0;
    pub fn headline_color() -> Color {
        theme().on_surface
    }
    pub fn supporting_color() -> Color {
        theme().on_surface_variant
    }
}

/// Default values for top app bar.
pub struct TopAppBarDefaults;

impl TopAppBarDefaults {
    pub const HEIGHT: f32 = 64.0;
    pub fn container_color() -> Color {
        theme().surface
    }
    pub fn title_color() -> Color {
        theme().on_surface
    }
}

/// Default values for tab row.
pub struct TabDefaults;

impl TabDefaults {
    pub const HEIGHT: f32 = 48.0;
    pub const INDICATOR_HEIGHT: f32 = 3.0;
    pub const INDICATOR_CORNER: f32 = 1.5;
    pub fn container_color() -> Color {
        theme().surface
    }
    pub fn selected_content_color() -> Color {
        theme().primary
    }
    pub fn unselected_content_color() -> Color {
        theme().on_surface_variant
    }
    pub fn indicator_color() -> Color {
        theme().primary
    }
}

/// Default values for navigation bar.
pub struct NavigationBarDefaults;

impl NavigationBarDefaults {
    pub const HEIGHT: f32 = 80.0;
    pub const ITEM_ACTIVE_INDICATOR_OPACITY: f32 = 0.12;
    pub fn container_color() -> Color {
        theme().surface_container
    }
    pub fn selected_icon_color() -> Color {
        theme().primary
    }
    pub fn unselected_icon_color() -> Color {
        theme().on_surface_variant
    }
    pub fn indicator_color() -> Color {
        theme().primary
    }
}

/// Default values for navigation rail.
pub struct NavigationRailDefaults;

impl NavigationRailDefaults {
    pub const WIDTH: f32 = 80.0;
    pub fn container_color() -> Color {
        theme().surface
    }
    pub fn selected_icon_color() -> Color {
        theme().on_secondary_container
    }
    pub fn unselected_icon_color() -> Color {
        theme().on_surface_variant
    }
    pub fn selected_container_color() -> Color {
        theme().secondary_container
    }
}

/// Default values for segmented button.
pub struct SegmentedButtonDefaults;

impl SegmentedButtonDefaults {
    pub const HEIGHT: f32 = 40.0;
    pub const SHAPE_RADIUS: f32 = 20.0;
    pub fn border_color() -> Color {
        theme().outline
    }
    pub fn selected_container_color() -> Color {
        theme().secondary_container
    }
    pub fn selected_content_color() -> Color {
        theme().on_secondary_container
    }
    pub fn unselected_content_color() -> Color {
        theme().on_surface
    }
}

/// Default values for FAB.
pub struct FABDefaults;

impl FABDefaults {
    pub const SIZE: f32 = 56.0;
    pub const LARGE_SIZE: f32 = 96.0;
    pub const SHAPE_RADIUS: f32 = 28.0;
    pub const LARGE_SHAPE_RADIUS: f32 = 28.0;
    pub fn container_color() -> Color {
        theme().primary_container
    }
    pub fn content_color() -> Color {
        theme().on_primary_container
    }
    pub fn state_elevation() -> StateElevation {
        StateElevation {
            default: 6.0,
            hovered: 8.0,
            pressed: 12.0,
            disabled: 0.0,
        }
    }
}

/// Default values for chip components.
pub struct ChipDefaults;

impl ChipDefaults {
    pub const HEIGHT: f32 = 32.0;
    pub const HORIZONTAL_PADDING: f32 = 16.0;
    pub const SHAPE_RADIUS: f32 = 8.0;
    pub fn surface_color() -> Color {
        theme().surface
    }
    pub fn selected_container_color() -> Color {
        theme().secondary_container
    }
    pub fn selected_content_color() -> Color {
        theme().on_secondary_container
    }
    pub fn unselected_content_color() -> Color {
        theme().on_surface_variant
    }
    pub fn unselected_border_color() -> Color {
        theme().outline_variant
    }
    pub fn assist_icon_color() -> Color {
        theme().primary
    }
    pub fn input_selected_icon_color() -> Color {
        theme().primary
    }
    pub fn input_unselected_icon_color() -> Color {
        theme().on_surface_variant
    }
    pub fn suggestion_icon_color() -> Color {
        theme().primary
    }
}

/// Default values for scaffold layout.
pub struct ScaffoldDefaults;

impl ScaffoldDefaults {
    pub fn container_color() -> Color {
        theme().background
    }
    pub const TOP_BAR_HEIGHT: f32 = 64.0;
    pub const BOTTOM_BAR_HEIGHT: f32 = 80.0;
    pub const FAB_MARGIN: f32 = 16.0;
}

/// Default values for navigation drawer.
pub struct NavigationDrawerDefaults;

impl NavigationDrawerDefaults {
    pub const WIDTH: f32 = 300.0;
    pub fn container_color() -> Color {
        theme().surface_container_low
    }
    pub fn scrim_color() -> Color {
        theme().scrim.with_alpha(82)
    }
    pub const SHAPE_RADIUS: f32 = 16.0;
}

/// Default values for bottom sheet / modal bottom sheet.
pub struct BottomSheetDefaults;

impl BottomSheetDefaults {
    pub fn container_color() -> Color {
        theme().surface_container_low
    }
    pub fn drag_handle_color() -> Color {
        theme().on_surface_variant
    }
    pub fn scrim_color() -> Color {
        theme().scrim.with_alpha(85)
    }
    pub const DRAG_HANDLE_WIDTH: f32 = 32.0;
    pub const DRAG_HANDLE_HEIGHT: f32 = 4.0;
    pub const SHAPE_RADIUS: f32 = 16.0;
    pub const PEEK_HEIGHT: f32 = 56.0;
    pub const MAX_WIDTH: f32 = 640.0;
}

/// Default values for search bar.
pub struct SearchBarDefaults;

impl SearchBarDefaults {
    pub const HEIGHT: f32 = 56.0;
    pub const EXPANDED_WIDTH: f32 = 360.0;
    pub const COLLAPSED_WIDTH: f32 = 240.0;
    pub const DOCKED_HEIGHT: f32 = 400.0;
    pub fn container_color() -> Color {
        theme().surface_container
    }
    pub fn active_container_color() -> Color {
        theme().surface_container_high
    }
    pub fn content_color() -> Color {
        theme().on_surface
    }
    pub fn placeholder_color() -> Color {
        theme().on_surface_variant
    }
}

/// Default values for dropdown menu.
pub struct DropdownMenuDefaults;

impl DropdownMenuDefaults {
    pub const MIN_WIDTH: f32 = 112.0;
    pub const ITEM_HEIGHT: f32 = 40.0;
    pub fn container_color() -> Color {
        theme().surface_container
    }
    pub fn item_text_color() -> Color {
        theme().on_surface
    }
    pub fn disabled_item_text_color() -> Color {
        theme().on_surface.with_alpha_f32(0.38)
    }
    pub fn divider_color() -> Color {
        theme().outline_variant
    }
}

/// Default values for tooltip.
pub struct TooltipDefaults;

impl TooltipDefaults {
    pub const OFFSET_Y: f32 = -28.0;
    pub const HORIZONTAL_PADDING: f32 = 8.0;
    pub const VERTICAL_PADDING: f32 = 4.0;
    pub fn container_color() -> Color {
        theme().inverse_surface
    }
    pub fn content_color() -> Color {
        theme().inverse_on_surface
    }
}

/// Default values for pull-to-refresh.
pub struct PullToRefreshDefaults;

impl PullToRefreshDefaults {
    pub const THRESHOLD: f32 = 64.0;
    pub fn indicator_color() -> Color {
        theme().primary
    }
    pub fn container_color() -> Color {
        Color::TRANSPARENT
    }
}

/// Default values for alert dialog.
pub struct AlertDialogDefaults;

impl AlertDialogDefaults {
    pub const MIN_WIDTH: f32 = 280.0;
    pub const MAX_WIDTH: f32 = 560.0;
    pub const HORIZONTAL_PADDING: f32 = 24.0;
    pub fn scrim_color() -> Color {
        theme().scrim.with_alpha(170)
    }
}