diff --git a/Documentation/Reference/structs/Carousel.md b/Documentation/Reference/structs/Carousel.md index db8c5d3..70672b5 100644 --- a/Documentation/Reference/structs/Carousel.md +++ b/Documentation/Reference/structs/Carousel.md @@ -13,6 +13,10 @@ The elements. The content. +### `allowLongSwipes` + +Whether long swipes are allowed. + ### `view` The view. @@ -24,3 +28,9 @@ Initialize `Carousel`. - Parameters: - elements: The elements. - 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. diff --git a/Documentation/Reference/structs/Text.md b/Documentation/Reference/structs/Text.md index 91c4b57..7cfaf67 100644 --- a/Documentation/Reference/structs/Text.md +++ b/Documentation/Reference/structs/Text.md @@ -9,6 +9,10 @@ A text widget. The content. +### `lineWrapping` + +Whether line wrapping is allowed. + ## Methods ### `init(_:)` @@ -26,3 +30,9 @@ Update the view storage of the text widget. Get the container of the text widget. - 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. diff --git a/Sources/Adwaita/View/Carousel.swift b/Sources/Adwaita/View/Carousel.swift index bf23f3a..ad04265 100644 --- a/Sources/Adwaita/View/Carousel.swift +++ b/Sources/Adwaita/View/Carousel.swift @@ -14,12 +14,15 @@ public struct Carousel: View where Element: Identifiable { var elements: [Element] /// The content. var content: (Element) -> Body + /// Whether long swipes are allowed. + var allowLongSwipes = false /// The view. public var view: Body { Container(elements, content: content) { Libadwaita.Carousel() } + .inspect { _ = ($0 as? Libadwaita.Carousel)?.longSwipes(allowLongSwipes) } } /// Initialize `Carousel`. @@ -34,4 +37,13 @@ public struct Carousel: View where Element: Identifiable { 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 + } + } diff --git a/Tests/CarouselDemo.swift b/Tests/CarouselDemo.swift index 2e5821a..6a5212a 100644 --- a/Tests/CarouselDemo.swift +++ b/Tests/CarouselDemo.swift @@ -38,6 +38,7 @@ struct CarouselDemo: View { .frame(minWidth: 300, minHeight: 200) .frame(maxSize: 500) } + .longSwipes() } } diff --git a/user-manual/Information/Widgets.md b/user-manual/Information/Widgets.md index c45bec4..f55a8fa 100644 --- a/user-manual/Information/Widgets.md +++ b/user-manual/Information/Widgets.md @@ -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. | +### `Carousel` Modifiers +| Syntax | Description | +| ---------------------------- | --------------------------------------------------------------------------------------- | +| `longSwipes(_:)` | Whether long swiping is enabled. | + ### `ViewSwitcher` Modifiers | Syntax | Description | | ---------------------------- | --------------------------------------------------------------------------------------- |