ruby_native 0.10.9 → 0.10.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1020516eb9b684247d40d16d00153a75691082fbe9a3e769d552826d7a217135
4
- data.tar.gz: cf8a1600e15ae4a7b26767b14543c763d13421aa96187e75a0608734e9780cab
3
+ metadata.gz: 1bb5b7670bd2d4d61029b914d26318ed49b9238dd285830a96804dc249be2402
4
+ data.tar.gz: 13f7f057b4be15c33e5c1c5fdade61102dd153a7a1aaba3c789d67bd730f950b
5
5
  SHA512:
6
- metadata.gz: 7dceda118ad0c65f7508a1d77ce5f9a77b0fbbd59d1137673d4076b987ccadc7311135dc0003cbe873747ecfea8b1a4838c69828364b3b56d724b71e3d236dee
7
- data.tar.gz: '0528af6b54e2bc22abc87c6f24d5b1d470872c5abb3d0bb3f0ad8ce93fe0d4657514938e322a5cec578b7982fb827ac0c500fedbac0037fb32bfc047899597d1'
6
+ metadata.gz: ae5949c2f376250485552b39960c5ba5b02d2618a0d15572ca53ac551ce1fc17c8bd418eadd138a9d51dfd3746737193f4f2916befc44bb697b4e32ea362ade3
7
+ data.tar.gz: 7248a218a8a196571628e8233bb687ac73ba51281eb23d24ffbd31b21be94e82ecf7e2e5ba410af36bfc0b43aab8c8b1b7d4b2ef1ae370c3512bb33d5f230909
@@ -81,6 +81,27 @@ background_color:
81
81
 
82
82
  Match these to your CSS framework's dark mode colors. For Bootstrap, `#212529` is `--bs-body-bg` in dark mode.
83
83
 
84
+ ### Navbar branding
85
+
86
+ Replace the navigation bar's text title with a centered logo and set your own bar colors. This is global chrome: the same bar on every screen.
87
+
88
+ ```yaml
89
+ appearance:
90
+ navbar:
91
+ logo: "<%= image_url('logo.png') %>"
92
+ background_color: "#3B3F54"
93
+ foreground_color: "#FFFFFF"
94
+ status_bar: light
95
+ ```
96
+
97
+ `config/ruby_native.yml` is evaluated as ERB, so `logo` can be any Rails expression that returns a URL. Use `image_url` for a local asset: the URL is fingerprinted, so the app caches the logo and re-downloads it only when the image changes. A full URL works too, so the logo can live on a CDN:
98
+
99
+ ```yaml
100
+ logo: "https://cdn.example.com/logo.png"
101
+ ```
102
+
103
+ `background_color` and `foreground_color` each accept a hex string or a `{ light:, dark: }` object. `status_bar` sets the status bar content to `light` (white) or `dark` to match your bar; omit it to let the system decide.
104
+
84
105
  ## View helpers
85
106
 
86
107
  Use these in your layouts and views:
@@ -34,6 +34,28 @@ appearance:
34
34
  # Default: false (portrait-only).
35
35
  # landscape: true
36
36
 
37
+ # Brand the navigation bar across the whole app: a centered logo in place of
38
+ # the page title, plus your own bar colors.
39
+ # https://rubynative.com/docs/appearance#navbar-branding
40
+ # navbar:
41
+ # # Centered logo, shown instead of the page title. Set this to an image URL.
42
+ # # For a local asset, point it at image_url wrapped in ERB so the URL is
43
+ # # fingerprinted (the app re-downloads only when the image changes). The
44
+ # # docs page above has the exact snippet to copy.
45
+ # logo: "https://cdn.example.com/logo.png"
46
+ #
47
+ # # Bar background color.
48
+ # # Accepts a hex string, or { light:, dark: } for dark mode support.
49
+ # background_color: "#3B3F54"
50
+ #
51
+ # # Title and bar-button color.
52
+ # # Accepts a hex string, or { light:, dark: } for dark mode support.
53
+ # foreground_color: "#FFFFFF"
54
+ #
55
+ # # Status bar content, to match your bar. Options: light (white) or dark.
56
+ # # Omit to let the system decide.
57
+ # status_bar: light
58
+
37
59
  # Configure the native tab bar on the bottom of the screen.
38
60
  # https://rubynative.com/docs/tabs
39
61
  tabs:
@@ -1,3 +1,3 @@
1
1
  module RubyNative
2
- VERSION = "0.10.9"
2
+ VERSION = "0.10.10"
3
3
  end
data/lib/ruby_native.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "erb"
1
2
  require "ruby_native/version"
2
3
  require "ruby_native/helper"
3
4
  require "ruby_native/native_version"
@@ -37,7 +38,7 @@ module RubyNative
37
38
  path = Rails.root.join("config", "ruby_native.yml")
38
39
  return unless path.exist?
39
40
 
40
- self.config = YAML.load_file(path).deep_symbolize_keys
41
+ self.config = YAML.load(render_config(path)).deep_symbolize_keys
41
42
  self.config[:app] ||= {}
42
43
  self.config[:app][:entry_path] ||= self.config.dig(:tabs, 0, :path) || "/"
43
44
  self.config[:auth] ||= {}
@@ -46,6 +47,23 @@ module RubyNative
46
47
  backfill_error_icons
47
48
  end
48
49
 
50
+ # config/ruby_native.yml is rendered as ERB before it is parsed, so a
51
+ # developer can interpolate Rails helpers into it. The motivating case is the
52
+ # navbar logo: `logo: "<%= image_url("logo.png") %>"` resolves to a
53
+ # fingerprinted asset URL the native app downloads and caches, and because the
54
+ # digest changes whenever the asset changes, the cache busts itself. A full
55
+ # URL (a CDN, say) works just as well; the app only ever sees a URL to fetch.
56
+ #
57
+ # The template renders against the controller helper proxy, so `image_url` and
58
+ # friends behave exactly as they do in a view. With no request or asset host
59
+ # they degrade to a relative path -- asset helpers never raise "missing host"
60
+ # the way routing helpers do -- and the native app resolves any relative URL
61
+ # against the base URL it already fetched the config from.
62
+ def self.render_config(path)
63
+ helpers = ActionController::Base.helpers
64
+ ERB.new(path.read, trim_mode: "-").result(helpers.instance_eval { binding })
65
+ end
66
+
49
67
  # Mirrors per-platform `icons:` into the legacy flat `icon:` field so native
50
68
  # binaries that only read `tab.icon` keep rendering an icon. Explicit `icon:`
51
69
  # wins; otherwise falls back to `icons.ios`, then `icons.android`.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_native
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.9
4
+ version: 0.10.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Masilotti