All posts in Mobile Development

A question that regularly pops up in the Framer community is how to use Framer if you’re using a PC. Currently, Framer Studio is only available on a Mac but the Framer.js framework, that powers Framer Studio, is free and open source. That means if you’re using Windows, Linux or on a Mac but still on the fence about purchasing Framer Studio, you can still create Framer prototypes.

framerjs-github

For most of us, we want to do as little configuration as possible — that’s where Atom comes in.Atom is a free, text editor from GitHub that’s modern and customizable to do almost anything without ever touching a config file.

atom-logo

Keep in mind is that Framer.js is written in JavaScript. Because Framer Studio uses theCoffeeScript programming language, which has a slightly different syntax that eventually gets compiled down to JavaScript, the majority of the Framer prototypes and examples you’ll see will be written in CoffeeScript. If you wanted to learn from any of these examples, you would need to first convert the code to JavaScript to run with Framer.js.

With a few simple steps, Atom takes care of that for us so we’ll be able to create Framer prototypes using CoffeeScript and preview them on our PC, Linux, or Mac machine. Let’s get started:

1. Download and install Atom

Go to the Atom website and look for the button to download. The button should be specific for your platform.

atom-download

  • If you’re on a Mac, you’ll download a zip file. Simply unzip it, move it to your Applications folder and run Atom
  • If you’re on a PC, run the installer and then open Atom
  • If you’re on Linux, download and install the Debian package or RPM package

2. Install Packages

When you launch Atom for the first time, you should see a welcome guide.

atom-welcome

Click on the “Install a Package” button on the right pane and then Open Installer.
atom-welcome-open-installer

The Install Packages screen should appear. If the future, you can also access this Settings screen through Preferences and then the install tab.

atom-settings-install

Search for the “coffee-compile” package and install it. This allows you to save your CoffeeScript file in the editor and it will convert it to Javascript. You may notice there are a few different packages that come up in the search results that do the same thing – these should work as well but I haven’t tested all of them.

atom-coffee-compile

Search for the “atom-html-preview” package and install it. This allows you to get a live preview when you make changes to the code.

atom-html-preview

If you click the Packages tab, you should now see your 2 new installed packages under the Community Packages section.

community-packages

3. Update Package Settings

If you installed the coffee-compile package, click the Settings button and check the “Compile on Save without Preview” option. This will automatically compile the file when you save and not show you the JavaScript.

compile-on-save-no-preview

4. Download the Framer.js Starter Template

You can download the template here or by going to the Get Started section of the Framer.js GitHub page and clicking the download link.

framerjs-template

Once downloaded, unzip the file and open up the Framer folder.

framer-js-template

Framer Generator is an application for Mac that comes bundled with Framer.js. It allows you to import layers directly out of Photoshop and Sketch files into your Framer projects . This feature is built into Framer Studio.

Let’s look at the files in the project folder in more detail:

  • /framer/framer.js — This is the JavaScript file that powers the interactions and animations you are able to create for your prototypes. You shouldn’t be touching this file unless you want to replace it with a newer version.
  • /framer/framer.js.map — This is a SourceMap file. It maps the code within a compressed file back to it’s original position in a source file to allow you to debug code for compressed file. You don’t need to worry about it and like the framer.js file, you don’t want to touch this file either.
  • /images/background.png & /images/icon.png — The icon image is used in the default prototype and the background image is just a black background that is specified in the CSS.
  • app.js — Here’s where you would write your JavaScript code for your prototypes. We’ll be writing CoffeeScript code that will generate this app.js file for us.
  • index.html — Open this file in a WebKit browser — such as Google Chrome or Safari to view your prototype. If you look at it, it includes the framer.js and app.js file that we looked at earlier.

5. Open up the Project folder in Atom

Go to File – Add Project Folder and open up the Framer Project folder template.

atom-project-js

6. Rename app.js to app.coffee

Right-click on the app.js file and then select rename.

atom-rename

Change the file extension from .js (JavaScript) to .coffee (CoffeeScript).

atom-rename-coffee

7. Write your CoffeeScript code

Delete the code that is in app.coffee since it’s in JavaScript. You can now write your CoffeeScript code in the file. If you’re not sure where to start, copy and paste the following example code.

Save your file when you’re done writing your code and you should see an app.js file appear in your project folder.

atom-compile-js

8. Preview your Prototype

Click the index.html file in the sidebar and then go to Packages – Preview HTML – Enable Preview

atom-enable-preview

