Skip to content

Commit

Permalink
Merge pull request #1115 from liveview-native/platform-updates
Browse files Browse the repository at this point in the history
Elixir platform updates
  • Loading branch information
supernintendo authored Aug 31, 2023
2 parents 2a3df0b + 3ea01f6 commit b2b7016
Show file tree
Hide file tree
Showing 335 changed files with 1,003 additions and 605 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
/// Enables/disables antialiasing.
///
/// ```html
/// <Image system-name="heart.fill" modifiers={antialiased(@native, is_active: true)} />
/// <Image system-name="heart.fill" modifiers={antialiased(true)} />
/// ```
///
/// ## Arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import SwiftUI
/// ```html
/// <Image
/// name="dot_green"
/// modifiers={@native |> resizable() |> interpolation(interpolation: :none)}
/// modifiers={resizable([]) |> interpolation(:none)}
/// />
/// <Image
/// name="dot_green"
/// modifiers={@native |> resizable() |> interpolation(interpolation: :medium)}
/// modifiers={resizable([]) |> interpolation(:medium)}
/// />
/// ```
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import SwiftUI
/// The `template` mode renders nontransparent pixels as the foreground color.
///
/// ```html
/// <Image name="dot_green" modifiers={rendering_mode(@native, mode: :original)} />
/// <Image name="dot_green" modifiers={rendering_mode(@native, mode: :template)} />
/// <Image name="dot_green" modifiers={rendering_mode(:original)} />
/// <Image name="dot_green" modifiers={rendering_mode(:template)} />
/// ```
///
/// This modifier can also be used to render multicolor SF Symbols.
Expand All @@ -23,7 +23,7 @@ import SwiftUI
/// ```html
/// <Image
/// system-name="person.crop.circle.badge.plus"
/// modifiers={rendering_mode(@native, mode: :original)}
/// modifiers={rendering_mode(:original)}
/// />
/// ```
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import SwiftUI
/// Enables an image to fill the available space.
///
/// ```html
/// <Image system-name="heart.fill" modifiers={resizable(@native)} />
/// <Image system-name="heart.fill" modifiers={resizable(@native, resizing_mode: :tile)} />
/// <Image system-name="heart.fill" modifiers={resizable([])} />
/// <Image system-name="heart.fill" modifiers={resizable(resizing_mode: :tile)} />
/// ```
///
/// ## Arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import SwiftUI
///
/// ```html
/// <Rectangle
/// modifiers={animation(@native, value: @color)}
/// fill-color={@color}
/// modifiers={animation(value: @color)}
/// fill-color={@color}
/// />
/// ```
///
Expand All @@ -27,8 +27,8 @@ import SwiftUI
///
/// ```html
/// <Rectangle
/// modifiers={animation(@native, animation: :ease_out, value: @color)}
/// fill-color={@color}
/// modifiers={animation(animation: :ease_out, value: @color)}
/// fill-color={@color}
/// />
/// ```
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ import SwiftUI
///
/// ```html
/// <Text
/// modifiers={
/// @native
/// |> content_transition(transition: :numeric_text)
/// |> animation(value: @count)
/// }
/// modifiers={
/// content_transition(:numeric_text)
/// |> animation(value: @count)
/// }
/// >
/// <%= @count %>
/// <%= @count %>
/// </Text>
/// ```
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ import SwiftUI
/// <Image
/// system-name="heart.fill"
/// modifiers={
/// @native |> keyframe_animator(
/// keyframe_animator(
/// initial_value: 1.0,
/// trigger: "#{@liked}",
/// keyframes: [
/// {:linear, 1.0, [duration: 0.36]},
/// {:spring, 1.5, [duration: 0.8, spring: :bouncy]},
/// {:spring, 1.0, [spring: :bouncy]}
/// ],
/// modifiers: @native |> scale_effect(x: 1.0, y: 1.0),
/// modifiers: scale_effect(x: 1.0, y: 1.0),
/// properties: [scale_effect: [:x, :y]]
/// )
/// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import SwiftUI
/// Use the same `id` argument for elements that should be paired.
///
/// ```html
/// <VStack modifiers={@native |> animation(value: Atom.to_string(@is_flipped))}>
/// <VStack modifiers={animation(value: Atom.to_string(@is_flipped))}>
/// <%= if @is_flipped do %>
/// <Text id="a" modifiers={@native |> matched_geometry_effect(id: "a", namespace: :animation)}>A</Text>
/// <Text id="b" modifiers={@native |> matched_geometry_effect(id: "b", namespace: :animation)}>B</Text>
/// <Text id="a" modifiers={matched_geometry_effect(id: "a", namespace: :animation)}>A</Text>
/// <Text id="b" modifiers={matched_geometry_effect(id: "b", namespace: :animation)}>B</Text>
/// <% else %>
/// <Text id="b" modifiers={@native |> matched_geometry_effect(id: "b", namespace: :animation)}>B</Text>
/// <Text id="a" modifiers={@native |> matched_geometry_effect(id: "a", namespace: :animation)}>A</Text>
/// <Text id="b" modifiers={matched_geometry_effect(id: "b", namespace: :animation)}>B</Text>
/// <Text id="a" modifiers={matched_geometry_effect(id: "a", namespace: :animation)}>A</Text>
/// <% end %>
/// <Button phx-click="flip">Flip</Button>
/// </VStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import SwiftUI
///
/// ```html
/// <%= if @show do %>
/// <Text modifiers={transition(@native, transition: :scale)}>Scaled</Text>
/// <Text modifiers={transition(:scale)}>Scaled</Text>
/// <% end %>
/// ```
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import SwiftUI
/// Alters the shape of any bordered buttons' borders.
///
/// ```html
/// <Button modifiers={button_style(@native, style: :bordered) |> button_border_shape(shape: :capsule)}>
/// <Button modifiers={button_style(:bordered) |> button_border_shape(:capsule)}>
/// Capsule
/// </Button>
/// <Button modifiers={button_style(@native, style: :bordered) |> button_border_shape(shape: :rounded_rectangle, radius: 15)}>
/// <Button modifiers={button_style(:bordered) |> button_border_shape(shape: :rounded_rectangle, radius: 15)}>
/// Rounded rectangle
/// </Button>
/// ```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import SwiftUI
/// Sets the size of controls within this view.
///
/// ```html
/// <Button modifiers={control_size(@native, size: :mini) |> button_style(style: :bordered_prominent)}>Mini</Button>
/// <Button modifiers={control_size(@native, size: :large) |> button_style(style: :bordered_prominent)}>Regular</Button>
/// <Button modifiers={control_size(:mini) |> button_style(:bordered_prominent)}>Mini</Button>
/// <Button modifiers={control_size(:large) |> button_style(:bordered_prominent)}>Regular</Button>
/// ```
///
/// ## Arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
/// Changes radio-group style ``Picker``s to lay out horizontally.
///
/// ```html
/// <Picker modifiers={picker_style(@native, style: :radio_group) |> horizontal_radio_group_layout()}>
/// <Picker modifiers={picker_style(:radio_group) |> horizontal_radio_group_layout()}>
/// ...
/// </Picker>
/// ```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import SwiftUI
/// ```html
/// <RenameButton
/// modifiers={
/// rename_action(@native, event: "begin_rename", target: @myself)
/// rename_action(%{ event: "begin_rename", target: @myself })
/// }
/// />
/// ```
Expand All @@ -30,33 +30,21 @@ struct RenameActionModifier: ViewModifier, Decodable {
#if swift(>=5.8)
@_documentation(visibility: public)
#endif
private let event: String
/// The LiveView or LiveComponent to perform the event on.
///
/// In a component, you may use the `@myself` assign to handle the event on the LiveComponent.
#if swift(>=5.8)
@_documentation(visibility: public)
#endif
private let target: Int?
@Environment(\.coordinatorEnvironment) private var coordinatorEnvironment
@Event private var action: Event.EventHandler

init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.event = try container.decode(String.self, forKey: .event)
self.target = try container.decode(Int?.self, forKey: .target)
self._action = try container.decode(Event.self, forKey: .action)
}

