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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1bb5b7670bd2d4d61029b914d26318ed49b9238dd285830a96804dc249be2402
|
|
4
|
+
data.tar.gz: 13f7f057b4be15c33e5c1c5fdade61102dd153a7a1aaba3c789d67bd730f950b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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:
|
data/lib/ruby_native/version.rb
CHANGED
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.
|
|
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`.
|