[MainView] Create "clear all" button. 34/129234/4
authorKamil Lipiszko <k.lipiszko@DIGITAL.local>
Mon, 15 May 2017 13:51:37 +0000 (15:51 +0200)
committerKamil Lipiszko <k.lipiszko@DIGITAL.local>
Sat, 20 May 2017 11:02:04 +0000 (13:02 +0200)
[OAPRNA-188] Patch fixes items positions and creates white line below.
Additionally creates "clear all" button with command binded to the
view model called on X icon tap.

Change-Id: I78ff6e3532561aeddab8ade7d6ca4e9d1fb93bfe

TaskManager/TaskManager.Tizen/TaskManager.Tizen.csproj
TaskManager/TaskManager.Tizen/ViewModels/MainViewModel.cs
TaskManager/TaskManager.Tizen/Views/AppItemView.xaml
TaskManager/TaskManager.Tizen/Views/ClearAllItemView.xaml [new file with mode: 0644]
TaskManager/TaskManager.Tizen/Views/ClearAllItemView.xaml.cs [new file with mode: 0644]
TaskManager/TaskManager.Tizen/Views/MainView.xaml
TaskManager/TaskManager.Tizen/res/images/clear_all_button_icon.png [new file with mode: 0644]

index 9850eeb993bb05fb3307e890ea9e3fd3ac863959..5b32834a031f747a11d491c6671b60e242f3b01a 100644 (file)
       <DependentUpon>AppItemView.xaml</DependentUpon>
     </Compile>
     <Compile Include="Views\BindableStackLayout.cs" />
+    <Compile Include="Views\ClearAllItemView.xaml.cs">
+      <DependentUpon>ClearAllItemView.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\MainView.xaml.cs">
       <DependentUpon>MainView.xaml</DependentUpon>
     </Compile>
   </ItemGroup>
   <ItemGroup>
     <Folder Include="lib\" />
-    <Folder Include="res\" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="Views\MainView.xaml">
       <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
     </EmbeddedResource>
   </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Views\ClearAllItemView.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="res\images\clear_all_button_icon.png" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
                Other similar extension points exist, see Microsoft.Common.targets.
