blob: edee2fe231fae9e621597d85b7a366784cddd59e [file] [log] [blame]
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Christophe Coenraets, http://coenraets.org -->
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:charts="charts.*"
width="100%" height="100%"
creationComplete="creationComplete()"
viewActivate="activateHandler()"
viewDeactivate="deactivateHandler()">
<fx:Script>
<![CDATA[
import controller.Feed;
import mx.core.FlexGlobals;
[Bindable]
[Embed("assets/up.png")]
protected var iconUp:Class;
[Bindable]
[Embed("assets/down.png")]
protected var iconDown:Class;
protected var feed:Feed;
protected function creationComplete():void
{
feed = FlexGlobals.topLevelApplication.feed;
}
protected function activateHandler():void
{
feed.subscribe();
}
protected function deactivateHandler():void
{
feed.unsubscribe();
}
override public function setCurrentState(stateName:String, playTransition:Boolean=true):void
{
if (stateName == "landscape")
{
if (FlexGlobals.topLevelApplication.height<500)
super.setCurrentState("landscapeSmall", playTransition);
else if (FlexGlobals.topLevelApplication.height<600)
super.setCurrentState("landscapeMedium", playTransition);
else
super.setCurrentState("landscapeLarge", playTransition);
}
else
{
super.setCurrentState(stateName, playTransition);
}
}
]]>
</fx:Script>
<s:states>
<s:State name="portrait"/>
<s:State name="landscape"/>
<s:State name="landscapeSmall"/>
<s:State name="landscapeMedium"/>
<s:State name="landscapeLarge"/>
</s:states>
<fx:Declarations>
<s:NumberFormatter id="nf" fractionalDigits="2" trailingZeros="true"/>
</fx:Declarations>
<s:navigationContent>
<s:Button icon="@Embed('assets/back.png')" click="navigator.popView();" height="55"/>
</s:navigationContent>
<s:Label text="{data.symbol}" fontSize="36" left="10" top="10" height="79" width="95" backgroundColor="#F0F0F0" verticalAlign="middle" textAlign="center" color="#646464"/>
<s:HGroup top="10" left="106" right="10" gap="1">
<s:Label text="Open" width="85" height="39" backgroundColor="#919191" verticalAlign="middle" paddingRight="8" textAlign="right"/>
<s:Label text="Last" width="85" height="39" backgroundColor="#919191" verticalAlign="middle" paddingRight="8" textAlign="right"/>
<s:Label text="Change" width="85" height="39" backgroundColor="#919191" verticalAlign="middle" paddingRight="8" textAlign="right" includeIn="landscapeLarge,landscapeMedium,landscapeSmall"/>
<s:Label text="High" width="85" height="39" backgroundColor="#919191" verticalAlign="middle" paddingRight="8" textAlign="right"/>
<s:Label text="Low" width="85" height="39" backgroundColor="#919191" verticalAlign="middle" paddingRight="8" textAlign="right"/>
</s:HGroup>
<s:HGroup top="50" left="106" right="10" gap="1">
<s:Label text="{nf.format(data.open)}" width="85" height="39" backgroundColor="#F0F0F0" verticalAlign="middle" paddingRight="8" textAlign="right"/>
<s:Group>
<s:Label text="{nf.format(data.last)}" color="{data.change>0?0x006600:0xFF0000}" width="85" height="39" backgroundColor="#F0F0F0" verticalAlign="middle" paddingRight="18" textAlign="right"/>
<s:Image source="{data.change>0?iconUp:iconDown}" x="70" y="14"/>
</s:Group>
<s:Label text="{nf.format(data.change)}" color="{data.change>0?0x006600:0xFF0000}" width="85" height="39" backgroundColor="#F0F0F0" verticalAlign="middle" paddingRight="8" textAlign="right" includeIn="landscapeLarge,landscapeMedium,landscapeSmall"/>
<s:Label text="{nf.format(data.high)}" width="85" height="39" backgroundColor="#F0F0F0" verticalAlign="middle" paddingRight="8" textAlign="right"/>
<s:Label text="{nf.format(data.low)}" width="85" height="39" backgroundColor="#F0F0F0" verticalAlign="middle" paddingRight="8" textAlign="right"/>
</s:HGroup>
<charts:RealTimeChart stock="{data}"
top="150" top.landscapeSmall="120" top.landscapeMedium="120"
height="350" height.landscapeSmall="{undefined}" height.landscapeMedium="{undefined}"
bottom.landscapeSmall="30" bottom.landscapeMedium="40" left="20" right="20"/>
<s:Label bottom="4" text="Rotate device for bigger chart." fontSize="16" color="#AAAAAA" horizontalCenter="0" includeIn="portrait"/>
</s:View>