-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set up scaffolds for state changes and DM slots #94
Conversation
note: because of this, the PR requires the deployment to use a fresh json file this prepares for the info needed by media sessions does some linting using the latest elixir-ls
Not sure why it doesn't display when using the emulator. I think it's better if I test it on the deployed version directly, not sure if the testing method is accurate.
Init functions don't have action handlers yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than for the action bar, there's a pattern to how to declare UI elements specific to the user_mode
lib/vyasa/display/user_mode.ex
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the main place we define user modes, which determines what the user sees and what the user can do within a mode.
NOTE: the keys here might change, and some of them are really just for example purposes.
What's more or less fixed is this style of defining what is rendered and letting it get handler by render functions later, or being slotted into function components and such.
The "slotting" pattern that these try to follow is the main fixed part.
@impl true | ||
# TODO: as a stop-gap we're using functions from Hoverune, this needs to be changed and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a temp note for now.
Change to Draft | ||
</.button> | ||
<%= for other_mode <- @mode.control_panel_modes do %> | ||
<.control_panel_mode_button |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part is to show what other modes can be shifted to from this mode. This is the flow on how one can shift from one major mode to another
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function components specific to what's defined in user components get defined here.
so if I were to add another type of button to the hoverrune, then I shall:
- update the user_mode definitions
- add either a custom rendering function (component) or add mod existing stuff
@@ -174,8 +172,15 @@ defmodule VyasaWeb.DisplayManager.DisplayLive do | |||
|
|||
defp change_mode(socket, curr, target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so mode changes get handled here
@@ -25,6 +25,12 @@ | |||
<.live_component module={@mode.control_panel_component} id="control_panel" mode={@mode} /> | |||
</div> | |||
|
|||
<.live_component |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hoverune is now a live component which is the responsiblity of the DM directly.
This allows emitting events from the live_component and handling it directly by the parent liveview (DM)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed all the old vyasa_web/source_live/*
files
@@ -47,7 +47,7 @@ defmodule Vyasa.MixProject do | |||
{:postgrex, ">= 0.0.0"}, | |||
{:phoenix_html, "~> 4.0"}, | |||
{:phoenix_live_reload, "~> 1.5", only: :dev}, | |||
{:phoenix_live_view, "~> 0.20.17"}, | |||
{:phoenix_live_view, github: "phoenixframework/phoenix_live_view", ref: "440fd04", override: true}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self: to support the stickyness behaviour across browser history navigation (i.e. pressing back / fwd button), we had to bump live_view version to the most updated.
Warning
this means that managing the :live_admin dep ends up being manual
a51ba19
to
dbcebf7
Compare
[Attempt] display topbar only if non-mobile Not sure if the ua_parsing actually works correctly Minor change
cd223ee
to
2caf3f5
Compare
Now, we do a check using the family values and doing a regex. I suspect we'd need to keep updating this if the parsing breaks in thefuture. but should be good enough for now. also the different versions of the ua_parser lib seem to be giving different output
Primarily for quick drafts on mobile, 1. the mediabridge will be hidden (animated away by right) 2. once done typing, it should be visible again It corresponds to: 1. if phone keyboard is open, hide the media player, else show it so that more screen space is given for mobile devices
This should be the "interface" to judge what the DM displays. time to toh for now
trim.0860DC37-2510-4684-AA85-86549E2947DD.MOV |
Similar to the hoverune implementation, this action_bar.ex live_component also takes in an array of actions, which the user_mode defines and then renders buttons that trigger click events specific to the mode and action_name. This allows the DM to be the one with the necessary handlers to act on these events. ******* 1. Bars are soft appearing / disappearing This means that we don't mount / destroy nodes, simply hide and make them appear as and when we need. This means that we need to make some things "equivalent" and work the same way as it does on MediaBridge and ActionBar. Suppose there are nav buttons (the left and right stuff) which are generic. They will DEFINITELY appear on the MediaBridge. They may or may not appear on the ActionBar. This means that any button click on the nav buttons on MediaBridge may just be relayed to a optionally present button on the actionbar, along with other buttons on the action bar. ******* 2. Maintain equivalence in UI buttons b/w action-bar and media bridge by relaying button clicks This will Shim / Relay the nav button click from the media bridge to the corresponding action bar via hooks Essentially, clicking the nav buttons on the mediabridge will relay to the nav buttons on the action bar, which is mode-specific Here's some logs to show that the wire-up looks okay (have left the functions empty first). %Vix.Vips.Image{ref: #Reference<0.3949460734.1140719640.214139>} [debug] HANDLE EVENT "read::nav_back" in VyasaWeb.DisplayManager.DisplayLive Parameters: %{"value" => ""} TRACE: TODO handle nav_event @ action-bar region: %{"event" => "nav_back", "mode" => "read"} [debug] Replied in 430µs TRACE: TODO handle nav_event @ action-bar region: %{"event" => "nav_fwd", "mode" => "read"} [debug] HANDLE EVENT "read::nav_fwd" in VyasaWeb.DisplayManager.DisplayLive Parameters: %{"value" => ""} [debug] Replied in 375µs TRACE handle event for toggle_show_control_panel: false [debug] HANDLE EVENT "toggle_show_control_panel" in VyasaWeb.DisplayManager.DisplayLive Component: VyasaWeb.ControlPanel Parameters: %{"value" => ""} [debug] Replied in 342µs [debug] HANDLE EVENT "change_mode" in VyasaWeb.DisplayManager.DisplayLive Parameters: %{"current_mode" => "read", "target_mode" => "draft", "value" => ""} [debug] Replied in 162µs [debug] HANDLE EVENT "draft::nav_fwd" in VyasaWeb.DisplayManager.DisplayLive Parameters: %{"value" => ""} TRACE: TODO handle nav_event @ action-bar region: %{"event" => "nav_fwd", "mode" => "draft"} [debug] Replied in 562µs TRACE: TODO handle nav_event @ action-bar region: %{"event" => "nav_back", "mode" => "draft"} [debug] HANDLE EVENT "draft::nav_back" in VyasaWeb.DisplayManager.DisplayLive Parameters: %{"value" => ""} [debug] Replied in 573µs iex(test@127.0.0.1)1>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this, the last pattern of slottable action bar has a v1 implementation.
It's fairly rough around the edges, for example, the different patterns could definitely be more standardised and cleaned up.
I shall only tackle what very trivial refactors I can see, else will leave it to subsequent PRs to do the consolidation / cleanup of patterns here.
Also, customary video showing the magic on mobile phone:
freecompress-RPReplay_Final1724747990.mp4
animation: { | ||
ripple: "ripple 0.6s linear", | ||
}, | ||
keyframes: { | ||
ripple: { | ||
"0%": { transform: "scale(0)", opacity: "0.5" }, | ||
"100%": { transform: "scale(4)", opacity: "0" }, | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was experimenting with ripple effect, it's not being used but shall just leave it here for future inspiration
label: "TRACE: TODO handle nav_event @ action-bar region" | ||
) | ||
|
||
# TODO: implement nav_event handlers from action bar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving this empty for now, this shall get wired up in a subsequent PR.
|
||
@impl true | ||
def handle_event( | ||
"draft" <> "::" <> event = _nav_event, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the use of id-based click events allow us to pattern match for particular modes
Signed-off-by: a/vivekbala <avivekbala@gmail.com>
Acked-by: ks0m1c_dharma <sakiyamuni@sams.ara>
Persisting Marks Interim PR
Just comitting this while I make some UI mods next to that. The reason why a live_component works here is that I expect to use some collapsible state.
This PR establishes the pattern on how we may define individual user_modes that determine what's presented to the user.
there are the following things that can be slotted into:
typically for quick actions that are context specific (e.g. quick drafts)
for common actions like navigation through an ordered list
for determining what content is to be displayed. This shall be user_mode-agnostic for now
When switching user modes from A to B, the DM will be able to switch what actions the user can do based on what's defined in the %UserMode{}