| <?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. |
| |
| --> |
| <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" |
| xmlns:s="library://ns.adobe.com/flex/spark" |
| autoDrawBackground="true"> |
| |
| <fx:Script> |
| <![CDATA[ |
| override public function set data(value:Object):void { |
| if (value == null) |
| return; |
| |
| // short circuit extra data setter calls (we're using strings as data here) |
| if (value == super.data) |
| return |
| |
| super.data = value; |
| |
| var theDataString:String = data as String; |
| |
| if (theDataString.length > 1){ // is not a heading |
| firstName.text = theDataString.split(" ")[0]; |
| lastName.text = theDataString.split(" ")[1]; |
| lastName.visible = true; |
| headerBG.includeInLayout = headerBG.visible = false; |
| firstName.top = firstName.bottom = 20; |
| lastName.top = lastName.bottom = 20; |
| } else { // is a heading |
| firstName.text = theDataString; |
| lastName.visible = false; |
| headerBG.includeInLayout = headerBG.visible = true; |
| firstName.top = firstName.bottom = 5; |
| lastName.top = lastName.bottom = 5; |
| } |
| } |
| |
| override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { |
| super.updateDisplayList(unscaledWidth, unscaledHeight); |
| |
| // move the lastName label into place rather than using an HGroup |
| lastName.setLayoutBoundsPosition(firstName.x + firstName.width + 6, firstName.y); |
| } |
| |
| ]]> |
| </fx:Script> |
| |
| <s:Rect id="headerBG" width="100%" height="100%" includeInLayout="false"> |
| <s:fill> |
| <s:LinearGradient rotation="90"> |
| <s:GradientEntry color="#909faa" ratio="0" alpha="1"/> |
| <s:GradientEntry color="#b8c1c8" ratio="1" alpha="1"/> |
| </s:LinearGradient> |
| </s:fill> |
| </s:Rect> |
| |
| <s:Rect width="100%" height="1" bottom="0"> |
| <s:fill> |
| <s:SolidColor color="0xe0e0e0" /> |
| </s:fill> |
| </s:Rect> |
| |
| <s:Label id="firstName" left="20" fontSize="32" fontWeight="bold" /> |
| <s:Label id="lastName" fontSize="32" /> |
| |
| </s:ItemRenderer> |