You should now see your Framer prototype that you can interact with on your Windows machine.

framer-atom

Note that although there is a live preview, updating the app.coffee file doesn’t trigger a refresh. You’ll need to make your updates to app.coffee, save it to generate a new app.js, and then in your index.html file, make a change – such as adding a return to one line or deleting a blank line. The prototype will then refresh with your newest code.


Now that you’re able to use Framer on Windows, I can’t wait to see what prototypes you come up with. If Atom isn’t your style, you can also check out a Framer video I did as part of my Rapid Prototyping with Framer course for O’Reilly where I also show you how you can use Framer with another text editor, Brackets, as well as with online code editors like CodePen.

In my personal opinion, if you’re on a Mac and plan on using Framer past the trial period,Framer Studio is well worth the price for the amount of time you’ll save with features like easily creating new projects, instant visual feedback, inline error checking, code completion and much more.

Do you have any tips or additional questions for using Framer on Windows? Let me know with a comment below or share your thoughts with me on Twitter (@kennycheny).

 

1. When you to open “android-ndk-r10c-darwin-x86_64.bin” with “Archive Utility.app” or other app.
2. Then you’ve got “android-ndk-r10c-darwin-x86_64.bin.cpgz”, OH! Crap it’s not extract but archive .bin to .cpgz extension.
Warning!! extracted file take more disk space up to 3.55 GB on disk
[Solution 1] recommended!!
1. open Terminal then type “chmod +x [path]/android-ndk-r10c-darwin-x86_64.bin” and press “Enter”, after that type only “[path]/android-ndk-r10c-darwin-x86_64.bin” and press “Enter” as below image.

After that Terminal was extract with 7-Zip SFX, as below detail.
7-Zip SFX 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=utf8,Utf16=on,HugeFiles=on,4 CPUs)
Processing archive: /Users/dtkad/Downloads/android-ndk-r10c-darwin-x86_64.bin
2. just wait process until Terminal show “Everything is Ok”

[Solution 2]

1. It’s too easy just rename by remove “.bin” if your non-extension file can be execute.
“android-ndk-r10c-darwin-x86_64.bin”
to
“android-ndk-r10c-darwin-x86_64”
you should see it’s as execute file, check it by right-click and choose “Get Info”, you will see detail like below image.
2. double click on “android-ndk-r10c-darwin-x86_64” execute file or open with “Archive Utility.app”,  so if you not see “Archive Utility.app” in both Launchpad and Application folder, it should be here “/System/Library/CoreServices” like below image.
then the Terminal was run and execute file will do extract process, leave it run until it’s show message as below.

 

Everything is Ok
logout
[Process completed]
 
3. Let’s see your extracted folder “android-ndk-r10c”, it’s contain in “Users” by default, for example my users is “poraweeraksasin” from step 2. name on bar, see below image.

All credits to the original author for doing this. Although I’m trying to extend it in the coming days, but props to Adam for finding this one out!

Go to https://www.syntaxismyui.com/xamarin-forms-in-anger-cards/ and follow his other tutorial as well.

 

The #1 request I get for the Xamarin.Forms in Anger is for a Google or Facebook like card view. Today is the day that I fulfill those requests.

To be completely honest, I’ve been thinking about how to do a card view for a while and let me tell you, it’s not easy. Especially when you try to stick with the “in the box” components of Xamarin.Forms. My first attempt at it was hideous.

Hideous Forms

Hideous would be the most polite way of saying it was crap. I started off using BoxViews to draw the lines and contain the whole thing in a Xamarin.Forms Grid. Ouch, yes hideous.

The Grid was becoming a nightmare with all the extra rows and columns needed for lines. What I wouldn’t do for some HTML Tables with a borders = 1 in Xamarin.Forms. I thought of putting in a feature request to the team, but didn’t. I don’t want them to laugh at me. 😉

Waffle Fries to the Rescue

With the BoxViews not working out, I went to lunch to clear my head and to think. I love lunch and I don’t miss a meal. That day, I decided to go to Chick Fil A and get a chicken sandwich with a side of epiphany fries.

There I was, eating my chicken and dunking my fries in ketchup (Sauce de American). When I dipped a waffle fry into the ketchup, the ketchup squeezed through the holes and made a red checkerboard on top of the fry. Then it hit me. Bam!

I was going about the card UI backwards or forwards. Either way, it was the wrong way. I had to do an about face and approach it in another way. The way the ketchup came up through the fry not by putting ketchup onto the fry.

A Grid of Lines

