Module: RubyNative::Helper
- Defined in:
- lib/ruby_native/helper.rb
Defined Under Namespace
Classes: MenuBuilder
Instance Method Summary collapse
- #native_back_button_tag(text = nil, **options) ⇒ Object
- #native_button_tag(title, url, ios_image: nil, side: :right, **options) ⇒ Object
- #native_form_data ⇒ Object
- #native_form_tag ⇒ Object
- #native_menu_tag(title:, side: :right, &block) ⇒ Object
- #native_push_tag ⇒ Object
- #native_search_tag ⇒ Object
- #native_submit_data ⇒ Object
- #native_tabs_tag(enabled: true) ⇒ Object
Instance Method Details
#native_back_button_tag(text = nil, **options) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/ruby_native/helper.rb', line 29 def (text = nil, **) [:class] = [[:class], "native-back-button"].compact.join(" ") default_content = tag.svg( tag.path(d: "M15.75 19.5L8.25 12l7.5-7.5", stroke_linecap: "round", stroke_linejoin: "round"), width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", stroke_width: 2.5 ) tag.(text || default_content, onclick: "webkit.messageHandlers.rubyNative.postMessage({action: 'back'})", **) end |
#native_button_tag(title, url, ios_image: nil, side: :right, **options) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/ruby_native/helper.rb', line 42 def (title, url, ios_image: nil, side: :right, **) data = .delete(:data) || {} data[:controller] = "bridge--button" data[:bridge_side] = side.to_s data[:bridge_ios_image] = ios_image if ios_image link_to title, url, **, data: data end |
#native_form_data ⇒ Object
14 15 16 |
# File 'lib/ruby_native/helper.rb', line 14 def native_form_data { controller: "bridge--form" } end |
#native_form_tag ⇒ Object
10 11 12 |
# File 'lib/ruby_native/helper.rb', line 10 def native_form_tag tag.div(data: { native_form: true }, hidden: true) end |
#native_menu_tag(title:, side: :right, &block) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ruby_native/helper.rb', line 51 def (title:, side: :right, &block) builder = MenuBuilder.new(self) capture(builder, &block) tag.div(style: "display:none", data: { controller: "bridge--menu", bridge__menu_title_value: title, bridge__menu_side_value: side.to_s }) { builder.to_html } end |
#native_push_tag ⇒ Object
22 23 24 25 26 27 |
# File 'lib/ruby_native/helper.rb', line 22 def native_push_tag safe_join([ tag.div(data: { native_push: true }, hidden: true), tag.div(data: { controller: "bridge--push" }) ]) end |
#native_search_tag ⇒ Object
38 39 40 |
# File 'lib/ruby_native/helper.rb', line 38 def native_search_tag tag.div(data: { controller: "bridge--search" }) end |
#native_submit_data ⇒ Object
18 19 20 |
# File 'lib/ruby_native/helper.rb', line 18 def native_submit_data { bridge__form_target: "submit" } end |
#native_tabs_tag(enabled: true) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/ruby_native/helper.rb', line 3 def native_tabs_tag(enabled: true) safe_join([ (tag.div(data: { native_tabs: true }, hidden: true) if enabled), tag.div(data: { controller: "bridge--tabs", bridge__tabs_enabled_value: enabled }) ].compact) end |