index b1fd49679fdc52fdc9656c32cb4da178fd05e061..ad28fec64ca2601beb000b8e6314a015b405557e 100644 (file)
@@ -20,19 +20,19 @@ namespace TaskManager.Tizen.ViewModels
         public MainViewModel()
         {
             this.Applications = new ObservableCollection<ApplicationInfo>();
-            //this.Applications.Add(new ApplicationInfo { Name = "Video", Icon = "/usr/apps/org.tizen.videos/shared/res/org.tizen.videos.png" });
-            //this.Applications.Add(new ApplicationInfo { Name = "Settings", Icon = "/usr/apps/org.tizen.setting/shared/res/org.tizen.setting.png" });
-            //this.Applications.Add(new ApplicationInfo { Name = "Contacts", Icon = "/usr/apps/org.tizen.contacts/shared/res/org.tizen.contacts.png" });
-            //this.Applications.Add(new ApplicationInfo { Name = "My Files", Icon = "/usr/apps/org.tizen.myfile/shared/res/org.tizen.myfile.png" });
-            //this.Applications.Add(new ApplicationInfo { Name = "Music", Icon = "/usr/apps/org.tizen.music-player/shared/res/org.tizen.music-player.png" });
-            //this.Applications.Add(new ApplicationInfo { Name = "Messages", Icon = " /usr/apps/org.tizen.message/shared/res/message.png" });
-            //this.Applications.Add(new ApplicationInfo { Name = "Memo", Icon = " /usr/apps/org.tizen.memo/shared/res/org.tizen.memo.png" });
-            //this.Applications.Add(new ApplicationInfo { Name = "Internet", Icon = "/usr/apps/org.tizen.browser/shared/res/org.tizen.browser.png" });
-            //this.Applications.Add(new ApplicationInfo { Name = "Gallery", Icon = "/usr/apps/org.tizen.gallery/shared/res/org.tizen.gallery.png" });
-            //this.Applications.Add(new ApplicationInfo { Name = "Email", Icon = "/usr/apps/org.tizen.email/shared/res/org.tizen.email.png" });
-            //this.Applications.Add(new ApplicationInfo { Name = "Camera", Icon = "/usr/apps/org.tizen.camera-app/shared/res/org.tizen.camera-app.png" });
-            //this.Applications.Add(new ApplicationInfo { Name = "Clock", Icon = " /usr/apps/org.tizen.clock/shared/res/clock.png" });
-            //this.Applications.Add(new ApplicationInfo { Name = "Calendar", Icon = "/usr/apps/org.tizen.calendar/shared/res/calendar.png" });
+            this.Applications.Add(new ApplicationInfo { Name = "Video", Icon = "/usr/apps/org.tizen.videos/shared/res/org.tizen.videos.png" });
+            this.Applications.Add(new ApplicationInfo { Name = "Settings", Icon = "/usr/apps/org.tizen.setting/shared/res/org.tizen.setting.png" });
+            this.Applications.Add(new ApplicationInfo { Name = "Contacts", Icon = "/usr/apps/org.tizen.contacts/shared/res/org.tizen.contacts.png" });
+            this.Applications.Add(new ApplicationInfo { Name = "My Files", Icon = "/usr/apps/org.tizen.myfile/shared/res/org.tizen.myfile.png" });
+            this.Applications.Add(new ApplicationInfo { Name = "Music", Icon = "/usr/apps/org.tizen.music-player/shared/res/org.tizen.music-player.png" });
+            this.Applications.Add(new ApplicationInfo { Name = "Messages", Icon = " /usr/apps/org.tizen.message/shared/res/message.png" });
+            this.Applications.Add(new ApplicationInfo { Name = "Memo", Icon = " /usr/apps/org.tizen.memo/shared/res/org.tizen.memo.png" });
+            this.Applications.Add(new ApplicationInfo { Name = "Internet", Icon = "/usr/apps/org.tizen.browser/shared/res/org.tizen.browser.png" });
+            this.Applications.Add(new ApplicationInfo { Name = "Gallery", Icon = "/usr/apps/org.tizen.gallery/shared/res/org.tizen.gallery.png" });
+            this.Applications.Add(new ApplicationInfo { Name = "Email", Icon = "/usr/apps/org.tizen.email/shared/res/org.tizen.email.png" });
+            this.Applications.Add(new ApplicationInfo { Name = "Camera", Icon = "/usr/apps/org.tizen.camera-app/shared/res/org.tizen.camera-app.png" });
+            this.Applications.Add(new ApplicationInfo { Name = "Clock", Icon = " /usr/apps/org.tizen.clock/shared/res/clock.png" });
+            this.Applications.Add(new ApplicationInfo { Name = "Calendar", Icon = "/usr/apps/org.tizen.calendar/shared/res/calendar.png" });
         }
 
         public ObservableCollection<ApplicationInfo> Applications { get; private set; }
index ce71adb4218ff42da8aca573823e22887b08b0fa..b4abf233975f4dbe4d28664d150201f519402faa 100644 (file)
@@ -4,13 +4,14 @@
              x:Class="TaskManager.Tizen.Views.AppItemView"
              >
   <ContentView.Content>
-    <RelativeLayout>
+    <RelativeLayout HeightRequest="118" Padding="0, 31">
       <AbsoluteLayout RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0, Constant=0}"
-                      RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=0}">
+                      RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=0}"
+                      RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=0}">
         <Image x:Name="AppIcon" Source="{Binding Icon}"
                AbsoluteLayout.LayoutBounds=".5, .5, 118, 118" AbsoluteLayout.LayoutFlags="PositionProportional"/>
-        <Label x:Name="AppName" Text="{Binding Name}" VerticalTextAlignment="Center" TextColor="White" FontSize="20" FontAttributes="Bold"
-               AbsoluteLayout.LayoutBounds="1, .5, 0.38, .24" AbsoluteLayout.LayoutFlags="All"/>
+        <Label x:Name="AppName" Text="{Binding Name}" VerticalTextAlignment="Center" TextColor="White" FontSize="20" FontAttributes="Bold" VerticalOptions="CenterAndExpand"
+               AbsoluteLayout.LayoutBounds="1, .5, 0.38, 1" AbsoluteLayout.LayoutFlags="All"/>
       </AbsoluteLayout>
     </RelativeLayout>
   </ContentView.Content>
