liveview-native / liveview-client-swiftui

MIT License
379 stars 39 forks source link

input ( type="DatePicker") don't show on ios 17.0(Xcode Simulator) #1454

Open youfun opened 2 months ago

youfun commented 2 months ago

The almost identical code on different drives has different displays. mabye it's a bug or just i written a wrong code.


  def render(assigns, %{"target" => "ios"}) do
     ...
     <HStack spacing={12}>
                <.button phx-click="previous_date" style="padding(.horizontal, 10);padding(.vertical, 5)">
                  previous
                </.button>
              <.simple_form for={@date_form} id="date-form" phx-change="change_date">
              <.input
                field={@date_form[:selected_date]}
                type="DatePicker"
                selection={@selected_date |> Date.to_iso8601()}
                displayedComponents={"date"}

              />
              </.simple_form>

                <.button phx-click="next_date" style="padding(.horizontal, 10);padding(.vertical, 5)">
                  next
                </.button>
              </HStack>
       ....
  end

  def render(assigns, _interface) do
...

 <HStack spacing={12}>
                <Button phx-click="previous_date">
                  <Text>previous</Text>
                </Button>
              <.simple_form for={@date_form} id="date-form" phx-change="change_date">
              <.input
                field={@date_form[:selected_date]}
                type="DatePicker"
                selection={@selected_date |> Date.to_iso8601()}
                displayedComponents={"date"}
                style="frame(width: 250)"

              />
            </.simple_form>

                <Button phx-click="next_date">
                  <Text>next</Text>
                </Button>
              </HStack>
...
end

Library Version 0.3

Xcode Version Version 15.4 (15F31d)

Swift Version swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4) Target: arm64-apple-macosx14.0

On which device or simulator are you running into the problem? MacOS

Target Device Operating System Version macos 14.2.1 (23C71)

Snipaste_2024-09-19_07-30-23
carson-katri commented 2 months ago

2 things you may want to check:

  1. Try using a <.form> component instead of <.simple_form>. My guess is you're seeing the Form element's List UI on iOS there, and you'd have to scroll down in that little box to find the date picker.
  2. If you're passing field to the <.input> component, there's no reason to pass selection as well since the core component will do that for you.
carson-katri commented 2 months ago

Here's what the layout you provided looks like when I render it locally:

You can see the Form element's list interface in the middle. You probably want to just use <.form> if you don't want any styling applied. Or you can customize the <.simple_form> component.

youfun commented 2 months ago

Here's what the layout you provided looks like when I render it locally:

You can see the Form element's list interface in the middle. You probably want to just use <.form> if you don't want any styling applied. Or you can customize the <.simple_form> component.

when i use .form instead .simple_form .it fix.

youfun commented 2 months ago

2 things you may want to check:

  1. Try using a <.form> component instead of <.simple_form>. My guess is you're seeing the Form element's List UI on iOS there, and you'd have to scroll down in that little box to find the date picker.
  2. If you're passing field to the <.input> component, there's no reason to pass selection as well since the core component will do that for you.

replpy 2: I do this because I need local time zone data. If I delete this line, it will pass UTC time zone data. Maybe there's a problem with my OS time zone settings? I am not sure about that. or it's no the best practice to process data on the client side? should i move this logic to handle_event?

carson-katri commented 1 month ago

I would suggest moving the logic to the handle_event.