Advertisement
leokan23

Untitled

Jul 30th, 2020
5,220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?xml version="1.0"?>
  2. <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
  3.         xmlns:leaderboard="components.leaderboard.*" title="The World" initialize="init()">
  4.  
  5.     <fx:Script><![CDATA[
  6.         import classes.GoogleMapsStaticAPI;
  7.         import classes.globals;
  8.  
  9.         import components.BackButtonGrey;
  10.  
  11.         import mx.collections.ArrayCollection;
  12.  
  13.         import mx.graphics.SolidColor;
  14.  
  15.         import mx.graphics.SolidColorStroke;
  16.  
  17.         import services.UserService;
  18.  
  19.         [Bindable]
  20.         private var PERCENTAGE_COUNTRIES_VISITED=0;
  21.  
  22.         [Bindable]
  23.         private var COUNTRIES_VISITED=0;
  24.         [Bindable]
  25.         private var AFRICA_VISITED=0;
  26.         [Bindable]
  27.         private var EUROPE_VISITED=0;
  28.  
  29.         private var africaArray:ArrayCollection = new ArrayCollection();
  30.         private var asiaArray:ArrayCollection = new ArrayCollection();
  31.         private var europeArray:ArrayCollection = new ArrayCollection();
  32.         private var northAmericaArray:ArrayCollection = new ArrayCollection();
  33.         private var southAmericaArray:ArrayCollection = new ArrayCollection();
  34.         private var australiaArray:ArrayCollection = new ArrayCollection();
  35.         private var antarcticaArray:ArrayCollection = new ArrayCollection();
  36.         private var restArray:ArrayCollection = new ArrayCollection();
  37.  
  38.  
  39.  
  40.         private function init():void {
  41.             var u:UserService = new UserService();
  42.             u.getVisitedCountries(globals.MY_USER.id, processVisitedCountries);
  43.         }
  44.  
  45.         private function processVisitedCountries(result:Object)
  46.         {
  47.             if(result.markers)
  48.             {
  49.                 var mapUrl:String = GoogleMapsStaticAPI.instance.getMapWithStyleForProfile(mapImage.width, mapImage.height, 30,0,1)+result.markers;
  50.                 trace(mapUrl);
  51.  
  52.                 mapImage.source = mapUrl;
  53.             }
  54.             if(result)
  55.             {
  56.                 COUNTRIES_VISITED = result.visitedCount;
  57.                 PERCENTAGE_COUNTRIES_VISITED = ((result.visitedCount*100)/255).toPrecision(1);
  58.  
  59.                 for each (var item in result.data){
  60.                     switch (item.continent) {
  61.                         case '1':
  62.                             africaArray.addItem(item);
  63.                             break;
  64.                         case '2':
  65.                             asiaArray.addItem(item);
  66.                             break;
  67.                         case '3':
  68.                             europeArray.addItem(item);
  69.                             break;
  70.                         case '4':
  71.                                 northAmericaArray.addItem(item);
  72.                             break;
  73.                         case '5':
  74.                                 southAmericaArray.addItem(item);
  75.                             break;
  76.                         case '6':
  77.                                 australiaArray.addItem(item);
  78.                             break;
  79.                         case '7':
  80.                                 antarcticaArray.addItem(item);
  81.                             break;
  82.                         case '8':
  83.                                 restArray.addItem(item);
  84.                             break;
  85.                     }
  86.  
  87.                 }
  88.  
  89.                 africaCard.countriesVisited = africaArray.length;
  90.                 asiaCard.countriesVisited = asiaArray.length;
  91.                 europeCard.countriesVisited = europeArray.length;
  92.                 northAmericaCard.countriesVisited = northAmericaArray.length;
  93.                 southAmericaCard.countriesVisited = southAmericaArray.length;
  94.                 australiaCard.countriesVisited = australiaArray.length;
  95.                 antarcticaCard.countriesVisited = antarcticaArray.length;
  96.                 restCard.countriesVisited = restArray.length;
  97.             }
  98.  
  99.             //TODO - Navigate to details list with search for countries and allow user to remove visited countries
  100.  
  101.  
  102.         }
  103.  
  104.         ]]></fx:Script>
  105.  
  106.     <s:navigationContent>
  107.         <s:Button icon="{new BackButtonGrey()}" click="navigator.popView()"/>
  108.     </s:navigationContent>
  109.  
  110.     <s:Scroller width="100%" height="100%">
  111.         <s:VGroup width="100%" gap="0">
  112.             <s:Group width="100%" height="425">
  113.                 <!--<s:Rect width="100%" height="100%" fill="{new SolidColor(0xb6b6b6,1)}" />-->
  114.                 <s:BusyIndicator horizontalCenter="0" verticalCenter="0"/>
  115.                 <s:Image id="mapImage" width="100%" height="425" scaleMode="letterbox" smooth="true"  />
  116.  
  117.             </s:Group>
  118.  
  119.             <s:Group width="100%" height="120">
  120.                <!-- <s:Rect width="100%" height="100%" fill="{new SolidColor(0xe5e5e5,1)}" />-->
  121.                 <s:HGroup width="100%" height="100%" gap="25" verticalAlign="middle" paddingLeft="15" >
  122.                     <s:BorderContainer width="60" height="60" borderAlpha="0" backgroundColor="#00AEEF" backgroundAlpha="0.15" cornerRadius="12">
  123.                         <s:RichText width="100%" textAlign="center" horizontalCenter="0" verticalCenter="0">
  124.                             <s:content>
  125.                                 <s:span fontSize="20" fontFamily="Montserrat-SemiBoldCFF" color="#00AEEF" >{PERCENTAGE_COUNTRIES_VISITED}</s:span><s:span fontSize="15" fontFamily="Montserrat-RegularCFF" color="#00AEEF" >%</s:span>
  126.                             </s:content>
  127.                         </s:RichText>
  128.                     </s:BorderContainer>
  129.  
  130.                     <s:VGroup >
  131.                         <s:Label text="You explored {COUNTRIES_VISITED} countries" color="#C5CFDA" />
  132.                         <s:Label text="bar goes here" />
  133.                     </s:VGroup>
  134.  
  135.  
  136.                 </s:HGroup>
  137.  
  138.                 <s:Line bottom="0" width="90%" horizontalCenter="0" stroke="{new SolidColorStroke(0xEBEBEB,1)}"/>
  139.             </s:Group>
  140.  
  141.             <leaderboard:CountriesVisitedCard id="africaCard" continentIcon="assets/640/africa.png" countryName="Africa"
  142.                                               totalCountries="54"/>
  143.  
  144.             <leaderboard:CountriesVisitedCard id="asiaCard" continentIcon="assets/640/asia.png" countryName="Asia"
  145.                                               totalCountries="48"/>
  146.  
  147.             <leaderboard:CountriesVisitedCard id="europeCard" continentIcon="assets/640/Europe.png" countryName="Europe"
  148.                                               totalCountries="44"/>
  149.  
  150.             <leaderboard:CountriesVisitedCard id="northAmericaCard" continentIcon="assets/640/north_america.png"
  151.                                               countryName="North America" totalCountries="23"/>
  152.  
  153.             <leaderboard:CountriesVisitedCard id="southAmericaCard" continentIcon="assets/640/south_america.png"
  154.                                               countryName="South America" totalCountries="14"/>
  155.  
  156.             <leaderboard:CountriesVisitedCard id="australiaCard" continentIcon="assets/640/australia.png"
  157.                                               countryName="Australia" totalCountries="3
  158. "/>
  159.  
  160.             <leaderboard:CountriesVisitedCard id="antarcticaCard" continentIcon="assets/640/antarctica.png"
  161.                                               countryName="Antarctica" totalCountries="1"/>
  162.  
  163.             <leaderboard:CountriesVisitedCard id="restCard" continentIcon="assets/640/rest.png" countryName="Rest of World"
  164.                                               totalCountries="1"/>
  165.         </s:VGroup>
  166.     </s:Scroller>
  167. </s:View>
  168.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement