Skip to content

Instantly share code, notes, and snippets.

I've lifted this from a project I'm working on, thought it might be interesting starting point for some sort of dynamic switching of styles with Alloy.

It's a hack, so please free to rip it apart.

  • Add the function to alloy.js

  • Add objects for "portrait" and "landscape" to your TSS (and leave defaults in there to be overridden, see the sample)

  • Call the function from your controller to a) init the view in case you have the device held in landscape when a window opens and b) within an event listener (remember to kill it)

@drmas
drmas / app.tss
Last active August 13, 2016 17:28 — forked from tonylukasavage/app.tss
'Label[platform=android]': {
color: '#000' // all platforms except Android default to black
}
'Window': {
backgroundColor: '#fff' // white background instead of default transparent
}
'Window[platform=android]': {
modal: false // make android windows all heavyweight
@drmas
drmas / navReducer.js
Last active June 21, 2016 09:58 — forked from dabit3/navReducer.js
React Native Navigator Experimental Part 2 — Implementing Redux navReducer.js
import { PUSH_ROUTE, POP_ROUTE } from '../constants/ActionTypes'
import { NavigationExperimental } from 'react-native'
const {
StateUtils: NavigationStateUtils
} = NavigationExperimental
const initialState = {
index: 0,
key: 'root',
routes: [{
@drmas
drmas / app.js
Last active April 22, 2017 10:29
import React from 'react'
import {
View,
StatusBar,
Platform
} from 'react-native'
import {Scene, Router} from 'react-native-router-flux';
import HomeScreen from './screens/home'
@drmas
drmas / home.js
Last active April 22, 2017 10:30
import React from 'react';
import {
View,
Text,
StyleSheet,
ListView,
TouchableOpacity,
ActivityIndicator
} from 'react-native';
import { Entypo } from '@expo/vector-icons';
import React from 'react';
import {
View,
Text,
TouchableOpacity,
StyleSheet,
ActivityIndicator,
Image,
ListView
} from 'react-native'
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,