As soon as I got home, I worked up a Xamarin.Forms Grid with some padding, row and column spacing. In addition to those settings, I also set the background color of the grid to a medium dark grey. Then added ContentViews with white backgrounds into each cell of the Grid. This is what it looked like when I finished.

GridLines

The white panels acted like the ketchup on my waffle fries and the borders are the potato. Yes, I know, it’s strange to describe Xamarin.Forms design techniques using food, but stay with me; it gets better. Now that I knew the technique worked and was a heck of a lot less messy, I pushed on.

Content View Panels

Each CardView is made up of 5 ContentViews with a background color set to the designed color. Here are some of the background colors for each panel.

Panels

The CardView.cs file would have been gigantic if I kept all the code in the same file so I broke it up into different ContentViews. Here are the names for each ContentView that makes up the CardView.

CardViews

The CardDetailsView has a column span of three to horizontally bridge the two IconLableViews and the ConfigIconView. The CardStatusView has a row span of two to complete the vertical lefthand status bar.

The CardView Code

For the demo, I put a couple of CardViews in a vertical StackLayout. If I had a lot of cards, I would prefer to use a ListView. Hopefully a reader will let me know how well this design works in a ListView. It should be ok, especially while using the Grid and not a bunch of nested StackLayouts. I’ve learned my lesson.

public class CardView : ContentView
{
public CardView (Card card)
{
Grid grid = new Grid {
Padding = new Thickness (0, 1, 1, 1),
RowSpacing = 1,
ColumnSpacing = 1, 
BackgroundColor = StyleKit.CardBorderColor,
VerticalOptions = LayoutOptions.FillAndExpand,
RowDefinitions = {
new RowDefinition { Height = new GridLength (70, GridUnitType.Absolute) },
new RowDefinition { Height = new GridLength (30, GridUnitType.Absolute) }
},
ColumnDefinitions = {
new ColumnDefinition { Width = new GridLength (4, GridUnitType.Absolute) },
new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength (100, GridUnitType.Absolute) },
new ColumnDefinition { Width = new GridLength (50, GridUnitType.Absolute) }
}
};

grid.Children.Add (
new CardStatusView (card)
, 0, 1, 0, 2);

grid.Children.Add (new CardDetailsView (card), 1, 4, 0, 1);

grid.Children.Add (
new IconLabelView (
card.StatusMessageFileSource,
card.StatusMessage
)
, 1, 1);

grid.Children.Add (
new IconLabelView (
card.ActionMessageFileSource,
card.ActionMessage
)
, 2, 1);

grid.Children.Add (new ConfigIconView (), 3, 1);

Content = grid;
}
}

With all the refactoring; the CardView looks small and plain but the devil is in the ContentViews.

 

Final Layout:

Solution

The code for this sample is up on GitHub in the “In Anger” repository. For this post, I broke the code out into a separate directory and solution to make it easier for you to reuse the CardView without getting confused with all the other code and resources from other posts.

Moar Epiphany Fires

Who knew that a humble waffle fry would be the answer to the Xamarin.Forms CardView? Not me; I go for the chicken. Don’t you worry dear read, I will continue to go to “Chick Fil a” to get more Xamarin.Forms design inspiration in the future. Stay tuned to this blog and, if you have a design challenge, just put it in the comments below or email me at adam [at] adamjwolf dot com.

Xamarin.Forms in Anger Series

Can Xamarin.Forms produce good looking cross-platform UI from a single codebase? Each “In Anger” blog post will tackle a single page of a beautifully designed iOS or Android application. My job will be to reproduce the design in Xamarin.Forms as faithfully as possible.

If you want to split a Single Linear layout into a Two Columns(Like newspaper Columns). Here’s the layout for it. Use recursively as per your requirement:


 <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/item" />

            <TextView
                android:id="@+id/text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>

        </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical" >

            <ImageView
                content here/>

            <TextView
                content here/>

        </LinearLayout>
    </LinearLayout>

If anyone wants to split the android layout into two parts horizontally then use the below snippet.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FF0000"
    android:weightSum="4"
    android:padding="5dp"> <!-- to show what the parent is -->
    <LinearLayout
        android:background="#0000FF"
        android:layout_height="0dp"
        android:layout_width="match_parent"
        android:layout_weight="2" />
    <LinearLayout
        android:background="#00FF00"
        android:layout_height="0dp"
        android:layout_width="match_parent"
        android:layout_weight="1" />
</LinearLayout>

 

You can recursively use this layout as per your requirement.