You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,7 @@
28
28
-[Buttons](#buttons)
29
29
-[Text Fields](#text-fields)
30
30
-[Group Settings Using Nested Spice Stores](#group-settings-using-nested-spice-stores)
31
+
-[Inject Your Own Views](#inject-your-own-views)
31
32
-[Require Restart](#require-restart)
32
33
-[Display Custom Name](#display-custom-name)
33
34
-[Specify Editor Title](#specify-editor-title)
@@ -349,6 +350,53 @@ When inlining a nested spice store, a header and footer can be provided for bett
349
350
var featureFlags =FeatureFlagsSpiceStore()
350
351
```
351
352
353
+
### Inject Your Own Views
354
+
355
+
You can embed your own views into Spices, for example, to display static information.
356
+
357
+
The `@Spice` property wrapper allows you to define custom views within Spices settings. These views can be inlined by default or presented using different styles.
358
+
359
+
By default, views are inlined within the settings list:
360
+
361
+
```swift
362
+
@Spicevar version =LabeledContent("Version", value: "1.0 (1)")
363
+
```
364
+
365
+
You can change the presentation style using the presentation argument.
366
+
367
+
The `.push` presentation pushes the view onto the navigation stack.
368
+
369
+
```swift
370
+
@Spice(presentation: .push) var helloWorld =VStack {
371
+
Image(systemName: "globe")
372
+
.imageScale(.large)
373
+
.foregroundStyle(.tint)
374
+
Text("Hello, world!")
375
+
}
376
+
.padding()
377
+
```
378
+
379
+
The `.modal` presentation presents the view modally on top of Spices.
380
+
381
+
```swift
382
+
@Spice(presentation: .modal) var helloWorld =// ...
383
+
```
384
+
385
+
### Nest Spice Stores
386
+
387
+
Spice stores can be nested to create a hierarchical user interface.
388
+
389
+
```swift
390
+
classAppSpiceStore: SpiceStore {
391
+
@Spicevar featureFlags =FeatureFlagsSpiceStore()
392
+
}
393
+
394
+
classFeatureFlagsSpiceStore: SpiceStore {
395
+
@Spicevar notifications =false
396
+
@Spicevar fastRefreshWidgets =false
397
+
}
398
+
```
399
+
352
400
### Require Restart
353
401
354
402
Setting `requiresRestart` to true will cause the app to be shut down after changing the value. Use this only when necessary, as users do not expect a restart.
0 commit comments