HipByte / Flow

Cross-platform libraries for RubyMotion
BSD 2-Clause "Simplified" License
141 stars 29 forks source link

Adding an `Application` or `Platform` library? #59

Open hboon opened 7 years ago

hboon commented 7 years ago

Related to #58.

UI doesn't look like a place to add build_number and version_string. @jjaffeux suggested Application or Platform. This might also be a place for "utility" functions such as retrieving the environment (test, prod, etc).

Since Flow is marked as WIP, we can go ahead with something and refactor later? :)

Ideas?

hboon commented 7 years ago

@jjaffeux @Watson1978 @andrewhavens ?

jjaffeux commented 7 years ago

note : the platform module of react-native https://facebook.github.io/react-native/docs/platform-specific-code.html#platform-module

andrewhavens commented 7 years ago

I'm not convinced that an Application class would be useful/necessary/intuitive. I kind of feel like build_number is a config setting, or something related to the current build, but not ever something you would reference in your application code.

I think a Platform class makes a lot of sense.

if Platform.iOS?
  puts Platform.sdk_version
end
if Platform.android?
  puts Platform.api_version
end

Though, a Device class may also be a nice alternative:

Device.platform.iOS?
if Device.platform.android?
  puts Device.api_version
  puts Device.scale
  puts Device.screen.width
end