@maccesar/titools 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS-TEMPLATE.md +173 -0
- package/README.md +867 -0
- package/agents/ti-researcher.md +108 -0
- package/bin/titools.js +53 -0
- package/lib/commands/agents.js +126 -0
- package/lib/commands/install.js +188 -0
- package/lib/commands/uninstall.js +215 -0
- package/lib/commands/update.js +159 -0
- package/lib/config.js +119 -0
- package/lib/downloader.js +153 -0
- package/lib/installer.js +253 -0
- package/lib/platform.js +108 -0
- package/lib/symlink.js +142 -0
- package/lib/utils.js +270 -0
- package/package.json +67 -0
- package/skills/alloy-expert/SKILL.md +247 -0
- package/skills/alloy-expert/assets/ControllerAutoCleanup.js +182 -0
- package/skills/alloy-expert/references/alloy-structure.md +381 -0
- package/skills/alloy-expert/references/anti-patterns.md +133 -0
- package/skills/alloy-expert/references/code-conventions.md +469 -0
- package/skills/alloy-expert/references/contracts.md +280 -0
- package/skills/alloy-expert/references/controller-patterns.md +520 -0
- package/skills/alloy-expert/references/error-handling.md +484 -0
- package/skills/alloy-expert/references/examples.md +735 -0
- package/skills/alloy-expert/references/migration-patterns.md +298 -0
- package/skills/alloy-expert/references/patterns.md +448 -0
- package/skills/alloy-expert/references/performance-patterns.md +855 -0
- package/skills/alloy-expert/references/security-patterns.md +847 -0
- package/skills/alloy-expert/references/state-management.md +779 -0
- package/skills/alloy-expert/references/testing.md +872 -0
- package/skills/alloy-guides/SKILL.md +214 -0
- package/skills/alloy-guides/references/CLI_TASKS.md +243 -0
- package/skills/alloy-guides/references/CONCEPTS.md +191 -0
- package/skills/alloy-guides/references/CONTROLLERS.md +298 -0
- package/skills/alloy-guides/references/MODELS.md +1028 -0
- package/skills/alloy-guides/references/PURGETSS.md +56 -0
- package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +242 -0
- package/skills/alloy-guides/references/VIEWS_STYLES.md +388 -0
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +109 -0
- package/skills/alloy-guides/references/VIEWS_XML.md +558 -0
- package/skills/alloy-guides/references/WIDGETS.md +176 -0
- package/skills/alloy-howtos/SKILL.md +203 -0
- package/skills/alloy-howtos/references/best_practices.md +138 -0
- package/skills/alloy-howtos/references/cli_reference.md +253 -0
- package/skills/alloy-howtos/references/config_files.md +87 -0
- package/skills/alloy-howtos/references/custom_tags.md +147 -0
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +101 -0
- package/skills/alloy-howtos/references/samples.md +167 -0
- package/skills/purgetss/SKILL.md +442 -0
- package/skills/purgetss/assets/purgetss.config.cjs +17 -0
- package/skills/purgetss/references/EXAMPLES.md +247 -0
- package/skills/purgetss/references/animation-system.md +1294 -0
- package/skills/purgetss/references/apply-directive.md +375 -0
- package/skills/purgetss/references/arbitrary-values.md +612 -0
- package/skills/purgetss/references/class-index.md +1350 -0
- package/skills/purgetss/references/cli-commands.md +948 -0
- package/skills/purgetss/references/configurable-properties.md +654 -0
- package/skills/purgetss/references/custom-rules.md +161 -0
- package/skills/purgetss/references/customization-deep-dive.md +722 -0
- package/skills/purgetss/references/dynamic-component-creation.md +489 -0
- package/skills/purgetss/references/grid-layout.md +455 -0
- package/skills/purgetss/references/icon-fonts.md +609 -0
- package/skills/purgetss/references/installation-setup.md +366 -0
- package/skills/purgetss/references/opacity-modifier.md +291 -0
- package/skills/purgetss/references/platform-modifiers.md +479 -0
- package/skills/purgetss/references/smart-mappings.md +42 -0
- package/skills/purgetss/references/titanium-resets.md +359 -0
- package/skills/purgetss/references/ui-ux-design.md +1526 -0
- package/skills/ti-guides/SKILL.md +94 -0
- package/skills/ti-guides/references/advanced-data-and-images.md +19 -0
- package/skills/ti-guides/references/alloy-cli-advanced.md +84 -0
- package/skills/ti-guides/references/alloy-data-mastery.md +29 -0
- package/skills/ti-guides/references/alloy-widgets-and-themes.md +19 -0
- package/skills/ti-guides/references/android-manifest.md +97 -0
- package/skills/ti-guides/references/app-distribution.md +258 -0
- package/skills/ti-guides/references/application-frameworks.md +377 -0
- package/skills/ti-guides/references/cli-reference.md +402 -0
- package/skills/ti-guides/references/coding-best-practices.md +102 -0
- package/skills/ti-guides/references/commonjs-advanced.md +134 -0
- package/skills/ti-guides/references/hello-world.md +100 -0
- package/skills/ti-guides/references/hyperloop-native-access.md +62 -0
- package/skills/ti-guides/references/javascript-primer.md +411 -0
- package/skills/ti-guides/references/reserved-words.md +36 -0
- package/skills/ti-guides/references/resources.md +183 -0
- package/skills/ti-guides/references/style-and-conventions.md +48 -0
- package/skills/ti-guides/references/tiapp-config.md +609 -0
- package/skills/ti-howtos/SKILL.md +174 -0
- package/skills/ti-howtos/references/android-platform-deep-dives.md +658 -0
- package/skills/ti-howtos/references/automation-fastlane-appium.md +95 -0
- package/skills/ti-howtos/references/buffer-codec-streams.md +140 -0
- package/skills/ti-howtos/references/cross-platform-development.md +348 -0
- package/skills/ti-howtos/references/debugging-profiling.md +543 -0
- package/skills/ti-howtos/references/extending-titanium.md +723 -0
- package/skills/ti-howtos/references/google-maps-v2.md +169 -0
- package/skills/ti-howtos/references/ios-map-kit.md +143 -0
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +783 -0
- package/skills/ti-howtos/references/local-data-sources.md +301 -0
- package/skills/ti-howtos/references/location-and-maps.md +252 -0
- package/skills/ti-howtos/references/media-apis.md +210 -0
- package/skills/ti-howtos/references/notification-services.md +599 -0
- package/skills/ti-howtos/references/remote-data-sources.md +349 -0
- package/skills/ti-howtos/references/tutorials.md +502 -0
- package/skills/ti-howtos/references/using-modules.md +237 -0
- package/skills/ti-howtos/references/web-content-integration.md +307 -0
- package/skills/ti-howtos/references/webpack-build-pipeline.md +78 -0
- package/skills/ti-ui/SKILL.md +179 -0
- package/skills/ti-ui/references/accessibility-deep-dive.md +242 -0
- package/skills/ti-ui/references/animation-and-matrices.md +599 -0
- package/skills/ti-ui/references/application-structures.md +655 -0
- package/skills/ti-ui/references/custom-fonts-styling.md +579 -0
- package/skills/ti-ui/references/event-handling.md +393 -0
- package/skills/ti-ui/references/gestures.md +473 -0
- package/skills/ti-ui/references/icons-and-splash-screens.md +409 -0
- package/skills/ti-ui/references/layouts-and-positioning.md +462 -0
- package/skills/ti-ui/references/listviews-and-performance.md +619 -0
- package/skills/ti-ui/references/orientation.md +362 -0
- package/skills/ti-ui/references/platform-ui-android.md +635 -0
- package/skills/ti-ui/references/platform-ui-ios.md +469 -0
- package/skills/ti-ui/references/scrolling-views.md +252 -0
- package/skills/ti-ui/references/tableviews.md +568 -0
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
# Grid Layout System
|
|
2
|
+
|
|
3
|
+
The PurgeTSS grid system is a layout tool with utilities to lay out columns and rows using Titanium's layout properties.
|
|
4
|
+
|
|
5
|
+
:::caution Not CSS Grid
|
|
6
|
+
**PurgeTSS grid does NOT work like CSS Grid.** Titanium lacks native CSS Grid support. The PurgeTSS grid system is an abstraction using `horizontal` and `vertical` layouts with percentage widths and margins.
|
|
7
|
+
:::
|
|
8
|
+
|
|
9
|
+
## Table of Contents
|
|
10
|
+
|
|
11
|
+
- [Grid Layout System](#grid-layout-system)
|
|
12
|
+
- [Table of Contents](#table-of-contents)
|
|
13
|
+
- [Basic Structure](#basic-structure)
|
|
14
|
+
- [Column Grid](#column-grid)
|
|
15
|
+
- [`.grid-cols-{n}`](#grid-cols-n)
|
|
16
|
+
- [`.col-span-{n}`](#col-span-n)
|
|
17
|
+
- [Row Grid](#row-grid)
|
|
18
|
+
- [`.grid-rows-{n}`](#grid-rows-n)
|
|
19
|
+
- [`.row-span-{n}`](#row-span-n)
|
|
20
|
+
- [Gutter Utilities](#gutter-utilities)
|
|
21
|
+
- [Available Gap Utilities](#available-gap-utilities)
|
|
22
|
+
- [Direction Utilities](#direction-utilities)
|
|
23
|
+
- [Alignment Utilities](#alignment-utilities)
|
|
24
|
+
- [Common Layout Patterns](#common-layout-patterns)
|
|
25
|
+
- [Two-Column Layout](#two-column-layout)
|
|
26
|
+
- [Three-Column Layout](#three-column-layout)
|
|
27
|
+
- [Sidebar + Main Content](#sidebar--main-content)
|
|
28
|
+
- [Asymmetric Layout](#asymmetric-layout)
|
|
29
|
+
- [Grid System Pitfalls and Solutions](#grid-system-pitfalls-and-solutions)
|
|
30
|
+
- [Problem: Gap Breaks Percentage Widths](#problem-gap-breaks-percentage-widths)
|
|
31
|
+
- [Problem: Grid Without w-screen](#problem-grid-without-w-screen)
|
|
32
|
+
- [Problem: Missing Gap Container](#problem-missing-gap-container)
|
|
33
|
+
- [When to Use Grid vs. Manual Layout](#when-to-use-grid-vs-manual-layout)
|
|
34
|
+
- [Use Grid System When:](#use-grid-system-when)
|
|
35
|
+
- [Use Manual Layout When:](#use-manual-layout-when)
|
|
36
|
+
- [Complete Utility Reference](#complete-utility-reference)
|
|
37
|
+
- [Real-World Example](#real-world-example)
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Basic Structure
|
|
42
|
+
|
|
43
|
+
This is the most basic layout for using the grid system:
|
|
44
|
+
|
|
45
|
+
```xml
|
|
46
|
+
<Alloy>
|
|
47
|
+
<View class='grid'>
|
|
48
|
+
<View class="grid-cols-4">
|
|
49
|
+
<!-- Remove gap View if you don't need gutters between columns -->
|
|
50
|
+
<View class="gap-1">
|
|
51
|
+
<!-- ANY CONTENT GOES HERE -->
|
|
52
|
+
</View>
|
|
53
|
+
</View>
|
|
54
|
+
|
|
55
|
+
<View class="grid-cols-4">
|
|
56
|
+
<View class="gap-1">
|
|
57
|
+
<!-- ANY CONTENT GOES HERE -->
|
|
58
|
+
</View>
|
|
59
|
+
</View>
|
|
60
|
+
</View>
|
|
61
|
+
</Alloy>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Column Grid
|
|
65
|
+
|
|
66
|
+
### `.grid-cols-{n}`
|
|
67
|
+
|
|
68
|
+
With `grid-cols`, you tell the grid system how many columns you want to fit in each row:
|
|
69
|
+
|
|
70
|
+
- `grid-cols-1` - 1 column per row (100% width each)
|
|
71
|
+
- `grid-cols-2` - 2 columns per row (50% width each)
|
|
72
|
+
- `grid-cols-3` - 3 columns per row (33.33% width each)
|
|
73
|
+
- `grid-cols-4` - 4 columns per row (25% width each)
|
|
74
|
+
- And so on...
|
|
75
|
+
|
|
76
|
+
```xml
|
|
77
|
+
<View class="grid">
|
|
78
|
+
<View class="grid-cols-2">
|
|
79
|
+
<!-- Each view is 50% width -->
|
|
80
|
+
</View>
|
|
81
|
+
<View class="grid-cols-2">
|
|
82
|
+
<!-- Each view is 50% width -->
|
|
83
|
+
</View>
|
|
84
|
+
</View>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### `.col-span-{n}`
|
|
88
|
+
|
|
89
|
+
With `col-span`, you set the number of columns each element will occupy in a **12-column grid**:
|
|
90
|
+
|
|
91
|
+
- `col-span-1` - Spans 1 column (8.33% width)
|
|
92
|
+
- `col-span-2` - Spans 2 columns (16.66% width)
|
|
93
|
+
- `col-span-3` - Spans 3 columns (25% width)
|
|
94
|
+
- `col-span-4` - Spans 4 columns (33.33% width)
|
|
95
|
+
- `col-span-6` - Spans 6 columns (50% width)
|
|
96
|
+
- `col-span-12` - Spans 12 columns (100% width)
|
|
97
|
+
|
|
98
|
+
If you set a view with `.col-span-3`, you can add three more views of equal width to fill the row, or any other combination like 3-6-3, 2-4-6, etc., as long as the sum fills a **12-column grid**.
|
|
99
|
+
|
|
100
|
+
```xml
|
|
101
|
+
<!-- 12-column grid examples -->
|
|
102
|
+
<View class="grid">
|
|
103
|
+
<!-- 3 + 3 + 3 + 3 = 12 -->
|
|
104
|
+
<View class="col-span-3">...</View>
|
|
105
|
+
<View class="col-span-3">...</View>
|
|
106
|
+
<View class="col-span-3">...</View>
|
|
107
|
+
<View class="col-span-3">...</View>
|
|
108
|
+
</View>
|
|
109
|
+
|
|
110
|
+
<View class="grid">
|
|
111
|
+
<!-- 6 + 6 = 12 -->
|
|
112
|
+
<View class="col-span-6">...</View>
|
|
113
|
+
<View class="col-span-6">...</View>
|
|
114
|
+
</View>
|
|
115
|
+
|
|
116
|
+
<View class="grid">
|
|
117
|
+
<!-- 4 + 4 + 4 = 12 -->
|
|
118
|
+
<View class="col-span-4">...</View>
|
|
119
|
+
<View class="col-span-4">...</View>
|
|
120
|
+
<View class="col-span-4">...</View>
|
|
121
|
+
</View>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Row Grid
|
|
125
|
+
|
|
126
|
+
### `.grid-rows-{n}`
|
|
127
|
+
|
|
128
|
+
With `grid-rows`, you tell the grid system how many rows you want to fit in each column:
|
|
129
|
+
|
|
130
|
+
- `grid-rows-2` - 2 rows per column
|
|
131
|
+
- `grid-rows-3` - 3 rows per column
|
|
132
|
+
- And so on...
|
|
133
|
+
|
|
134
|
+
```xml
|
|
135
|
+
<View class="grid-flow-row">
|
|
136
|
+
<View class="grid-rows-2">
|
|
137
|
+
<!-- Each view is 50% height -->
|
|
138
|
+
</View>
|
|
139
|
+
<View class="grid-rows-2">
|
|
140
|
+
<!-- Each view is 50% height -->
|
|
141
|
+
</View>
|
|
142
|
+
</View>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### `.row-span-{n}`
|
|
146
|
+
|
|
147
|
+
With `row-span`, you set the number of rows each element will occupy in a **12-row grid**:
|
|
148
|
+
|
|
149
|
+
- `row-span-1` through `row-span-12`
|
|
150
|
+
|
|
151
|
+
If you set a view with `.row-span-3`, you can add three more views of equal height to fill the column, or any other combination like 3-6-3, 2-4-6, etc., as long as the sum fills a **12-row grid**.
|
|
152
|
+
|
|
153
|
+
```xml
|
|
154
|
+
<!-- 12-row grid example -->
|
|
155
|
+
<View class="grid-flow-row">
|
|
156
|
+
<!-- 6 + 6 = 12 -->
|
|
157
|
+
<View class="row-span-6">...</View>
|
|
158
|
+
<View class="row-span-6">...</View>
|
|
159
|
+
</View>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Gutter Utilities
|
|
163
|
+
|
|
164
|
+
The gap utilities add spacing between grid items.
|
|
165
|
+
|
|
166
|
+
:::warning Important Note on Gaps
|
|
167
|
+
**`gap-{size}` adds margin to ALL sides** (top, right, bottom, left), not just between elements. This is different from CSS gap and can cause layout issues if not used carefully.
|
|
168
|
+
:::
|
|
169
|
+
|
|
170
|
+
### Available Gap Utilities
|
|
171
|
+
|
|
172
|
+
- **`gap-{size}`** - Gap between rows and columns
|
|
173
|
+
- **`gap-x-{size}`** - Gap between columns only
|
|
174
|
+
- **`gap-y-{size}`** - Gap between rows only
|
|
175
|
+
- **`gap-t-{size}`** - Gap on top side
|
|
176
|
+
- **`gap-r-{size}`** - Gap on right side
|
|
177
|
+
- **`gap-b-{size}`** - Gap on bottom side
|
|
178
|
+
- **`gap-l-{size}`** - Gap on left side
|
|
179
|
+
|
|
180
|
+
```xml
|
|
181
|
+
<View class="grid">
|
|
182
|
+
<View class="gap-1">
|
|
183
|
+
<!-- 4px margin on all sides -->
|
|
184
|
+
</View>
|
|
185
|
+
<View class="gap-1">
|
|
186
|
+
<!-- 4px margin on all sides -->
|
|
187
|
+
</View>
|
|
188
|
+
</View>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Direction Utilities
|
|
192
|
+
|
|
193
|
+
Control the flow direction of the grid:
|
|
194
|
+
|
|
195
|
+
- **`.grid`** or **`.grid-flow-col`** - Sets `layout: 'horizontal'` (columns flow left to right)
|
|
196
|
+
- **`.grid-flow-row`** - Sets `layout: 'vertical'` (rows flow top to bottom)
|
|
197
|
+
|
|
198
|
+
```xml
|
|
199
|
+
<!-- Horizontal grid (default) -->
|
|
200
|
+
<View class="grid">
|
|
201
|
+
<View class="col-span-6">...</View>
|
|
202
|
+
<View class="col-span-6">...</View>
|
|
203
|
+
</View>
|
|
204
|
+
|
|
205
|
+
<!-- Vertical grid -->
|
|
206
|
+
<View class="grid-flow-row">
|
|
207
|
+
<View class="row-span-6">...</View>
|
|
208
|
+
<View class="row-span-6">...</View>
|
|
209
|
+
</View>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Alignment Utilities
|
|
213
|
+
|
|
214
|
+
Align items within the grid:
|
|
215
|
+
|
|
216
|
+
- **`.start`** - Aligns element to the start of a row
|
|
217
|
+
- **`.center`** - Aligns element to the center of a row
|
|
218
|
+
- **`.end`** - Aligns element to the end of a row
|
|
219
|
+
|
|
220
|
+
```xml
|
|
221
|
+
<View class="grid">
|
|
222
|
+
<View class="start col-span-4">...</View>
|
|
223
|
+
<View class="center col-span-4">...</View>
|
|
224
|
+
<View class="end col-span-4">...</View>
|
|
225
|
+
</View>
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Common Layout Patterns
|
|
229
|
+
|
|
230
|
+
### Two-Column Layout
|
|
231
|
+
|
|
232
|
+
```xml
|
|
233
|
+
<View class="grid">
|
|
234
|
+
<View class="col-span-6 bg-blue-100">
|
|
235
|
+
<Label text="Left Column" />
|
|
236
|
+
</View>
|
|
237
|
+
<View class="col-span-6 bg-green-100">
|
|
238
|
+
<Label text="Right Column" />
|
|
239
|
+
</View>
|
|
240
|
+
</View>
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Three-Column Layout
|
|
244
|
+
|
|
245
|
+
```xml
|
|
246
|
+
<View class="grid">
|
|
247
|
+
<View class="col-span-4 bg-blue-100">
|
|
248
|
+
<Label text="Column 1" />
|
|
249
|
+
</View>
|
|
250
|
+
<View class="col-span-4 bg-green-100">
|
|
251
|
+
<Label text="Column 2" />
|
|
252
|
+
</View>
|
|
253
|
+
<View class="col-span-4 bg-red-100">
|
|
254
|
+
<Label text="Column 3" />
|
|
255
|
+
</View>
|
|
256
|
+
</View>
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Sidebar + Main Content
|
|
260
|
+
|
|
261
|
+
```xml
|
|
262
|
+
<View class="grid">
|
|
263
|
+
<View class="col-span-3 bg-gray-100">
|
|
264
|
+
<Label text="Sidebar" />
|
|
265
|
+
</View>
|
|
266
|
+
<View class="col-span-9 bg-white">
|
|
267
|
+
<Label text="Main Content" />
|
|
268
|
+
</View>
|
|
269
|
+
</View>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Asymmetric Layout
|
|
273
|
+
|
|
274
|
+
```xml
|
|
275
|
+
<View class="grid">
|
|
276
|
+
<View class="col-span-8 bg-blue-100">
|
|
277
|
+
<Label text="Wide Column" />
|
|
278
|
+
</View>
|
|
279
|
+
<View class="col-span-4 bg-green-100">
|
|
280
|
+
<Label text="Narrow Column" />
|
|
281
|
+
</View>
|
|
282
|
+
</View>
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Grid System Pitfalls and Solutions
|
|
286
|
+
|
|
287
|
+
### Problem: Gap Breaks Percentage Widths
|
|
288
|
+
|
|
289
|
+
```xml
|
|
290
|
+
<!-- ❌ This may overflow -->
|
|
291
|
+
<View class="grid grid-cols-2">
|
|
292
|
+
<View class="col-span-6 gap-2">
|
|
293
|
+
<!-- 50% width + 8px margin all sides = overflow -->
|
|
294
|
+
</View>
|
|
295
|
+
<View class="col-span-6 gap-2">
|
|
296
|
+
<!-- Same issue -->
|
|
297
|
+
</View>
|
|
298
|
+
</View>
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**Solution**: Use explicit widths with margins
|
|
302
|
+
|
|
303
|
+
```xml
|
|
304
|
+
<!-- ✅ Better approach -->
|
|
305
|
+
<View class="horizontal w-screen">
|
|
306
|
+
<View class="w-(48%) mr-2">
|
|
307
|
+
<!-- Card 1 -->
|
|
308
|
+
</View>
|
|
309
|
+
<View class="w-(48%) ml-2">
|
|
310
|
+
<!-- Card 2 -->
|
|
311
|
+
</View>
|
|
312
|
+
</View>
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Problem: Grid Without w-screen
|
|
316
|
+
|
|
317
|
+
```xml
|
|
318
|
+
<!-- ❌ Parent doesn't have explicit width -->
|
|
319
|
+
<View>
|
|
320
|
+
<View class="grid grid-cols-2">
|
|
321
|
+
<!-- Percentage widths may not work correctly -->
|
|
322
|
+
</View>
|
|
323
|
+
</View>
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
**Solution**: Add `w-screen` to parent
|
|
327
|
+
|
|
328
|
+
```xml
|
|
329
|
+
<!-- ✅ Parent has explicit width -->
|
|
330
|
+
<View class="w-screen">
|
|
331
|
+
<View class="grid grid-cols-2">
|
|
332
|
+
<!-- Percentage widths work correctly -->
|
|
333
|
+
</View>
|
|
334
|
+
</View>
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### Problem: Missing Gap Container
|
|
338
|
+
|
|
339
|
+
```xml
|
|
340
|
+
<!-- ❌ Gap not applied correctly -->
|
|
341
|
+
<View class="grid">
|
|
342
|
+
<View class="col-span-6 bg-white">
|
|
343
|
+
<!-- Content -->
|
|
344
|
+
</View>
|
|
345
|
+
</View>
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
**Solution**: Wrap content in gap View
|
|
349
|
+
|
|
350
|
+
```xml
|
|
351
|
+
<!-- ✅ Correct structure -->
|
|
352
|
+
<View class="grid">
|
|
353
|
+
<View class="col-span-6">
|
|
354
|
+
<View class="gap-2 bg-white">
|
|
355
|
+
<!-- Content -->
|
|
356
|
+
</View>
|
|
357
|
+
</View>
|
|
358
|
+
</View>
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
## When to Use Grid vs. Manual Layout
|
|
362
|
+
|
|
363
|
+
### Use Grid System When:
|
|
364
|
+
- You need simple column layouts (2, 3, 4 columns)
|
|
365
|
+
- Content is uniform in size
|
|
366
|
+
- You don't need complex gutters
|
|
367
|
+
- Building a dashboard or card grid
|
|
368
|
+
|
|
369
|
+
### Use Manual Layout When:
|
|
370
|
+
- You need precise control over spacing
|
|
371
|
+
- Using percentage widths with margins
|
|
372
|
+
- Creating adaptive layouts (tablet vs handheld)
|
|
373
|
+
- Dealing with complex responsive behavior
|
|
374
|
+
|
|
375
|
+
```xml
|
|
376
|
+
<!-- Manual layout for more control -->
|
|
377
|
+
<View class="horizontal mb-4 w-screen">
|
|
378
|
+
<View class="w-(48%) vertical mr-2 rounded-xl bg-white shadow">
|
|
379
|
+
<!-- Card content -->
|
|
380
|
+
</View>
|
|
381
|
+
<View class="w-(48%) vertical ml-2 rounded-xl bg-white shadow">
|
|
382
|
+
<!-- Card content -->
|
|
383
|
+
</View>
|
|
384
|
+
</View>
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
## Complete Utility Reference
|
|
388
|
+
|
|
389
|
+
| Utility | Purpose | Example |
|
|
390
|
+
| ---------------- | ------------------------ | ------------------------------ |
|
|
391
|
+
| `.grid` | Horizontal layout | `<View class="grid">` |
|
|
392
|
+
| `.grid-flow-col` | Horizontal layout | `<View class="grid-flow-col">` |
|
|
393
|
+
| `.grid-flow-row` | Vertical layout | `<View class="grid-flow-row">` |
|
|
394
|
+
| `.grid-cols-{n}` | N columns per row | `<View class="grid-cols-2">` |
|
|
395
|
+
| `.grid-rows-{n}` | N rows per column | `<View class="grid-rows-2">` |
|
|
396
|
+
| `.col-span-{n}` | Span N columns (12-grid) | `<View class="col-span-6">` |
|
|
397
|
+
| `.row-span-{n}` | Span N rows (12-grid) | `<View class="row-span-6">` |
|
|
398
|
+
| `.gap-{size}` | Gap all sides | `<View class="gap-4">` |
|
|
399
|
+
| `.gap-x-{size}` | Gap horizontal | `<View class="gap-x-4">` |
|
|
400
|
+
| `.gap-y-{size}` | Gap vertical | `<View class="gap-y-4">` |
|
|
401
|
+
| `.start` | Align to start | `<View class="start">` |
|
|
402
|
+
| `.center` | Align to center | `<View class="center">` |
|
|
403
|
+
| `.end` | Align to end | `<View class="end">` |
|
|
404
|
+
|
|
405
|
+
## Real-World Example
|
|
406
|
+
|
|
407
|
+
```xml
|
|
408
|
+
<Alloy>
|
|
409
|
+
<Window class="bg-gray-100">
|
|
410
|
+
<ScrollView class="vertical h-screen w-screen">
|
|
411
|
+
|
|
412
|
+
<!-- Header -->
|
|
413
|
+
<View class="bg-white p-4">
|
|
414
|
+
<Label class="text-xl font-bold text-gray-800" text="Dashboard" />
|
|
415
|
+
</View>
|
|
416
|
+
|
|
417
|
+
<!-- Stats Grid -->
|
|
418
|
+
<View class="m-4 grid">
|
|
419
|
+
<View class="col-span-6">
|
|
420
|
+
<View class="gap-2 rounded-lg bg-white p-4">
|
|
421
|
+
<Label class="text-2xl font-bold text-blue-600" text="1,234" />
|
|
422
|
+
<Label class="text-sm text-gray-500" text="Total Users" />
|
|
423
|
+
</View>
|
|
424
|
+
</View>
|
|
425
|
+
<View class="col-span-6">
|
|
426
|
+
<View class="gap-2 rounded-lg bg-white p-4">
|
|
427
|
+
<Label class="text-2xl font-bold text-green-600" text="$56.7k" />
|
|
428
|
+
<Label class="text-sm text-gray-500" text="Revenue" />
|
|
429
|
+
</View>
|
|
430
|
+
</View>
|
|
431
|
+
</View>
|
|
432
|
+
|
|
433
|
+
<!-- Three Column Section -->
|
|
434
|
+
<View class="m-4 grid">
|
|
435
|
+
<View class="col-span-4">
|
|
436
|
+
<View class="h-32 gap-2 rounded-lg bg-white p-4">
|
|
437
|
+
<Label class="text-center text-gray-800" text="Card 1" />
|
|
438
|
+
</View>
|
|
439
|
+
</View>
|
|
440
|
+
<View class="col-span-4">
|
|
441
|
+
<View class="h-32 gap-2 rounded-lg bg-white p-4">
|
|
442
|
+
<Label class="text-center text-gray-800" text="Card 2" />
|
|
443
|
+
</View>
|
|
444
|
+
</View>
|
|
445
|
+
<View class="col-span-4">
|
|
446
|
+
<View class="h-32 gap-2 rounded-lg bg-white p-4">
|
|
447
|
+
<Label class="text-center text-gray-800" text="Card 3" />
|
|
448
|
+
</View>
|
|
449
|
+
</View>
|
|
450
|
+
</View>
|
|
451
|
+
|
|
452
|
+
</ScrollView>
|
|
453
|
+
</Window>
|
|
454
|
+
</Alloy>
|
|
455
|
+
```
|