private enum CodingKeys: String, CodingKey {
case event
case target
case action
}

func body(content: Content) -> some View {
content
.renameAction {
Task {
try await coordinatorEnvironment?.pushEvent("click", event, [String:Any](), target)
}
action(value: [String:String]())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import SwiftUI
/// Activates this view as the source of a drag and drop operation.
///
/// ```html
/// <Text modifiers={draggable(@native, payload: "ABC")}>ABC</Text>
/// <Text modifiers={draggable(@native, payload: "ABC", preview: :my_preview)}>
/// <Text modifiers={draggable("ABC")}>ABC</Text>
/// <Text modifiers={draggable("ABC", preview: :my_preview)}>
/// ABC
/// <Image system-name="heart.fill" template={:my_preview}>
/// </Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import SwiftUI
/// Defines the destination of a drag and drop operation that handles the dropped content with an event that you specify.
///
/// ```html
/// <Text modifiers={draggable(@native, payload: "ABC")}>ABC</Text>
/// <Text modifiers={drop_destination(@native, action: "drop")}>
/// <Text modifiers={draggable("ABC")}>ABC</Text>
/// <Text modifiers={drop_destination(action: "drop")}>
/// Drop Here
/// </Text>
/// ```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ import SwiftUI
///
/// ```html
/// <HStack>
/// <Color name="system-yellow" modifiers={@native |> frame(width: 50, height: 50, alignment: :center)} />
/// <Color name="system-yellow" modifiers={frame(width: 50, height: 50, alignment: :center)} />
/// <Color name="system-red"
/// modifiers={
/// @native
/// |> frame(width: 50, height: 50, alignment: :center)
/// |> rotation_effect(angle: {:degrees, 45})
/// |> padding(all: -20)
/// |> blend_mode(blend_mode: :color_burn)
/// frame(width: 50, height: 50, alignment: :center)
/// |> rotation_effect({:degrees, 45})
/// |> padding(-20)
/// |> blend_mode(:color_burn)
/// }
/// />
/// </HStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SwiftUI
/// Set the ``radius`` to control the strength of the blur.
///
/// ```html
/// <Text modifiers={blur(@native, radius: 2)}>Hello, world!</Text>
/// <Text modifiers={blur(radius: 2)}>Hello, world!</Text>
/// ```
///
/// ## Arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
/// Applies a border to any element.
///
/// ```html
/// <Text modifiers={border(@native, content: {:color, :purple}, width: 4)}>
/// <Text modifiers={border({:color, :purple}, width: 4)}>
/// Purple border inside the view bounds.
/// </Text>
/// ```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
/// Brighten the intensity of the colors in a view.
///
/// ```html
/// <Color name="system-red" modifiers={@native |> brightness(amount: 0.5)} />
/// <Color name="system-red" modifiers={brightness(0.5)} />
/// ```
///
/// ## Arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SwiftUI
/// Provide a ``ShapeReference`` to clip the element with.
///
/// ```html
/// <Text modifiers={clip_shape(@native, shape: :circle)}>
/// <Text modifiers={clip_shape(:circle)}>
/// Hello,
/// world!
/// </Text>
Expand All @@ -22,10 +22,10 @@ import SwiftUI
/// This lets you apply modifiers to the clip shape.
///
/// ```html
/// <Text modifiers={clip_shape(@native, shape: :my_shape)}>
/// <Text modifiers={clip_shape(:my_shape)}>
/// Hello,
/// world!
/// <Rectangle template={:my_shape} modifiers={@native |> rotation(angle: {:degrees, 45})} />
/// <Rectangle template={:my_shape} modifiers={rotation({:degrees, 45})} />
/// </Text>
/// ```
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import SwiftUI
/// ```html
/// <Circle
/// modifiers={
/// @native
/// |> foreground_color(color: :mint)
/// foreground_color(:mint)
/// |> frame(width: 20, height: 20)
/// |> clipped(antialiased: true)
/// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
/// Inverts the colors in this view.
///
/// ```html
/// <Circle modifiers={@native |> foreground_style(primary: {:color, :red}) |> color_invert()} />
/// <Circle modifiers={foreground_style({:color, :red}) |> color_invert()} />
/// ```
#if swift(>=5.8)
@_documentation(visibility: public)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
/// Adds a color multiplication effect to this view.
///
/// ```html
/// <Label modifiers={foreground_style(@native, primary: {:color, :mint}) |> color_multiply(color: :blue)}>Color Text</Label>
/// <Label modifiers={foreground_style({:color, :mint}) |> color_multiply(:blue)}>Color Text</Label>
/// ```
///
/// ## Arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ import SwiftUI
/// <HStack>
/// <ZStack
/// modifiers={
/// @native
/// |> compositing_group()
/// |> opacity(opacity: 0.5)
/// compositing_group([])
/// |> opacity(0.5)
/// }
/// >
/// <Text>Hello, world!</Text>
/// <Text modifiers={blur(@native, radius: 2)}>Hello, world!</Text>
/// <Text modifiers={blur(radius: 2)}>Hello, world!</Text>
/// </ZStack>
/// </HStack>
/// ```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
/// Sets the contrast and separation between similar colors in this view.
///
/// ```html
/// <Circle modifiers={@native |> foreground_style(primary: {:color, :red}) |> contrast(amount: 0.5)} />
/// <Circle modifiers={foreground_style({:color, :red}) |> contrast(0.5)} />
/// ```
///
/// ## Arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
/// Clips this view to its bounding frame, with the specified corner ``radius``.
///
/// ```html
/// <Image name="MyCustomImage" modifiers={@native |> corner_radius(radius: 8)} />
/// <Image name="MyCustomImage" modifiers={corner_radius(8)} />
/// ```
///
/// ## Arguments
Expand Down
Loading

0 comments on commit b2b7016

Please sign in to comment.