One of the things I love about Sencha Touch is the built in themes. Android has 4.x has two themes: Halo Dark, Halo Light. There is only one Android theme for Sencha Touch and it's dark. I've been bugging them for awhile to include a light theme and their response was "You do it".
I googled for a long time and couldn't find a theme someone else did. I gave in and decided to make my own theme after finding this one. It's beautiful. I read his breakdown and he created a theme by copying the winPho theme and made changes until he was happy. I did something similar. I copied the Android theme and started digging in.
That's when I found it. There is a Sass variable in /[Sencha SDK folder]/resources/themes/stylesheets/sencha-touch/mountainview/var/_Class.scss called $dark-theme. If you set this variable to false in your local sass file for android it becomes a light theme.
I wish this was explained better. It's only through source code diving can we find the true answers.
Google analytics code
Showing posts with label theme. Show all posts
Showing posts with label theme. Show all posts
Wednesday, September 17, 2014
Thursday, June 5, 2014
Sencha Touch Themes: Using built-in themes for iOS and Android
One of the things I like about Sencha Touch is the built in device themes. I like being able to make a web app look native.
I found many resources that talked about the themes but none gave very good instructions on how to make them work. I finally found a video that walked you through some of the process involved in making themes work. It left out some important stuff that I found through lots of trial and even more error.
I'll show you how to apply a theme to the default sencha project. You can apply these steps to your own project.
I found many resources that talked about the themes but none gave very good instructions on how to make them work. I finally found a video that walked you through some of the process involved in making themes work. It left out some important stuff that I found through lots of trial and even more error.
I'll show you how to apply a theme to the default sencha project. You can apply these steps to your own project.
- Create an example app.
- sencha -sdk [path to sdk] generate app [AppName] [path]
- You'll need to create scss files for the different platforms you want to support.
- cupertino.scss (iOS 7 styling)
- cupertino-classic.scss (iOS 6 styling)
- mountainview.scss (Android)
- Each of these files will include two imports lines that define our theme styles.
@import 'sencha-touch/[platform name]';@import 'sencha-touch/[platform name]/all';
[platform name] is the name of the style you're including. cupertino.scss will use "cupertino" and mountainview.scss will use "mountainview". All the platform names are available here under tip 2. - Next you'll need to run "compass compile" or "compass watch" in the resources/sass folder.
- Now we have to update app.json to include the new css files that were generated by compass. Look for the css option and add each platform as an object to the css array.{"path": "resources/css/cupertino.css","platform": ["ios"],"update": "delta"}
Make sure to update the platform value with the appropriate value. The options are available here under available platforms.
IMPORTANT NOTE: Make sure to add the "platform": ['desktop'] to the app.css entry. If you don't app.css will be included in every theme and it will break the display. - Lastly you'll need to run sencha app build to bring everything together. You can test the different templates by appending ?platform=[platform name] to your uri.
eg: senchaapp.io/?platform=ios
I've added the example project to github so you can pull that down as an example.
Subscribe to:
Posts (Atom)