-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
Sources/LiveViewNative/Modifiers/Search Modifiers/FindNavigatorModifier.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// FindNavigatorModifier.swift | ||
// LiveViewNative | ||
// | ||
// Created by Shadowfacts on 5/19/2023. | ||
// | ||
|
||
import SwiftUI | ||
|
||
/// Controls whether the find navigator is shown. | ||
/// | ||
/// Use this modifier with a ``TextEditor``: | ||
/// | ||
/// ```html | ||
/// <TextEditor value-binding="my_text" modifiers={find_navigator(@native, is_presented: :show)} /> | ||
/// ``` | ||
/// | ||
/// ## Arguments | ||
/// * ``isPresented`` | ||
#if swift(>=5.8) | ||
@_documentation(visibility: public) | ||
#endif | ||
@available(iOS 16.0, *) | ||
struct FindNavigatorModifier: ViewModifier, Decodable { | ||
/// A binding that controls whether the find navigator is shown. | ||
#if swift(>=5.8) | ||
@_documentation(visibility: public) | ||
#endif | ||
@LiveBinding private var isPresented: Bool | ||
|
||
init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
self._isPresented = try LiveBinding(decoding: .isPresented, in: container) | ||
} | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
#if os(iOS) | ||
.findNavigator(isPresented: $isPresented) | ||
#endif | ||
} | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case isPresented | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
lib/live_view_native_swift_ui/modifiers/search/find_navigator.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
defmodule LiveViewNativeSwiftUi.Modifiers.FindNavigator do | ||
use LiveViewNativePlatform.Modifier | ||
|
||
alias LiveViewNativeSwiftUi.Types.NativeBindingName | ||
|
||
modifier_schema "find_navigator" do | ||
field :is_presented, NativeBindingName | ||
end | ||
end |