diff --git a/TaskManager/TaskManager.Tizen/Views/ClearAllItemView.xaml b/TaskManager/TaskManager.Tizen/Views/ClearAllItemView.xaml
new file mode 100644 (file)
index 0000000..dd0643e
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
+             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+             xmlns:views="clr-namespace:TaskManager.Tizen.Views;assembly=TaskManager.Tizen"
+             x:Class="TaskManager.Tizen.Views.ClearAllItemView"
+             >
+
+  <ContentView.Content>
+    <AbsoluteLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
+      <Image x:Name="AppIcon" Source="images/clear_all_button_icon.png"
+             AbsoluteLayout.LayoutBounds=".5, .5, 62, 62" AbsoluteLayout.LayoutFlags="PositionProportional">
+             <Image.GestureRecognizers>
+               <TapGestureRecognizer Tapped="OnTapped"/>
+             </Image.GestureRecognizers>
+        </Image>
+      <Label x:Name="AppName" Text="Clear all" VerticalTextAlignment="Center" TextColor="White" FontSize="20" FontAttributes="Bold" VerticalOptions="CenterAndExpand" 
+             AbsoluteLayout.LayoutBounds="1, .5, 0.38, 1" AbsoluteLayout.LayoutFlags="All"/>
+      </AbsoluteLayout>
+  </ContentView.Content>
+</ContentView>
diff --git a/TaskManager/TaskManager.Tizen/Views/ClearAllItemView.xaml.cs b/TaskManager/TaskManager.Tizen/Views/ClearAllItemView.xaml.cs
new file mode 100644 (file)
index 0000000..93df7ad
--- /dev/null
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+using Tizen;
+using Xamarin.Forms;
+
+namespace TaskManager.Tizen.Views
+{
+    public partial class ClearAllItemView : ContentView
+    {
+        public static readonly BindableProperty OnIconTappedProperty = BindableProperty.Create(nameof(OnIconTapped), typeof(ICommand), typeof(ContentView), null, BindingMode.OneWay, null);
+        public ICommand OnIconTapped
+        {
+            set
+            {
+                SetValue(OnIconTappedProperty, value);
+            }
+            get
+            {
+                return (ICommand)GetValue(OnIconTappedProperty);
+            }
+        }
+
+        public ClearAllItemView()
+        {
+            InitializeComponent();
+        }
+
+        private void OnTapped(object sender, EventArgs e)
+        {
+            OnIconTapped?.Execute(sender);
+        }
+    }
+}
index 4fe3dcbffb20b2cf4a5d7404169f9e9f0d5843a9..c783f2c82e485ec59d05eb622bdec0c73e42f7f9 100644 (file)
            IsVisible="{Binding Applications, Converter={StaticResource InvertListToBoolConverter}}"/>
 
     <ScrollView AbsoluteLayout.LayoutBounds=".5, .5, 1, 1" AbsoluteLayout.LayoutFlags="All" IsVisible="{Binding Applications, Converter={StaticResource ListToBoolConverter}}">
-      <views:BindableStackLayout ItemsSource="{Binding Applications}" >
-        <views:BindableStackLayout.ItemTemplate>
-          <DataTemplate>
-            <ViewCell>
-              <views:AppItemView></views:AppItemView>
-            </ViewCell>
-          </DataTemplate>
-        </views:BindableStackLayout.ItemTemplate>
-      </views:BindableStackLayout>
+      <StackLayout>
+        <BoxView VerticalOptions="FillAndExpand" HeightRequest="210"/>
+        <AbsoluteLayout>
+          <BoxView BackgroundColor="White" AbsoluteLayout.LayoutBounds=".5, 31, 2, 1" AbsoluteLayout.LayoutFlags="XProportional, HeightProportional"/>
+          <views:ClearAllItemView AbsoluteLayout.LayoutBounds=".5, .0, 1, 62" AbsoluteLayout.LayoutFlags="PositionProportional, WidthProportional" OnIconTapped="{Binding KillAll}"/>
+          <views:BindableStackLayout ItemsSource="{Binding Applications}" Padding="0, 25, 0, 0" AbsoluteLayout.LayoutBounds=".5, 62, 1, 1" AbsoluteLayout.LayoutFlags="XProportional, HeightProportional, WidthProportional">
+            <views:BindableStackLayout.ItemTemplate>
+              <DataTemplate>
+                <ViewCell>
+                  <views:AppItemView/>
+                </ViewCell>
+              </DataTemplate>
+            </views:BindableStackLayout.ItemTemplate>
+          </views:BindableStackLayout>
+        </AbsoluteLayout>
+      </StackLayout>
     </ScrollView>
 
   </AbsoluteLayout>
diff --git a/TaskManager/TaskManager.Tizen/res/images/clear_all_button_icon.png b/TaskManager/TaskManager.Tizen/res/images/clear_all_button_icon.png
new file mode 100644 (file)
index 0000000..4ba500c
Binary files /dev/null and b/TaskManager/TaskManager.Tizen/res/images/clear_all_button_icon.png differ