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
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
//! Chainable `View` methods, generated from the `views` free functions.
//!
//! `swiftui!` lowers to this layer, so a modifier that exists only as a
//! `views::` free function cannot be written in the macro. These are the
//! wrappers that were missing, generated by `tools/gen_chainable.py` because
//! they are mechanical; `tests/dx_tests.rs` re-runs it and fails on drift.
use super::View;
use crate::views;
impl View {
/// Apply `.accessibilityAction(_:_:)`.
pub fn accessibility_action(self, kind: crate::views::ActionKind, action: impl Fn() + 'static) -> Self {
Self::new(views::accessibility_action(&self.handle, kind, action))
}
/// Apply `.accessibilityActions(category:_:)`.
pub fn accessibility_actions(self, category: crate::views::ActionCategory, content: View) -> Self {
Self::new(views::accessibility_actions(&self.handle, category, content.handle()))
}
/// Apply `.accessibilityActivationPoint(_:)`.
///
/// A `UnitPoint` is two `CGFloat`s and frozen, so it arrives in d0 and d1
/// rather than by address.
pub fn accessibility_activation_point(self, x: f64, y: f64) -> Self {
Self::new(views::accessibility_activation_point(&self.handle, x, y))
}
/// Apply `.accessibilityAddTraits(_:)`.
pub fn accessibility_add_traits(self, traits: &[crate::views::AccessibilityTrait]) -> Self {
Self::new(views::accessibility_add_traits(&self.handle, traits))
}
/// Apply `.accessibilityAdjustableAction(_:)`.
///
/// The direction reaches the callback as a case number: 0 is `.increment`,
/// 1 is `.decrement`.
pub fn accessibility_adjustable_action(self, action: impl Fn(i64) + 'static) -> Self {
Self::new(views::accessibility_adjustable_action(&self.handle, action))
}
/// Apply `.accessibilityChartDescriptor(_:)` with a synthesized representable.
///
/// No public SwiftUI type conforms to `AXChartDescriptorRepresentable` — the
/// protocol exists for applications to adopt — so the conformance is built at
/// run time and hung on `EdgeInsets`, which the reference can name too.
pub fn accessibility_chart_descriptor(self) -> Self {
Self::new(views::accessibility_chart_descriptor(&self.handle))
}
/// Apply `.accessibilityChildren(children:)`.
pub fn accessibility_children(self, children: View) -> Self {
Self::new(views::accessibility_children(&self.handle, children.handle()))
}
/// Apply `.accessibilityCustomContent(_:_:importance:)`.
///
/// The key is built first, through `AccessibilityCustomContentKey.init(_:id:)`
/// — four words of `LocalizedStringKey` and two of `String`, returning the key
/// through x8 because it is resilient. The modifier then takes that key by
/// address, its own label as another `LocalizedStringKey`, and the importance
/// in a register.
pub fn accessibility_custom_content(self, key_label: &str, id: &str, value: &str, importance: crate::views::CustomContentImportance) -> Self {
Self::new(views::accessibility_custom_content(&self.handle, key_label, id, value, importance))
}
/// Apply `.accessibilityDefaultFocus(_:_:)`.
///
/// The binding's `Value` is generic here, which makes `FocusState<A>.Binding`
/// address-only — unlike the concrete `focused(_:)`, where it travels in three
/// registers.
pub fn accessibility_default_focus(self, value: bool) -> Self {
Self::new(views::accessibility_default_focus(&self.handle, value))
}
/// Apply `.accessibility(identifier:)`, the pre-`accessibilityIdentifier` name.
pub fn accessibility_deprecated_identifier(self, id: &str) -> Self {
Self::new(views::accessibility_deprecated_identifier(&self.handle, id))
}
/// Apply `.accessibilityDirectTouch(_:options:)`.
pub fn accessibility_direct_touch(self, enabled: bool, options: &[crate::views::DirectTouchOption]) -> Self {
Self::new(views::accessibility_direct_touch(&self.handle, enabled, options))
}
/// Apply `.accessibilityDragPoint(_:description:isEnabled:)`.
pub fn accessibility_drag_point(self, x: f64, y: f64, description: &str, enabled: bool) -> Self {
Self::new(views::accessibility_drag_point(&self.handle, x, y, description, enabled))
}
/// Apply `.accessibilityDropPoint(_:description:isEnabled:)`.
pub fn accessibility_drop_point(self, x: f64, y: f64, description: &str, enabled: bool) -> Self {
Self::new(views::accessibility_drop_point(&self.handle, x, y, description, enabled))
}
/// Apply `.accessibilityElement(_:)`.
pub fn accessibility_element(self, v0: crate::views::AccessibilityChildBehavior) -> Self {
Self::new(views::accessibility_element(&self.handle, v0))
}
/// Apply `.accessibilityFocused(_:)`.
pub fn accessibility_focused(self) -> Self {
Self::new(views::accessibility_focused(&self.handle))
}
/// Apply `.accessibilityHeading(_:)`.
pub fn accessibility_heading(self, level: crate::views::HeadingLevel) -> Self {
Self::new(views::accessibility_heading(&self.handle, level))
}
/// Apply `.accessibilityHidden(_:)`.
pub fn accessibility_hidden(self, hidden: bool) -> Self {
Self::new(views::accessibility_hidden(&self.handle, hidden))
}
/// Apply `.accessibilityHint(_:)`.
pub fn accessibility_hint(self, hint: &str) -> Self {
Self::new(views::accessibility_hint(&self.handle, hint))
}
/// Apply `.accessibilityIdentifier(_:)`.
pub fn accessibility_identifier(self, id: &str) -> Self {
Self::new(views::accessibility_identifier(&self.handle, id))
}
/// Apply `.accessibilityIgnoresInvertColors(_:)`.
pub fn accessibility_ignores_invert_colors(self, value: bool) -> Self {
Self::new(views::accessibility_ignores_invert_colors(&self.handle, value))
}
pub fn accessibility_input_labels(self, labels: &[&str], enabled: bool) -> Self {
Self::new(views::accessibility_input_labels(&self.handle, labels, enabled))
}
/// Apply `.accessibilityLabel(_:)`.
pub fn accessibility_label(self, label: &str) -> Self {
Self::new(views::accessibility_label(&self.handle, label))
}
/// Apply `.accessibilityLabeledPair(role:id:in:)`.
pub fn accessibility_labeled_pair<'h>(self, role: crate::views::LabeledPairRole, id: impl crate::views::IntoHashable<'h>) -> Self {
Self::new(views::accessibility_labeled_pair(&self.handle, role, id.into_hashable()))
}
/// Apply `.accessibilityLinkedGroup(id:in:)`.
pub fn accessibility_linked_group<'h>(self, id: impl crate::views::IntoHashable<'h>) -> Self {
Self::new(views::accessibility_linked_group(&self.handle, id.into_hashable()))
}
/// Apply `.accessibilityRemoveTraits(_:)`.
pub fn accessibility_remove_traits(self, traits: &[crate::views::AccessibilityTrait]) -> Self {
Self::new(views::accessibility_remove_traits(&self.handle, traits))
}
/// Apply `.accessibilityRepresentation(representation:)`.
pub fn accessibility_representation(self, representation: View) -> Self {
Self::new(views::accessibility_representation(&self.handle, representation.handle()))
}
/// Apply `.accessibilityRespondsToUserInteraction(_:)`.
pub fn accessibility_responds_to_user_interaction(self, responds: bool) -> Self {
Self::new(views::accessibility_responds_to_user_interaction(&self.handle, responds))
}
/// Apply `.accessibilityRotor(_:textRanges:)`.
///
/// The ranges are real `Range<String.Index>` values taken from `text` — one
/// spanning the whole string. `Range` is frozen and its two bounds are stored
/// back to back, so the array elements are built directly rather than through an
/// initialiser.
pub fn accessibility_rotor(self, label: &str, text: &str) -> Self {
Self::new(views::accessibility_rotor(&self.handle, label, text))
}
/// Apply `.accessibilityRotorEntry(id:in:)`.
pub fn accessibility_rotor_entry<'h>(self, id: impl crate::views::IntoHashable<'h>) -> Self {
Self::new(views::accessibility_rotor_entry(&self.handle, id.into_hashable()))
}
/// Apply `.accessibilityScrollAction(_:)`.
///
/// The edge reaches the callback as a case number, in `Edge`'s declared order:
/// top, leading, bottom, trailing.
pub fn accessibility_scroll_action(self, action: impl Fn(i64) + 'static) -> Self {
Self::new(views::accessibility_scroll_action(&self.handle, action))
}
/// Apply `.accessibilityScrollStatus(_:isEnabled:)`.
pub fn accessibility_scroll_status(self, status: &str, enabled: bool) -> Self {
Self::new(views::accessibility_scroll_status(&self.handle, status, enabled))
}
/// `.accessibility(selectionIdentifier:)` — which item of a selectable group
/// this is, for assistive technologies.
///
/// Deprecated in Swift, with no modern replacement — `accessibilityIdentifier`
/// is a different thing (a test hook). Bound because it is the one member of
/// that family the crate could not otherwise reach.
///
/// The argument is `AnyHashable`, which is three words: the boxed value, its
/// metadata and its `Hashable` witness.
pub fn accessibility_selection_identifier<'h>(self, id: impl crate::views::IntoHashable<'h>) -> Self {
Self::new(views::accessibility_selection_identifier(&self.handle, id.into_hashable()))
}
/// Apply `.accessibilityShowsLargeContentViewer(_:)`.
pub fn accessibility_shows_large_content_viewer(self) -> Self {
Self::new(views::accessibility_shows_large_content_viewer(&self.handle))
}
/// Apply `.accessibilitySortPriority(_:)`.
pub fn accessibility_sort_priority(self, priority: f64) -> Self {
Self::new(views::accessibility_sort_priority(&self.handle, priority))
}
/// Apply `.accessibilityTextContentType(_:)`.
pub fn accessibility_text_content_type(self, kind: crate::views::TextContentType) -> Self {
Self::new(views::accessibility_text_content_type(&self.handle, kind))
}
/// Apply `.accessibilityValue(_:isEnabled:)`.
pub fn accessibility_value(self, value: &str, enabled: bool) -> Self {
Self::new(views::accessibility_value(&self.handle, value, enabled))
}
/// Apply `.accessibilityZoomAction(_:)`.
pub fn accessibility_zoom_action(self, action: impl Fn() + 'static) -> Self {
Self::new(views::accessibility_zoom_action(&self.handle, action))
}
/// `.actionSheet(isPresented:content:)` — the iOS sheet of choices.
///
/// Deprecated by Apple in favour of `confirmationDialog`, and bound because the
/// catalogue still lists it and an app targeting an older iOS has nothing else.
///
/// `presented` is a constant, so the sheet cannot dismiss itself; use
/// `action_sheet_bound` for one the user can close.
#[cfg(not(target_os = "macos"))]
pub fn action_sheet(self, title: &str, message: Option<&str>, buttons: Vec<crate::views::AlertButton<'_>>) -> Self {
Self::new(views::action_sheet(&self.handle, title, message, buttons))
}
/// `.actionSheet` bound to Rust state, so dismissing it writes `false` back.
#[cfg(not(target_os = "macos"))]
pub fn action_sheet_bound(self, title: &str, message: Option<&str>, buttons: Vec<crate::views::AlertButton<'_>>, state: &crate::views::BoundState<bool>) -> Self {
Self::new(views::action_sheet_bound(&self.handle, title, message, buttons, state))
}
/// Apply `.allowedDynamicRange(_:)`.
pub fn allowed_dynamic_range(self, range: crate::views::DynamicRange) -> Self {
Self::new(views::allowed_dynamic_range(&self.handle, range))
}
/// Apply `.allowsHitTesting(_:)`.
pub fn allows_hit_testing(self, value: bool) -> Self {
Self::new(views::allows_hit_testing(&self.handle, value))
}
/// Apply `.allowsTightening(_:)`.
pub fn allows_tightening(self, value: bool) -> Self {
Self::new(views::allows_tightening(&self.handle, value))
}
/// Apply `.allowsWindowActivationEvents(_:)`.
pub fn allows_window_activation_events(self, allows: Option<bool>) -> Self {
Self::new(views::allows_window_activation_events(&self.handle, allows))
}
/// `.animation(_:value:)` with the curve named.
pub fn animation_kind(self, kind: crate::views::AnimationKind, value: i64) -> Self {
Self::new(views::animation_kind(&self.handle, kind, value))
}
/// `.aspectRatio(_:contentMode:)` with the mode named rather than spelled as a
/// `bool`.
///
/// `None` for the ratio means "keep whatever the content already has", which is
/// not the same as `Some(1.0)`.
pub fn aspect_ratio_content_mode(self, ratio: Option<f64>, mode: crate::views::ContentMode) -> Self {
Self::new(views::aspect_ratio_content_mode(&self.handle, ratio, mode))
}
/// `.autocapitalization(_:)`.
///
/// Deprecated in SwiftUI in favour of
/// `text_input_autocapitalization`, and bound because Apple's catalogue still
/// lists it and a caller targeting an older iOS has nothing else.
#[cfg(not(target_os = "macos"))]
pub fn autocapitalization(self, style: crate::views::Autocapitalization) -> Self {
Self::new(views::autocapitalization(&self.handle, style))
}
/// Apply `.background(_:)` with a Color.
pub fn background(self, r: f64, g: f64, b: f64, a: f64) -> Self {
Self::new(views::background(&self.handle, r, g, b, a))
}
/// Apply `.background(_:)` with an `AnyGradient` — what `.indigo.gradient` is.
pub fn background_any_gradient(self, color: u64) -> Self {
Self::new(views::background_any_gradient(&self.handle, color))
}
/// Apply `.background(alignment:content:)`.
///
/// The same call as `.overlay(alignment:content:)` with a different symbol:
/// an `Alignment` in x0/x1, the content closure and its context in x2/x3, four
/// generic words after that. The colour-taking `background` next door is a
/// different overload entirely — that one is generic over `ShapeStyle`, this
/// one over `View`.
pub fn background_content(self, content: View, alignment: crate::views::Alignment) -> Self {
Self::new(views::background_content(&self.handle, content.handle(), alignment))
}
/// Apply `.backgroundExtensionEffect(_:)`.
pub fn background_extension_effect(self) -> Self {
Self::new(views::background_extension_effect(&self.handle))
}
/// Apply `.background(in:fillStyle:)` — the background style, clipped to a shape.
///
/// The shape must be `InsettableShape`, not merely `Shape`, so its witness is a
/// different table from the one `super::Shape` carries.
pub fn background_in_circle(self) -> Self {
Self::new(views::background_in_circle(&self.handle))
}
/// Apply `.background(LinearGradient(colors:startPoint:endPoint:))`.
pub fn background_linear_gradient(self, colors: &[crate::Color], start: (f64, f64), end: (f64, f64)) -> Self {
Self::new(views::background_linear_gradient(&self.handle, colors, start, end))
}
/// Apply `.background(_: Material)` — the blur materials.
pub fn background_material(self, kind: crate::views::MaterialKind) -> Self {
Self::new(views::background_material(&self.handle, kind))
}
/// Apply `.background(RadialGradient(colors:center:startRadius:endRadius:))`.
pub fn background_radial_gradient(self, colors: &[crate::Color], center: (f64, f64), start_radius: f64, end_radius: f64) -> Self {
Self::new(views::background_radial_gradient(&self.handle, colors, center, start_radius, end_radius))
}
/// `.backgroundStyle(_:)` with a `Color`.
///
/// `background_style_of` takes the style as raw bytes and a witness, which
/// is what an arbitrary `ShapeStyle` needs and what nothing can call without
/// building one first. These three name the styles that have a Rust spelling,
/// so the modifier is reachable the way the documentation writes it.
///
/// Not `.background(_:)`: that draws behind *this* view, while this says what
/// style the views *inside* should use for their own backgrounds.
pub fn background_style_color(self, r: f64, g: f64, b: f64, a: f64) -> Self {
Self::new(views::background_style_color(&self.handle, r, g, b, a))
}
/// `.backgroundStyle(_:)` with one of the hierarchical levels.
pub fn background_style_hierarchical(self, level: crate::views::Hierarchical) -> Self {
Self::new(views::background_style_hierarchical(&self.handle, level))
}
/// `.backgroundStyle(_:)` with an already-resolved `Color` word.
pub fn background_style_value(self, color: u64) -> Self {
Self::new(views::background_style_value(&self.handle, color))
}
/// Apply `.badge(_:)`.
pub fn badge(self, value: i64) -> Self {
Self::new(views::badge(&self.handle, value))
}
/// Apply `.border(_:width:)` with a `Color` that is already built.
///
/// For one of SwiftUI's named colours: `Color.gray` is semantic and no set of
/// components spells it. See `system_color`.
pub fn border_value(self, color: u64, width: f64) -> Self {
Self::new(views::border_value(&self.handle, color, width))
}
/// Apply `.buttonStyle(.glass(.clear))`.
///
/// `.glass(_:)` is a static on a `PrimitiveButtonStyle` extension constrained
/// to `GlassButtonStyle` — the shape that has been inlinable every other time
/// in this file. This one is exported, which is only knowable by looking.
pub fn button_style_glass_clear(self) -> Self {
Self::new(views::button_style_glass_clear(&self.handle))
}
/// Apply `.clipShape(RoundedRectangle(cornerRadius:))`.
pub fn clip_rounded_rect(self, radius: f64) -> Self {
Self::new(views::clip_rounded_rect(&self.handle, radius))
}
/// Apply `.clipShape(RoundedRectangle(cornerRadius:style:))`.
///
/// As with `super::rounded_rectangle_styled`, the style is not optional here
/// even though Swift source can leave it out: leaving it out means
/// `.continuous`, and writing case 0 builds the other shape.
pub fn clip_rounded_rect_styled(self, radius: f64, continuous: bool) -> Self {
Self::new(views::clip_rounded_rect_styled(&self.handle, radius, continuous))
}
/// Apply `.colorEffect(_:)` — recolours each pixel.
pub fn color_effect(self, shader: &crate::metal::Shader) -> Self {
Self::new(crate::metal::color_effect(&self.handle, shader))
}
/// Apply `.colorInvert(_:)`.
pub fn color_invert(self) -> Self {
Self::new(views::color_invert(&self.handle))
}
/// `confirmationDialog(…actions:message:)` with a fixed flag, which cannot be
/// dismissed — see `confirmation_dialog`.
pub fn confirmation_message(self, title: &str, actions: View, message: View, presented: bool) -> Self {
Self::new(views::confirmation_message(&self.handle, title, actions.handle(), message.handle(), presented))
}
/// `.containerValue(\.key, value)` for a key defined here.
///
/// What the `@_alwaysEmitIntoClient` modifier's body does, since the modifier
/// itself exports no symbol: build a `_ContainerValueWritingModifier` and apply
/// it with `.modifier(_:)`.
pub fn container_value<T: crate::views::KeyValue>(self, key: &crate::views::CustomContainerKey<T>, value: impl crate::views::IntoKeyValue<T>) -> Self {
Self::new(views::container_value(&self.handle, key, value))
}
/// `.contentToolbar(for:content:)` — a toolbar attached to a container's
/// content rather than to the window.
///
/// The `Content: View` overload, which is the one that takes an ordinary view
/// builder; the `ToolbarContent` overload is a different symbol.
///
/// iOS only. See `ContentToolbarPlacement` — there is no macOS case to pass.
#[cfg(not(target_os = "macos"))]
pub fn content_toolbar(self, placement: crate::views::ContentToolbarPlacement, content: View) -> Self {
Self::new(views::content_toolbar(&self.handle, placement, content.handle()))
}
/// Apply `.cornerRadius(_:)`.
pub fn corner_radius(self, radius: f64) -> Self {
Self::new(views::corner_radius(&self.handle, radius))
}
/// `.animation(Animation(curve), value:)` with a curve written in Rust.
pub fn custom_animation(self, curve: &crate::views::CustomAnimationCurve, value: i64) -> Self {
Self::new(views::custom_animation(&self.handle, curve, value))
}
/// `.buttonStyle(_:)` with a style written in Rust.
pub fn custom_button_style(self, style: &crate::views::CustomButtonStyle) -> Self {
Self::new(views::custom_button_style(&self.handle, style))
}
/// `.labelStyle(_:)` with a style written in Rust.
pub fn custom_label_style(self, style: &crate::views::CustomLabelStyle) -> Self {
Self::new(views::custom_label_style(&self.handle, style))
}
/// `.modifier(_:)` with a modifier written in Rust.
///
/// The result is `ModifiedContent<Self, RustModifier>` — a concrete type, not an
/// opaque one, because `modifier<T>(_:)` says so. `T` is unconstrained there, so
/// no witness table is passed at the call: SwiftUI finds the conformance by
/// lookup when it renders, which is exactly why registering it matters.
pub fn custom_modifier(self, modifier: &crate::views::CustomModifier) -> Self {
Self::new(views::custom_modifier(&self.handle, modifier))
}
/// `.transition(_:)` with a transition written in Rust.
///
/// Wrapped in an `AnyTransition` on the way, because that is what
/// `transition<T: Transition>(_:)` does: it is `@_alwaysEmitIntoClient` and
/// exports no symbol, so the binding calls what its body calls.
pub fn custom_transition(self, transition: &crate::views::CustomTransition) -> Self {
Self::new(views::custom_transition(&self.handle, transition))
}
/// `.defaultHoverEffect(_:)` with the effect named.
///
/// See `default_hover_effect_highlight` for why this is iOS-only.
#[cfg(not(target_os = "macos"))]
pub fn default_hover_effect(self, effect: crate::views::HoverEffect) -> Self {
Self::new(views::default_hover_effect(&self.handle, effect))
}
/// Apply `.defaultHoverEffect(_:)` with `.highlight`.
///
/// Marked `@available(macOS, unavailable)`, which is a *source* restriction:
/// the compiler refuses the call, but `$s7SwiftUI4ViewPAAE18defaultHoverEffect…`
/// is in the export table all the same. Searching for the symbol and finding it
/// is not evidence the call works — the macOS implementation is a trap stub,
/// the same as `hoverEffect` next door — so this is compiled out there rather
/// than left to die at run time.
///
/// The argument is `HoverEffect?`, and `HoverEffect` is resilient: `.highlight`
/// comes back through x8 and is then handed over by address.
#[cfg(not(target_os = "macos"))]
pub fn default_hover_effect_highlight(self) -> Self {
Self::new(views::default_hover_effect_highlight(&self.handle))
}
/// `.defersSystemGestures(on:)` — hold off the home indicator and Control Centre
/// swipes on the named edges.
///
/// `Edge.Set` is an option set over one byte, read out of SwiftUI's own static
/// rather than written as a bitmask.
#[cfg(not(target_os = "macos"))]
pub fn defers_system_gestures(self, edges: crate::views::EdgeSet) -> Self {
Self::new(views::defers_system_gestures(&self.handle, edges))
}
/// Apply `.deleteDisabled(_:)`.
pub fn delete_disabled(self, value: bool) -> Self {
Self::new(views::delete_disabled(&self.handle, value))
}
/// Apply `.dialogIcon(_:)`.
pub fn dialog_icon(self, system_name: Option<&str>) -> Self {
Self::new(views::dialog_icon(&self.handle, system_name))
}
/// Apply `.dialogPreventsAppTermination(_:)`.
pub fn dialog_prevents_app_termination(self, prevents: Option<bool>) -> Self {
Self::new(views::dialog_prevents_app_termination(&self.handle, prevents))
}
pub fn dialog_severity(self, value: crate::views::DialogSeverity) -> Self {
Self::new(views::dialog_severity(&self.handle, value))
}
/// Apply `.dialogSuppressionToggle(isSuppressed:)`.
pub fn dialog_suppression_toggle(self, state: &crate::views::BoundState<bool>) -> Self {
Self::new(views::dialog_suppression_toggle(&self.handle, state))
}
/// Apply `.dialogSuppressionToggle(_:isSuppressed:)` with a label.
///
/// Seven integer arguments — four for the key, three for the binding — so
/// `Self.Type` and the witness table travel on the stack rather than in
/// registers.
pub fn dialog_suppression_toggle_labelled(self, label: &str, state: &crate::views::BoundState<bool>) -> Self {
Self::new(views::dialog_suppression_toggle_labelled(&self.handle, label, state))
}
/// Apply `.disableAutocorrection(_:)`.
pub fn disable_autocorrection(self, disable: Option<bool>) -> Self {
Self::new(views::disable_autocorrection(&self.handle, disable))
}
/// Apply `.distortionEffect(_:maxSampleOffset:)` — warps geometry.
pub fn distortion_effect(self, shader: &crate::metal::Shader, max_w: f64, max_h: f64) -> Self {
Self::new(crate::metal::distortion_effect(&self.handle, shader, max_w, max_h))
}
/// Attach a `DragGesture`.
pub fn drag_gesture(self, minimum_distance: f64) -> Self {
Self::new(views::drag_gesture(&self.handle, minimum_distance))
}
/// Apply `.draggable(_:)` with a `String` payload.
///
/// The overload everything else calls `draggable`: drag this view and a piece
/// of text comes out, droppable anywhere that takes one. The
/// `containerItemID:` binding next door is a different modifier for a
/// different job — reordering within a container.
///
/// `String` because it is the `Transferable` conformer that needs no bridging:
/// its witness is exported from CoreTransferable, and its value is two loadable
/// words. A `Data` or a `URL` payload would each need their own.
pub fn draggable_text(self, text: &str) -> Self {
Self::new(views::draggable_text(&self.handle, text))
}
/// `.environment(model)` — put the model where every view below can read it.
///
/// The `Observable` overload. A body that reads a property of the model through
/// `Model::get` while SwiftUI is tracking it is re-run when that property
/// changes; one that reads a *different* property is not.
pub fn environment_model(self, model: &crate::observable::Model) -> Self {
Self::new(crate::observable::environment_model(&self.handle, model))
}
/// `.environment(\.key, value)` for a key defined here.
pub fn environment_value<T: crate::views::KeyValue>(self, key: &crate::views::CustomEnvKey<T>, value: impl crate::views::IntoKeyValue<T>) -> Self {
Self::new(views::environment_value(&self.handle, key, value))
}
/// `.equatable()` — wrap a view in `EquatableView`, whatever its type.
///
/// `equatable_text` does this for a `Text` and nothing else, because the
/// mangled name it resolves names `Text`. The constraint is
/// `Content: Equatable & View`, and whether a given type satisfies it is a
/// question the runtime can answer — so this asks, instead of the binding
/// deciding in advance which one type is allowed.
///
/// The bound is genuine, not a limitation here: a view erased into `AnyView`
/// is not `Equatable` and cannot be made so. That is what the panic says, and
/// it is the same thing Swift's type checker would say at the call site.
///
/// Wrapping is the whole of it — `equatable()` is `@inlinable` with the body
/// `EquatableView(content: self)`, and `EquatableView` stores only its
/// content, so the value is the content's own bytes copied through its value
/// witness. A raw `memcpy` would work for a `Text` and leak a reference for
/// anything holding one.
pub fn equatable(self) -> Self {
Self::new(views::equatable(&self.handle))
}
pub fn file_dialog_browser_options(self, value: crate::views::FileDialogBrowserOptions) -> Self {
Self::new(views::file_dialog_browser_options(&self.handle, value))
}
/// Apply `.fileDialogConfirmationLabel(_:)`.
pub fn file_dialog_confirmation_label(self, value: &str) -> Self {
Self::new(views::file_dialog_confirmation_label(&self.handle, value))
}
/// Apply `.fileDialogCustomizationID(_:)`.
pub fn file_dialog_customization_id(self, value: &str) -> Self {
Self::new(views::file_dialog_customization_id(&self.handle, value))
}
/// Apply `.fileDialogDefaultDirectory(_:)`.
pub fn file_dialog_default_directory(self, path: Option<&str>) -> Self {
Self::new(views::file_dialog_default_directory(&self.handle, path))
}
/// Apply `.fileDialogImportsUnresolvedAliases(_:)`.
pub fn file_dialog_imports_unresolved_aliases(self, value: bool) -> Self {
Self::new(views::file_dialog_imports_unresolved_aliases(&self.handle, value))
}
/// Apply `.fileDialogMessage(_:)`.
pub fn file_dialog_message(self, value: &str) -> Self {
Self::new(views::file_dialog_message(&self.handle, value))
}
/// Apply `.fileDialogURLEnabled(_:)`.
///
/// The argument is a `Foundation.Predicate<Pack{URL}>`, which the `#Predicate`
/// macro normally builds from an expression tree at compile time. `Predicate`
/// also exposes `.true` and `.false` as statics, and those are values rather
/// than syntax — so they are reachable from here, where an arbitrary predicate
/// is not.
///
/// The type is generic over a *parameter pack*, whose mangling closes with
/// `_QP` rather than directly; see `crate::mangle::pack`.
pub fn file_dialog_url_enabled(self, enabled: bool) -> Self {
Self::new(views::file_dialog_url_enabled(&self.handle, enabled))
}
/// Apply `.fileExporterFilenameLabel(_:)`.
pub fn file_exporter_filename_label(self, value: &str) -> Self {
Self::new(views::file_exporter_filename_label(&self.handle, value))
}
/// Apply `.findDisabled(_:)`.
pub fn find_disabled(self, value: bool) -> Self {
Self::new(views::find_disabled(&self.handle, value))
}
/// Apply `.flipsForRightToLeftLayoutDirection(_:)`.
pub fn flips_for_right_to_left_layout_direction(self, value: bool) -> Self {
Self::new(views::flips_for_right_to_left_layout_direction(&self.handle, value))
}
/// Apply `.focusEffectDisabled(_:)`.
pub fn focus_effect_disabled(self, value: bool) -> Self {
Self::new(views::focus_effect_disabled(&self.handle, value))
}
/// Apply `.focusSection(_:)`.
pub fn focus_section(self) -> Self {
Self::new(views::focus_section(&self.handle))
}
/// Apply `.focused(_:)` with a real, installed `@FocusState`.
///
/// `focused` applies the same modifier with a `FocusState` built on the spot,
/// which is what SwiftUI stores either way but leaves nothing to read or move.
/// This takes the projection of a property SwiftUI has installed, so
/// `crate::state::ComposedView::focus` reports whether the field has focus
/// and `crate::state::ComposedView::set_focus` puts it there.
pub fn focused_on(self, projection: [u64; 3]) -> Self {
Self::new(views::focused_on(&self.handle, projection))
}
/// Apply `.focusedSceneObject(_:)`.
pub fn focused_scene_object(self) -> Self {
Self::new(views::focused_scene_object(&self.handle))
}
/// `.focusedSceneValue(keyPath, value)` — publish a value for the whole scene.
///
/// What a window tells the menu bar about its selection. The scene form is the
/// one commands read; `focused_value_keyed` is the same thing scoped to
/// whatever currently has focus.
pub fn focused_scene_value<T: crate::views::KeyValue>(self, key: &crate::views::FocusKey<T>, value: impl crate::views::IntoKeyValue<T>) -> Self {
Self::new(views::focused_scene_value(&self.handle, key, value))
}
/// `.focusedValue(keyPath, value)` — publish a value for the focused view.
pub fn focused_value_keyed<T: crate::views::KeyValue>(self, key: &crate::views::FocusKey<T>, value: impl crate::views::IntoKeyValue<T>) -> Self {
Self::new(views::focused_value_keyed(&self.handle, key, value))
}
/// `.focusedValue(model)` — publish the model for the commands above it.
///
/// The object form of what `crate::views::focused_scene_value` does with a key
/// path, and the one Apple now recommends: a key is a type, and an `@Observable`
/// object already is one.
pub fn focused_value_model(self, model: &crate::observable::Model) -> Self {
Self::new(crate::observable::focused_value_model(&self.handle, model))
}
/// Apply an already-built raw `Font` value with `.font(_:)`.
pub fn font_apply(self, font: u64) -> Self {
Self::new(views::font_apply(&self.handle, font))
}
/// Apply `.font(.custom(_:size:))`.
pub fn font_custom(self, name: &str, size: f64) -> Self {
Self::new(views::font_custom(&self.handle, name, size))
}
/// Apply `.font(.system(size:weight:design:))`.
pub fn font_system(self, size: f64, weight: Option<crate::views::Weight>, design: Option<crate::views::Design>) -> Self {
Self::new(views::font_system(&self.handle, size, weight, design))
}
/// Apply `.font(_:)` with one of the built-in text styles.
pub fn font_text_style(self, style: crate::views::TextStyle) -> Self {
Self::new(views::font_text_style(&self.handle, style))
}
/// Apply `.fontWeight(_:)`.
pub fn font_weight(self, weight: crate::views::Weight) -> Self {
Self::new(views::font_weight(&self.handle, weight))
}
/// Apply `.foregroundColor(_:)`.
pub fn foreground_color(self, color: Option<crate::Color>) -> Self {
Self::new(views::foreground_color(&self.handle, color))
}
/// Apply `.foregroundColor(_:)`, the deprecated environment-writing one.
///
/// Not `foreground_style_color`: this produces
/// `_EnvironmentKeyWritingModifier<Color?>` and that produces
/// `_ForegroundStyleModifier<Color>`. They render the same.
/// Apply `.foregroundColor(_:)` to a `Color` that is already built.
///
/// For one of SwiftUI's named colours, which no set of components can spell.
/// See `super::system_color`.
pub fn foreground_color_value(self, color: u64) -> Self {
Self::new(views::foreground_color_value(&self.handle, color))
}
/// Apply `.foregroundStyle(_:)` with a colour.
///
/// Named for what it does, not for `.foregroundColor(_:)` — which is deprecated
/// and a different thing: it writes an environment key, producing
/// `_EnvironmentKeyWritingModifier<Color?>` where this produces
/// `_ForegroundStyleModifier<Color>`. The two render alike, so only a
/// type-level comparison tells them apart. See `foreground_color` for the
/// other one.
pub fn foreground_style_color(self, r: f64, g: f64, b: f64, a: f64) -> Self {
Self::new(views::foreground_style_color(&self.handle, r, g, b, a))
}
/// Apply `.foregroundStyle(.linearGradient(colors:startPoint:endPoint:))`.
///
/// The shorthand in Swift source is a protocol-extension static marked
/// `@inlinable`, so it has no symbol; the `LinearGradient` it builds does.
/// Apply `.foregroundStyle(_:)` with one of the hierarchical levels —
/// `.secondary` and friends.
pub fn foreground_style_hierarchical(self, level: crate::views::Hierarchical) -> Self {
Self::new(views::foreground_style_hierarchical(&self.handle, level))
}
pub fn foreground_style_linear_gradient(self, colors: &[u64], start: (f64, f64), end: (f64, f64)) -> Self {
Self::new(views::foreground_style_linear_gradient(&self.handle, colors, start, end))
}
/// Apply `.foregroundStyle(_:_:)` — a primary and a secondary style.
///
/// What `symbolRenderingMode(.palette)` needs: a palette symbol takes its
/// layers from successive styles, and with only one it renders as monochrome.
pub fn foreground_style_pair(self, primary: u64, secondary: u64) -> Self {
Self::new(views::foreground_style_pair(&self.handle, primary, secondary))
}
/// Apply `.foregroundStyle(_:_:_:)` — three styles.
///
/// A palette symbol takes its layers from successive styles.
/// `foreground_style_pair` covers the two-layer symbols; the three-layer
/// ones — and there are plenty in SF Symbols — rendered their third layer in
/// the secondary colour, because there was no way to say what it should be.
///
/// Eleven words of arguments, so three spill: the three style addresses and
/// `Self.Type` fill x0–x3, the three style types and the `Self: View` witness
/// take x4–x7, and all *three* `ShapeStyle` witnesses go to the stack.
///
/// Spilling only two of them — which is easy to do, since the pair version next
/// door fits in eight words exactly and spills none — left the callee reading a
/// stale word as a witness table. It did not fault there: it faulted much later
/// inside `swift::MetadataCacheKey::operator==`, recursing on a type built from
/// the garbage, which is what an argument-count mistake looks like from the
/// outside.
pub fn foreground_style_triple(self, primary: u64, secondary: u64, tertiary: u64) -> Self {
Self::new(views::foreground_style_triple(&self.handle, primary, secondary, tertiary))
}
/// Apply `.foregroundStyle(_:)` to a `Color` that is already built.
///
/// The components overload above cannot express `Color.blue`: SwiftUI's named
/// colours are semantic, not literal, and resolve per appearance — the aqua
/// `Color.blue` is nowhere near `(0, 0, 1)`. This takes the value a static
/// getter handed back instead. See `super::system_color`.
pub fn foreground_style_value(self, color: u64) -> Self {
Self::new(views::foreground_style_value(&self.handle, color))
}
/// Apply `.frame(maxWidth:maxHeight:alignment:)` with `.infinity` for both.
///
/// Six `Optional<CGFloat>`s — min, ideal and max for each axis — then an
/// `Alignment`, then the two generic words. Each optional is payload and tag,
/// so that is sixteen words in all: x0 through x7 carry the first four
/// optionals and the remaining eight go on the stack. The generic arguments
/// come *after* every formal parameter, which is what makes them spill; putting
/// them in x6 and x7 builds a frame out of the metadata pointers.
pub fn frame_max_infinity(self, alignment: crate::views::Alignment) -> Self {
Self::new(views::frame_max_infinity(&self.handle, alignment))
}
/// Apply `.frame(maxWidth: .infinity)` — the *width* only.
///
/// Not `frame_max_infinity`, which sets both axes. Swift's
/// `.frame(maxWidth: .infinity)` leaves `maxHeight` nil, so the view keeps its
/// content's height; setting both stretched a card to fill its canvas and moved
/// everything in it.
///
/// Six `Optional<CGFloat>`s — min, ideal and max for each axis — then an
/// `Alignment`, then the two generic words. Each optional is payload and tag,
/// so that is sixteen words in all: x0 through x7 carry the first four
/// optionals and the remaining eight go on the stack. The generic arguments
/// come *after* every formal parameter, which is what makes them spill; putting
/// them in x6 and x7 builds a frame out of the metadata pointers.
pub fn frame_max_width(self, alignment: crate::views::Alignment) -> Self {
Self::new(views::frame_max_width(&self.handle, alignment))
}
/// `.fullScreenCover(isPresented:onDismiss:content:)` with a fixed flag.
///
/// As with `super::sheet`, a constant binding is read-only: the cover cannot
/// dismiss itself, because there is nowhere for SwiftUI to write `false`. Use
/// `full_screen_cover_bound` for one the user can close.
#[cfg(not(target_os = "macos"))]
pub fn full_screen_cover(self, content: View, presented: bool) -> Self {
Self::new(views::full_screen_cover(&self.handle, content.handle(), presented))
}
/// `.fullScreenCover` bound to Rust state, so dismissing it writes `false` back.
#[cfg(not(target_os = "macos"))]
pub fn full_screen_cover_bound(self, content: View, state: &crate::views::BoundState<bool>) -> Self {
Self::new(views::full_screen_cover_bound(&self.handle, content.handle(), state))
}
/// `.fullScreenCover` with the `onDismiss:` closure spelled out.
#[cfg(not(target_os = "macos"))]
pub fn full_screen_cover_bound_dismiss(self, content: View, state: &crate::views::BoundState<bool>, on_dismiss: impl Fn() + 'static) -> Self {
Self::new(views::full_screen_cover_bound_dismiss(&self.handle, content.handle(), state, on_dismiss))
}
/// `.gesture(_:including:)`.
pub fn gesture<V: crate::views::GestureData>(self, g: &crate::views::GestureValue<V>, mask: crate::views::GestureMask) -> Self {
Self::new(views::gesture(&self.handle, g, mask))
}
/// Apply `.glassEffect()` — Liquid Glass, in its default shape.
///
/// The result type is a `StaticIf<GlassEnabledPredicate, ...>`: SwiftUI picks
/// between the glass-modified view and the original at runtime depending on
/// whether the platform has Liquid Glass enabled.
pub fn glass_effect(self) -> Self {
Self::new(views::glass_effect(&self.handle))
}
/// Apply `.glassEffectID(_:in:)`.
pub fn glass_effect_id<'h>(self, id: Option<impl crate::views::IntoHashable<'h>>) -> Self {
Self::new(views::glass_effect_id(&self.handle, id.map(crate::views::IntoHashable::into_hashable)))
}
/// The same, with the variant named.
///
/// `Identity` is the no-op: it still builds the `StaticIf`, so the view's type
/// is the one a glass effect gives it, with nothing drawn. That is what makes
/// it usable as the "off" end of a condition without the two branches
/// disagreeing about their type.
pub fn glass_effect_kind(self, glass: crate::views::Glass) -> Self {
Self::new(views::glass_effect_kind(&self.handle, glass))
}
pub fn glass_effect_transition(self, value: crate::views::GlassEffectTransition) -> Self {
Self::new(views::glass_effect_transition(&self.handle, value))
}
/// Apply `.glassEffectUnion(id:namespace:)`.
pub fn glass_effect_union<'h>(self, id: Option<impl crate::views::IntoHashable<'h>>) -> Self {
Self::new(views::glass_effect_union(&self.handle, id.map(crate::views::IntoHashable::into_hashable)))
}
/// Apply `.gridCellColumns(_:)`.
pub fn grid_cell_columns(self, value: i64) -> Self {
Self::new(views::grid_cell_columns(&self.handle, value))
}
/// Apply `.help(_:)`.
pub fn help(self, value: &str) -> Self {
Self::new(views::help(&self.handle, value))
}
/// Apply `.help(_:)`.
pub fn help_text(self, value: &str) -> Self {
Self::new(views::help_text(&self.handle, value))
}
/// `.highPriorityGesture(_:including:)` — this gesture wins over the view's own.
pub fn high_priority_gesture_of<V: crate::views::GestureData>(self, g: &crate::views::GestureValue<V>, mask: crate::views::GestureMask) -> Self {
Self::new(views::high_priority_gesture_of(&self.handle, g, mask))
}
/// Apply `.horizontalRadioGroupLayout(_:)`.
pub fn horizontal_radio_group_layout(self) -> Self {
Self::new(views::horizontal_radio_group_layout(&self.handle))
}
/// Apply `.hoverEffect()` — the effect a bare call means, which is
/// `AutomaticHoverEffect`.
///
/// Not available on macOS, for the reason `hover_effect_lift` gives.
#[cfg(not(target_os = "macos"))]
pub fn hover_effect_automatic(self) -> Self {
Self::new(views::hover_effect_automatic(&self.handle))
}
/// `.indexViewStyle(PageIndexViewStyle(backgroundDisplayMode:))` — the page dots
/// under a paged `TabView`.
///
/// iOS only. `PageIndexViewStyle` is the only `IndexViewStyle` SwiftUI ships, so
/// there is nothing to choose between — what there *is* to choose is when the
/// dots get a backdrop, which is the argument.
#[cfg(not(target_os = "macos"))]
pub fn index_view_style_page(self, background: crate::views::IndexBackground) -> Self {
Self::new(views::index_view_style_page(&self.handle, background))
}
/// Apply `.interactionActivityTrackingTag(_:)`.
pub fn interaction_activity_tracking_tag(self, value: &str) -> Self {
Self::new(views::interaction_activity_tracking_tag(&self.handle, value))
}
/// Apply `.interactiveDismissDisabled(_:)`.
pub fn interactive_dismiss_disabled(self, value: bool) -> Self {
Self::new(views::interactive_dismiss_disabled(&self.handle, value))
}
/// Apply `.invalidatableContent(_:)`.
pub fn invalidatable_content(self, value: bool) -> Self {
Self::new(views::invalidatable_content(&self.handle, value))
}
/// `.keyboardType(_:)`.
#[cfg(not(target_os = "macos"))]
pub fn keyboard_type(self, kind: crate::views::KeyboardType) -> Self {
Self::new(views::keyboard_type(&self.handle, kind))
}
/// Apply `.labelIconToTitleSpacing(_:)`.
pub fn label_icon_to_title_spacing(self, value: f64) -> Self {
Self::new(views::label_icon_to_title_spacing(&self.handle, value))
}
/// Apply `.labelReservedIconWidth(_:)`.
pub fn label_reserved_icon_width(self, value: f64) -> Self {
Self::new(views::label_reserved_icon_width(&self.handle, value))
}
/// Apply `.labelsHidden(_:)`.
pub fn labels_hidden(self) -> Self {
Self::new(views::labels_hidden(&self.handle))
}
/// Apply `.layerEffect(_:maxSampleOffset:)` — can sample neighbouring pixels.
pub fn layer_effect(self, shader: &crate::metal::Shader, max_w: f64, max_h: f64) -> Self {
Self::new(crate::metal::layer_effect(&self.handle, shader, max_w, max_h))
}
/// Apply `.layoutPriority(_:)`.
pub fn layout_priority(self, value: f64) -> Self {
Self::new(views::layout_priority(&self.handle, value))
}
/// Apply `.layoutValue(key:value:)` with a runtime-synthesized key.
///
/// A second protocol through the same machinery as `preference_int`, to show
/// nothing about it is specific to `PreferenceKey`.
pub fn layout_value_int(self, value: i64) -> Self {
Self::new(views::layout_value_int(&self.handle, value))
}
/// Apply `.listItemTint(_:)`.
///
/// `None` clears the tint, which is the `nil` the modifier's `ListItemTint?`
/// parameter takes.
pub fn list_item_tint(self, tint: Option<crate::views::ListItemTint>) -> Self {
Self::new(views::list_item_tint(&self.handle, tint))
}
/// Attach a `LongPressGesture` with `.gesture(_:including:)`.
pub fn long_press_gesture(self, duration: f64, max_distance: f64) -> Self {
Self::new(views::long_press_gesture(&self.handle, duration, max_distance))
}
/// Apply `.luminanceToAlpha(_:)`.
pub fn luminance_to_alpha(self) -> Self {
Self::new(views::luminance_to_alpha(&self.handle))
}
/// Attach a `MagnifyGesture`.
pub fn magnify_gesture(self, minimum_scale_delta: f64) -> Self {
Self::new(views::magnify_gesture(&self.handle, minimum_scale_delta))
}
/// Apply `.minimumScaleFactor(_:)`.
pub fn minimum_scale_factor(self, value: f64) -> Self {
Self::new(views::minimum_scale_factor(&self.handle, value))
}
/// Apply `.monospacedDigit(_:)`.
pub fn monospaced_digit(self) -> Self {
Self::new(views::monospaced_digit(&self.handle))
}
/// Apply `.moveDisabled(_:)`.
pub fn move_disabled(self, value: bool) -> Self {
Self::new(views::move_disabled(&self.handle, value))
}
/// Apply `.multilineTextAlignment(_:)`.
pub fn multiline_alignment(self, align: crate::views::TextAlign) -> Self {
Self::new(views::multiline_alignment(&self.handle, align))
}
/// Apply `.navigationBarBackButtonHidden(_:)`.
pub fn navigation_bar_back_button_hidden(self, value: bool) -> Self {
Self::new(views::navigation_bar_back_button_hidden(&self.handle, value))
}
/// `.navigationBarHidden(_:)`.
#[cfg(not(target_os = "macos"))]
pub fn navigation_bar_hidden(self, hidden: bool) -> Self {
Self::new(views::navigation_bar_hidden(&self.handle, hidden))
}
/// `.navigationBarTitleDisplayMode(_:)`.
///
/// The mode is a resilient enum, so it goes by address and its tag is read from
/// reflection rather than written down — see `abi::enum_case_index`.
#[cfg(not(target_os = "macos"))]
pub fn navigation_bar_title_display_mode(self, mode: crate::views::TitleDisplayMode) -> Self {
Self::new(views::navigation_bar_title_display_mode(&self.handle, mode))
}
/// Apply `.navigationSplitViewStyle(_:)`.
pub fn navigation_split_view_style(self, style: crate::views::SplitViewStyle) -> Self {
Self::new(views::navigation_split_view_style(&self.handle, style))
}
/// Apply `.navigationSubtitle(_:)`.
pub fn navigation_subtitle(self, value: &str) -> Self {
Self::new(views::navigation_subtitle(&self.handle, value))
}
/// Apply `.navigationSubtitle(_:)`.
pub fn navigation_subtitle_text(self, value: &str) -> Self {
Self::new(views::navigation_subtitle_text(&self.handle, value))
}
/// `.navigationViewStyle(.columns)` — the two-column split.
///
/// The witness is looked up at run time rather than named: a
/// `NavigationViewStyle` conformance mangles its substitutions against the
/// words in its *own* type name, so `ColumnNavigationViewStyle`'s is not
/// `DefaultNavigationViewStyle`'s with a letter changed. Copying one has
/// produced a witness for the wrong protocol in this crate before.
pub fn navigation_view_style_columns(self) -> Self {
Self::new(views::navigation_view_style_columns(&self.handle))
}
/// `.navigationViewStyle(.doubleColumn)` — sidebar plus detail.
pub fn navigation_view_style_double_column(self) -> Self {
Self::new(views::navigation_view_style_double_column(&self.handle))
}
/// `.navigationViewStyle(.stack)` — one view at a time, pushed and popped.
///
/// `@available(macOS, unavailable)`, so iOS only.
#[cfg(not(target_os = "macos"))]
pub fn navigation_view_style_stack(self) -> Self {
Self::new(views::navigation_view_style_stack(&self.handle))
}
/// Apply `.onContinuousHover(coordinateSpace:perform:)`.
pub fn on_continuous_hover(self, space: crate::views::CoordinateSpace, perform: impl Fn(crate::views::HoverPhase) + 'static) -> Self {
Self::new(views::on_continuous_hover(&self.handle, space, perform))
}
/// The same, with the value SwiftUI delivered.
///
/// `on_drag_gesture`'s handler is told only *that* a drag ended. This one is
/// told where it started, where it finished and how fast it was going — see
/// `DragValue`.
pub fn on_drag_ended_value(self, minimum_distance: f64, action: impl Fn(crate::views::DragValue) + 'static) -> Self {
Self::new(views::on_drag_ended_value(&self.handle, minimum_distance, action))
}
/// Attach a `DragGesture` with an `onEnded` handler.
///
/// `drag_gesture` attaches a bare `DragGesture` with nothing listening, which
/// builds the same value Swift would but can never be seen to fire. This wires
/// the action SwiftUI calls when the drag ends, so the gesture is observable.
///
/// The result type is taken from `.gesture`'s opaque-result-type descriptor
/// rather than a hand-written mangling: the type is
/// `ModifiedContent<AnyView, AddGestureModifier<_EndedGesture<DragGesture>, _>>`,
/// and spelling that out by hand is how earlier bindings resolved to null.
pub fn on_drag_gesture(self, minimum_distance: f64, action: impl Fn() + 'static) -> Self {
Self::new(views::on_drag_gesture(&self.handle, minimum_distance, action))
}
/// Apply `.onLongPressGesture(minimumDuration:maximumDistance:pressing:perform:)`.
///
/// Unlike `long_press_gesture`, which attaches a bare `LongPressGesture` with
/// nothing listening, this takes the action SwiftUI runs when the press
/// completes — so the gesture can be observed rather than only built.
pub fn on_long_press_gesture(self, duration: f64, max_distance: f64, action: impl Fn() + 'static) -> Self {
Self::new(views::on_long_press_gesture(&self.handle, duration, max_distance, action))
}
/// Attach a `MagnifyGesture` with an `onEnded` handler.
pub fn on_magnify_ended(self, minimum_scale_delta: f64, action: impl Fn(crate::views::MagnifyValue) + 'static) -> Self {
Self::new(views::on_magnify_ended(&self.handle, minimum_scale_delta, action))
}
/// Apply `.onPencilDoubleTap(perform:)`.
pub fn on_pencil_double_tap(self, action: impl Fn() + 'static) -> Self {
Self::new(views::on_pencil_double_tap(&self.handle, action))
}
/// Apply `.onPencilSqueeze(perform:)`.
pub fn on_pencil_squeeze(self, action: impl Fn() + 'static) -> Self {
Self::new(views::on_pencil_squeeze(&self.handle, action))
}
/// Apply `.onPreferenceChange(_:perform:)`, recording the value.
///
/// The value is read back through `observed_preference`. `K.Value` must also
/// be `Equatable` here, so the call carries two witness tables for the one
/// generic parameter.
pub fn on_preference_change_int(self) -> Self {
Self::new(views::on_preference_change_int(&self.handle))
}
/// Attach a `RotateGesture` with an `onEnded` handler.
pub fn on_rotate_ended(self, minimum_degrees: f64, action: impl Fn(crate::views::RotateValue) + 'static) -> Self {
Self::new(views::on_rotate_ended(&self.handle, minimum_degrees, action))
}
/// Apply `.onTapGesture(count:perform:)`.
/// The action may capture, as `super::button`'s may — a tap handler that
/// cannot know which row it is on is one every list has to route around.
pub fn on_tap_gesture(self, count: i64, action: impl Fn() + 'static) -> Self {
Self::new(views::on_tap_gesture(&self.handle, count, action))
}
/// `.padding(_: EdgeInsets)` — a different inset per edge.
///
/// `padding_set` takes one length for a set of edges; this takes four. The
/// insets go in d0–d3, being a homogeneous float aggregate.
pub fn padding_insets(self, insets: crate::views::EdgeInsets) -> Self {
Self::new(views::padding_insets(&self.handle, insets))
}
/// Apply `.padding(_:_:)` — chosen edges, an explicit length.
///
/// `edges` is an `Edge.Set` bit pattern: 1 top, 2 leading, 4 bottom, 8 trailing,
/// so `.vertical` is 5 and `.all` is 15. A `None` length means the system's own
/// inset, as in `padding_default`.
/// `.padding(_:_:)` with the edges named rather than spelled as a bitmask.
///
/// `padding_edges` takes the raw option-set bits, which a caller has to know;
/// this reads the member out of SwiftUI's own `Edge.Set` instead.
pub fn padding_set(self, edges: crate::views::EdgeSet, length: Option<f64>) -> Self {
Self::new(views::padding_set(&self.handle, edges, length))
}
/// Apply `.preference(key:value:)` with a runtime-synthesized key.
///
/// The key type carries a `PreferenceKey` conformance built by
/// `crate::conformance` at run time, and its `Value` is `Int`. No Swift
/// source declares it, which is the whole point: this is the one family of
/// modifiers that expects the *client* to supply a conformance.
pub fn preference_int(self, value: i64) -> Self {
Self::new(views::preference_int(&self.handle, value))
}
/// Apply `.preferredColorScheme(_:)` — light or dark for this subtree.
pub fn preferred_color_scheme(self, scheme: crate::views::ColorScheme) -> Self {
Self::new(views::preferred_color_scheme(&self.handle, scheme))
}
/// Apply `.presentedWindowStyle(_:)`.
pub fn presented_window_style(self, style: crate::views::WindowStyle) -> Self {
Self::new(views::presented_window_style(&self.handle, style))
}
/// Apply `.presentedWindowToolbarStyle(_:)`.
pub fn presented_window_toolbar_style(self, style: crate::views::WindowToolbarStyle) -> Self {
Self::new(views::presented_window_toolbar_style(&self.handle, style))
}
/// Apply `.previewContext(_:)`.
pub fn preview_context(self) -> Self {
Self::new(views::preview_context(&self.handle))
}
/// Apply `.previewDevice(_:)`.
pub fn preview_device(self, name: Option<&str>) -> Self {
Self::new(views::preview_device(&self.handle, name))
}
/// Apply `.previewDisplayName(_:)`.
pub fn preview_display_name(self, name: Option<&str>) -> Self {
Self::new(views::preview_display_name(&self.handle, name))
}
pub fn preview_interface_orientation(self, value: crate::views::InterfaceOrientation) -> Self {
Self::new(views::preview_interface_orientation(&self.handle, value))
}
/// Apply `.previewLayout(_:)`.
pub fn preview_layout(self, layout: crate::views::PreviewLayout) -> Self {
Self::new(views::preview_layout(&self.handle, layout))
}
/// Apply `.privacySensitive(_:)`.
pub fn privacy_sensitive(self, value: bool) -> Self {
Self::new(views::privacy_sensitive(&self.handle, value))
}
/// Apply `.progressViewStyle(_:)`.
///
/// Not missing after all. Searching the export table for `progressViewStyle`
/// finds nothing because the mangling compresses `ViewStyle` to
/// `08progressC5Style` — `C` substitutes the `View` of the enclosing
/// `SwiftUI.View` — so the spelled-out name never appears. The SIL for one line
/// of Swift names it outright.
///
/// `.linear` and `.automatic` are `@_alwaysEmitIntoClient` statics with no
/// symbol of their own; the structs they return have plain initialisers, which
/// is what this needs.
pub fn progress_view_style(self, style: crate::views::ProgressStyle) -> Self {
Self::new(views::progress_view_style(&self.handle, style))
}
/// Apply `.replaceDisabled(_:)`.
pub fn replace_disabled(self, value: bool) -> Self {
Self::new(views::replace_disabled(&self.handle, value))
}
/// Attach a `RotateGesture`. The minimum delta is an `Angle`, i.e. radians.
pub fn rotate_gesture(self, minimum_degrees: f64) -> Self {
Self::new(views::rotate_gesture(&self.handle, minimum_degrees))
}
/// Apply `.rotationEffect(.degrees(_), anchor:)`.
pub fn rotation(self, degrees: f64, anchor_x: f64, anchor_y: f64) -> Self {
Self::new(views::rotation(&self.handle, degrees, anchor_x, anchor_y))
}
/// Apply `.rotation3DEffect(_:axis:)`.
pub fn rotation_3d(self, degrees: f64, ax: f64, ay: f64, az: f64) -> Self {
Self::new(views::rotation_3d(&self.handle, degrees, ax, ay, az))
}
/// Apply `.scaledToFill(_:)`.
pub fn scaled_to_fill(self) -> Self {
Self::new(views::scaled_to_fill(&self.handle))
}
/// Apply `.scaledToFit(_:)`.
pub fn scaled_to_fit(self) -> Self {
Self::new(views::scaled_to_fit(&self.handle))
}
/// Apply `.scenePadding(_:)`.
pub fn scene_padding(self, v0: crate::views::ScenePadding, v1: crate::views::EdgeSet) -> Self {
Self::new(views::scene_padding(&self.handle, v0, v1))
}
/// Apply `.scrollClipDisabled(_:)`.
pub fn scroll_clip_disabled(self, value: bool) -> Self {
Self::new(views::scroll_clip_disabled(&self.handle, value))
}
/// Apply `.scrollDisabled(_:)`.
pub fn scroll_disabled(self, value: bool) -> Self {
Self::new(views::scroll_disabled(&self.handle, value))
}
/// `.scrollPosition(_:anchor:)` — scroll to an edge, and stay bound to it.
///
/// `scroll_position_id` is the other overload, which scrolls to a row by its
/// identity. This one takes a whole `ScrollPosition`, which is what
/// "scrolled to the top" is: there is no row to name.
///
/// The position lives in the binding for the life of the view. SwiftUI writes
/// back as the user scrolls, so it has to be somewhere that outlives the call
/// that made it.
pub fn scroll_position_edge(self, edge: crate::views::Edge) -> Self {
Self::new(views::scroll_position_edge(&self.handle, edge))
}
/// Apply `.searchCompletion(_:)`.
pub fn search_completion(self, value: &str) -> Self {
Self::new(views::search_completion(&self.handle, value))
}
/// `.signInWithAppleButtonStyle(_:)`.
///
/// Declared on `View` in the overlay, so its mangled name says `SwiftUI.View`
/// with the overlay as the extension's module — which is why it resolves in the
/// overlay's image and not in SwiftUI's.
pub fn sign_in_with_apple_button_style(self, style: crate::views::AppleButtonStyle) -> Self {
Self::new(views::sign_in_with_apple_button_style(&self.handle, style))
}
/// `.simultaneousGesture(_:including:)` — both this and the view's own run.
pub fn simultaneous_gesture_of<V: crate::views::GestureData>(self, g: &crate::views::GestureValue<V>, mask: crate::views::GestureMask) -> Self {
Self::new(views::simultaneous_gesture_of(&self.handle, g, mask))
}
/// Apply `.speechAdjustedPitch(_:)`.
pub fn speech_adjusted_pitch(self, value: f64) -> Self {
Self::new(views::speech_adjusted_pitch(&self.handle, value))
}
/// Apply `.speechAlwaysIncludesPunctuation(_:)`.
pub fn speech_always_includes_punctuation(self, value: bool) -> Self {
Self::new(views::speech_always_includes_punctuation(&self.handle, value))
}
/// Apply `.speechAnnouncementsQueued(_:)`.
pub fn speech_announcements_queued(self, value: bool) -> Self {
Self::new(views::speech_announcements_queued(&self.handle, value))
}
/// Apply `.speechSpellsOutCharacters(_:)`.
pub fn speech_spells_out_characters(self, value: bool) -> Self {
Self::new(views::speech_spells_out_characters(&self.handle, value))
}
/// `.statusBarHidden(_:)`.
///
/// Reached through `statusBar(hidden:)`. `statusBarHidden` is
/// `@_alwaysEmitIntoClient`, so it exports no symbol of its own — its body is
/// this call, which is what a Swift caller compiles to.
#[cfg(not(target_os = "macos"))]
pub fn status_bar_hidden(self, hidden: bool) -> Self {
Self::new(views::status_bar_hidden(&self.handle, hidden))
}
/// Apply `.submitScope(_:)`.
pub fn submit_scope(self, value: bool) -> Self {
Self::new(views::submit_scope(&self.handle, value))
}
/// Apply `.symbolColorRenderingMode(_:)`.
pub fn symbol_color_rendering_mode(self, mode: crate::views::SymbolColorRendering) -> Self {
Self::new(views::symbol_color_rendering_mode(&self.handle, mode))
}
/// `.symbolEffect(_:)` with any of the indefinite effects.
///
/// The case tag is *read* from the enum's reflection rather than written down:
/// `SymbolEffectConfiguration.Effect` numbers its cases in declaration order,
/// which is not the order the documentation lists them — `.variableColor` is 2
/// and `.scale` is 3, where reading down the page would say otherwise. A wrong
/// tag builds a valid value of the wrong case, which renders, and renders
/// wrongly. See `abi::enum_case_index`.
pub fn symbol_effect(self, effect: crate::views::SymbolEffect) -> Self {
Self::new(views::symbol_effect(&self.handle, effect))
}
/// Apply `.symbolVariableValueMode(_:)`.
pub fn symbol_variable_value_mode(self, mode: crate::views::SymbolVariableValue) -> Self {
Self::new(views::symbol_variable_value_mode(&self.handle, mode))
}
/// `.tabViewCustomization(_:)` with a live customization, not `nil`.
///
/// `tab_view_customization_none` passes `nil`, which is the "do not persist
/// anything" case and the only one that needed no value. This builds a real
/// `TabViewCustomization` and hands SwiftUI a binding to it, so the user's
/// reordering and hiding of tabs is kept — the whole point of the modifier.
///
/// The value lives in the binding's closures for the life of the process: a
/// customization SwiftUI can write back to has to outlive the call that made
/// it, and there is nowhere else to put it.
pub fn tab_view_customization(self) -> Self {
Self::new(views::tab_view_customization(&self.handle))
}
/// `.tabViewSearchActivation(_:)`.
pub fn tab_view_search_activation(self, activation: crate::views::TabSearchActivation) -> Self {
Self::new(views::tab_view_search_activation(&self.handle, activation))
}
/// Apply `.tabViewStyle(_:)`.
pub fn tab_view_style(self, style: crate::views::TabStyle) -> Self {
Self::new(views::tab_view_style(&self.handle, style))
}
/// Apply `.task { … }` — the spelling with no `id:`.
///
/// A different modifier from `task`, not a default-argument version of it:
/// that one builds `_TaskValueModifier2<ID>` and re-runs when the id changes,
/// this one builds `_TaskModifier2` and runs once. `_TaskModifier2` is not
/// generic, so there are no generic words to spill.
///
/// The `name` carries the call site — SwiftUI records `View.task @ file:line` —
/// so a value comparison against a reference only agrees if the caller passes
/// the reference's own file and line, which is why they are parameters.
pub fn task_once(self, priority: crate::views::TaskPriority, file: &str, line: i64, action: impl Fn() + Send + Sync + 'static) -> Self {
Self::new(views::task_once(&self.handle, priority, file, line, action))
}
/// `Text.baselineOffset(_:)`
pub fn text_baseline_offset(self, amount: f64) -> Self {
Self::new(views::text_baseline_offset(&self.handle, amount))
}
/// `Text.bold()` — the one that returns `Text`.
///
/// Returns the `View` extension's result if this is not a `Text`: that is what a
/// caller wants there, and it is what every one of these used to do.
pub fn text_bold(self) -> Self {
Self::new(views::text_bold(&self.handle))
}
/// `Text.font(_:)` — the overload that returns `Text`.
///
/// `Text("x").font(.body).bold()` stays a `Text` all the way through in Swift
/// precisely because this returns one; going through the `View` extension for
/// the font is what made the rest of the chain fall back to the environment
/// forms. `None` clears the font.
pub fn text_font(self, font: Option<&crate::views::Font>) -> Self {
Self::new(views::text_font(&self.handle, font))
}
/// `Text.fontWeight(_:)` — the overload that returns `Text`.
///
/// `Font.Weight?` lowers to two words, a payload and a tag, which land ahead of
/// `self` — so this is the one shape the single-word helper cannot serve.
/// `None` clears the weight.
pub fn text_font_weight(self, weight: Option<crate::views::Weight>) -> Self {
Self::new(views::text_font_weight(&self.handle, weight))
}
/// `Text.foregroundColor(_:)` — the overload that returns `Text`.
pub fn text_foreground_color(self, color: crate::Color) -> Self {
Self::new(views::text_foreground_color(&self.handle, color))
}
/// `Text.foregroundStyle(_:)` with one of the hierarchical styles.
pub fn text_foreground_hierarchical(self, level: crate::views::Hierarchical) -> Self {
Self::new(views::text_foreground_hierarchical(&self.handle, level))
}
/// `Text.foregroundStyle(LinearGradient(...))`.
pub fn text_foreground_linear_gradient(self, colors: &[u64], start: (f64, f64), end: (f64, f64)) -> Self {
Self::new(views::text_foreground_linear_gradient(&self.handle, colors, start, end))
}
/// `.textInputAutocapitalization(_:)`. `None` means `nil` — defer to the field.
///
/// The argument is `TextInputAutocapitalization?`, an optional wrapping a
/// resilient struct. The payload is whatever the static getter writes; the
/// discriminator goes in through `storeEnumTagSinglePayload` on the *payload's*
/// witness table, which is the rule `abi::store_optional_tag` exists to keep.
#[cfg(not(target_os = "macos"))]
pub fn text_input_autocapitalization(self, style: Option<crate::views::TextInputCapitalization>) -> Self {
Self::new(views::text_input_autocapitalization(&self.handle, style))
}
/// Apply `.textInputCompletion(_:)`.
pub fn text_input_completion(self, value: &str) -> Self {
Self::new(views::text_input_completion(&self.handle, value))
}
/// `Text.italic()`
pub fn text_italic(self) -> Self {
Self::new(views::text_italic(&self.handle))
}
/// `Text.kerning(_:)` — space added between every pair of characters.
pub fn text_kerning(self, amount: f64) -> Self {
Self::new(views::text_kerning(&self.handle, amount))
}
/// `Text.monospaced(_:)`
pub fn text_monospaced(self) -> Self {
Self::new(views::text_monospaced(&self.handle))
}
/// `Text.tracking(_:)` — like kerning, but not suppressed between the pairs the
/// font has a ligature for.
pub fn text_tracking(self, amount: f64) -> Self {
Self::new(views::text_tracking(&self.handle, amount))
}
/// Apply `.tint(_:)` through the `Color?` overload.
///
/// `View.tint` has two: one generic over `ShapeStyle`, which `tint` calls and
/// which yields `_EnvironmentKeyWritingModifier<AnyShapeStyle?>`, and one taking
/// a plain `Color?`, which yields `…<Color?>`. Swift picks the second for
/// `.tint(.white)`, so a reference written that way disagrees with the first on
/// both type and value.
pub fn tint_color(self, color: u64) -> Self {
Self::new(views::tint_color(&self.handle, color))
}
/// The same, with the item placed somewhere other than `.automatic`.
pub fn toolbar_customizable_placed(self, toolbar_id: &str, item_id: &str, placement: crate::views::ToolbarItemPlacement, shows_by_default: bool, content: View) -> Self {
Self::new(views::toolbar_customizable_placed(&self.handle, toolbar_id, item_id, placement, shows_by_default, content.handle()))
}
/// Apply `.toolbarItemHidden(_:)`.
pub fn toolbar_item_hidden(self, value: bool) -> Self {
Self::new(views::toolbar_item_hidden(&self.handle, value))
}
/// Apply `.toolbar { ToolbarItem(placement:) { content } }`.
///
/// `toolbar` above is this with `.automatic`, which is what the placement
/// argument defaults to in Swift.
pub fn toolbar_placed(self, placement: crate::views::ToolbarItemPlacement, content: View) -> Self {
Self::new(views::toolbar_placed(&self.handle, placement, content.handle()))
}
/// Apply `.touchBar(content:)`.
pub fn touch_bar(self, content: View) -> Self {
Self::new(views::touch_bar(&self.handle, content.handle()))
}
/// Apply `.touchBarCustomizationLabel(_:)`.
pub fn touch_bar_customization_label(self, value: &str) -> Self {
Self::new(views::touch_bar_customization_label(&self.handle, value))
}
/// Apply `.touchBarItemPresence(_:)`.
///
/// The enum holds a `String`, which makes it larger than four words and so
/// address-only: the argument is a pointer to a buffer this builds, with the
/// string's two words written first and the tag injected by the enum's own
/// witness afterwards.
#[cfg(target_os = "macos")]
pub fn touch_bar_item_presence(self, presence: crate::views::TouchBarItemPresence, identifier: &str) -> Self {
Self::new(views::touch_bar_item_presence(&self.handle, presence, identifier))
}
/// Apply `.touchBarItemPrincipal(_:)`.
pub fn touch_bar_item_principal(self, value: bool) -> Self {
Self::new(views::touch_bar_item_principal(&self.handle, value))
}
/// Apply `.transformPreference(_:_:)`, doubling the value in place.
pub fn transform_preference_double(self) -> Self {
Self::new(views::transform_preference_double(&self.handle))
}
/// Apply `.transition(.opacity)`.
///
/// `AnyTransition` is eight bytes — a single class reference — so it is
/// *loadable*: its static getters return it in x0 and it is passed by value.
/// Reading it through an indirect (`x8`) return, as the larger resilient types
/// like `Material` and `Glass` require, yields an uninitialised buffer whose
/// contents are then released as if they were an object.
pub fn transition_opacity(self) -> Self {
Self::new(views::transition_opacity(&self.handle))
}
/// Apply `.transition(.slide)` — in from the leading edge, out to the trailing.
pub fn transition_slide(self) -> Self {
Self::new(views::transition_slide(&self.handle))
}
/// Apply `.typesettingLanguage(_:)`.
pub fn typesetting_language(self, v0: crate::views::TypesettingLanguage, v1: bool) -> Self {
Self::new(views::typesetting_language(&self.handle, v0, v1))
}
/// Apply `.unredacted(_:)`.
pub fn unredacted(self) -> Self {
Self::new(views::unredacted(&self.handle))
}
/// `.opacity(_:)`, taking `Color`'s own overload when the receiver is a `Color`.
///
/// `Color.opacity(_:)` returns `Color` — the same shape as `Text.bold()` and
/// `Image.resizable()`, and the reason Apple's `Color.primary.opacity(0.1)`
/// types as a plain `Color` where the `View` extension gives
/// `ModifiedContent<Color, _OpacityEffect>`. Both render identically; only one
/// is the type the listing has.
pub fn view_opacity(self, value: f64) -> Self {
Self::new(views::view_opacity(&self.handle, value))
}
pub fn window_dismiss_behavior(self, value: crate::views::WindowInteractionBehavior) -> Self {
Self::new(views::window_dismiss_behavior(&self.handle, value))
}
pub fn window_full_screen_behavior(self, value: crate::views::WindowInteractionBehavior) -> Self {
Self::new(views::window_full_screen_behavior(&self.handle, value))
}
pub fn window_minimize_behavior(self, value: crate::views::WindowInteractionBehavior) -> Self {
Self::new(views::window_minimize_behavior(&self.handle, value))
}
pub fn window_resize_behavior(self, value: crate::views::WindowInteractionBehavior) -> Self {
Self::new(views::window_resize_behavior(&self.handle, value))
}
pub fn window_toolbar_full_screen_visibility(self, value: crate::views::WindowToolbarFullScreenVisibility) -> Self {
Self::new(views::window_toolbar_full_screen_visibility(&self.handle, value))
}
/// Apply `.writingDirection(strategy:)`.
pub fn writing_direction(self, strategy: crate::views::WritingDirectionStrategy) -> Self {
Self::new(views::writing_direction(&self.handle, strategy))
}
/// Apply `.writingToolsAffordanceVisibility(_:)`.
pub fn writing_tools_affordance_visibility(self, value: crate::views::Visibility) -> Self {
Self::new(views::writing_tools_affordance_visibility(&self.handle, value))
}
pub fn writing_tools_behavior(self, value: crate::views::WritingToolsBehavior) -> Self {
Self::new(views::writing_tools_behavior(&self.handle, value))
}
}