forked from aparoksha/adwaita-swift
Support long swiping in carousels
This commit is contained in:
parent
9cbf88727c
commit
503cf3a191
@ -13,6 +13,10 @@ The elements.
|
|||||||
|
|
||||||
The content.
|
The content.
|
||||||
|
|
||||||
|
### `allowLongSwipes`
|
||||||
|
|
||||||
|
Whether long swipes are allowed.
|
||||||
|
|
||||||
### `view`
|
### `view`
|
||||||
|
|
||||||
The view.
|
The view.
|
||||||
@ -24,3 +28,9 @@ Initialize `Carousel`.
|
|||||||
- Parameters:
|
- Parameters:
|
||||||
- elements: The elements.
|
- elements: The elements.
|
||||||
- content: The view for an element.
|
- content: The view for an element.
|
||||||
|
|
||||||
|
### `longSwipes(_:)`
|
||||||
|
|
||||||
|
Set whether long swipes are allowed or not.
|
||||||
|
- Parameter longSwipes: Whether long swipes are allowed.
|
||||||
|
- Returns: The carousel.
|
||||||
|
|||||||
@ -9,6 +9,10 @@ A text widget.
|
|||||||
|
|
||||||
The content.
|
The content.
|
||||||
|
|
||||||
|
### `lineWrapping`
|
||||||
|
|
||||||
|
Whether line wrapping is allowed.
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
### `init(_:)`
|
### `init(_:)`
|
||||||
|
|
||||||
@ -26,3 +30,9 @@ Update the view storage of the text widget.
|
|||||||
|
|
||||||
Get the container of the text widget.
|
Get the container of the text widget.
|
||||||
- Returns: The view storage.
|
- Returns: The view storage.
|
||||||
|
|
||||||
|
### `wrap(_:)`
|
||||||
|
|
||||||
|
Line wrapping allows the text view to span multiple lines if the width is narrow.
|
||||||
|
- Parameter wrap: Whether to allow line wrapping.
|
||||||
|
- Returns: The text.
|
||||||
|
|||||||
@ -14,12 +14,15 @@ public struct Carousel<Element>: View where Element: Identifiable {
|
|||||||
var elements: [Element]
|
var elements: [Element]
|
||||||
/// The content.
|
/// The content.
|
||||||
var content: (Element) -> Body
|
var content: (Element) -> Body
|
||||||
|
/// Whether long swipes are allowed.
|
||||||
|
var allowLongSwipes = false
|
||||||
|
|
||||||
/// The view.
|
/// The view.
|
||||||
public var view: Body {
|
public var view: Body {
|
||||||
Container(elements, content: content) {
|
Container(elements, content: content) {
|
||||||
Libadwaita.Carousel()
|
Libadwaita.Carousel()
|
||||||
}
|
}
|
||||||
|
.inspect { _ = ($0 as? Libadwaita.Carousel)?.longSwipes(allowLongSwipes) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initialize `Carousel`.
|
/// Initialize `Carousel`.
|
||||||
@ -34,4 +37,13 @@ public struct Carousel<Element>: View where Element: Identifiable {
|
|||||||
self.elements = elements
|
self.elements = elements
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set whether long swipes are allowed or not.
|
||||||
|
/// - Parameter longSwipes: Whether long swipes are allowed.
|
||||||
|
/// - Returns: The carousel.
|
||||||
|
public func longSwipes(_ longSwipes: Bool = true) -> Self {
|
||||||
|
var newSelf = self
|
||||||
|
newSelf.allowLongSwipes = longSwipes
|
||||||
|
return newSelf
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,6 +38,7 @@ struct CarouselDemo: View {
|
|||||||
.frame(minWidth: 300, minHeight: 200)
|
.frame(minWidth: 300, minHeight: 200)
|
||||||
.frame(maxSize: 500)
|
.frame(maxSize: 500)
|
||||||
}
|
}
|
||||||
|
.longSwipes()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,6 +91,11 @@ This is an overview of the available widgets and other components in _Adwaita_.
|
|||||||
| ---------------------------- | --------------------------------------------------------------------------------------- |
|
| ---------------------------- | --------------------------------------------------------------------------------------- |
|
||||||
| `trailingSidebar(_:)` | Whether the sidebar is trailing to the content view. |
|
| `trailingSidebar(_:)` | Whether the sidebar is trailing to the content view. |
|
||||||
|
|
||||||
|
### `Carousel` Modifiers
|
||||||
|
| Syntax | Description |
|
||||||
|
| ---------------------------- | --------------------------------------------------------------------------------------- |
|
||||||
|
| `longSwipes(_:)` | Whether long swiping is enabled. |
|
||||||
|
|
||||||
### `ViewSwitcher` Modifiers
|
### `ViewSwitcher` Modifiers
|
||||||
| Syntax | Description |
|
| Syntax | Description |
|
||||||
| ---------------------------- | --------------------------------------------------------------------------------------- |
|
| ---------------------------- | --------------------------------------------------------------------------------------- |
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user