TizenRefApp-8630 Implement IncomingCall view 51/151351/11
authorRuslan Zakharov <r.zakharov@samsung.com>
Wed, 20 Sep 2017 10:06:52 +0000 (13:06 +0300)
committerRuslan Zakharov <r.zakharov@samsung.com>
Wed, 22 Nov 2017 11:06:40 +0000 (13:06 +0200)
Added IncomingCall view

Change-Id: I462a2ac9f3447800076d3ba2aead70a9c122a3cd

CallApp.Tizen/Call/Helper/RejectMessage.cs [new file with mode: 0644]
CallApp.Tizen/Call/Helper/TestModelCreator.cs
CallApp.Tizen/Call/Manager/MessagesManager.cs
CallApp.Tizen/Call/View/Controls/RejectCallPanel.xaml
CallApp.Tizen/Call/View/Controls/RejectCallPanel.xaml.cs
CallApp.Tizen/Call/View/IncomingCallView.xaml
CallApp.Tizen/Call/View/IncomingCallView.xaml.cs
CallApp.Tizen/Call/ViewModel/IncomingCallViewModel.cs
CallApp.Tizen/CallApp.Tizen.csproj
CallApp.Tizen/Common/Themes/CommonTheme.xaml

diff --git a/CallApp.Tizen/Call/Helper/RejectMessage.cs b/CallApp.Tizen/Call/Helper/RejectMessage.cs
new file mode 100644 (file)
index 0000000..40bca81
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * 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.
+ */
+
+namespace CallApp.Tizen.Call.Helper
+{
+    /// <summary>
+    /// Reject message structure
+    /// </summary>
+    public struct RejectMessage
+    {
+        public RejectMessage(string message)
+        {
+            Message = message;
+        }
+
+        public string Message
+        {
+            get;
+            private set;
+        }
+    }
+}
index 86cadd5..a7239ab 100644 (file)
@@ -51,22 +51,22 @@ namespace CallApp.Tizen.Call.Helper
         /// <returns>ConferenceCallViewModel</returns>
         public static ConferenceCallViewModel CreateConferenceCallViewModel()
         {
-            CallModel callModelAS = new CallModel(0);
-            callModelAS.ContactModel.Name = "John Doe";
-            callModelAS.CallerNumber = "+321224994574";
+            CallModel callModel01 = new CallModel(0);
+            callModel01.ContactModel.Name = "John Plumber";
+            callModel01.CallerNumber = "+322256032712";
 
-            CallModel callModelGA = new CallModel(0);
-            callModelGA.ContactModel.Name = "Princess Doe";
-            callModelGA.CallerNumber = "+329118070585";
+            CallModel callModel02 = new CallModel(0);
+            callModel02.ContactModel.Name = "Eddie Punch-Clock";
+            callModel02.CallerNumber = "+370235512098";
 
-            CallModel callModelRZ = new CallModel(0);
-            callModelRZ.ContactModel.Name = "Vasia Pupkin";
-            callModelRZ.CallerNumber = "+335286157242";
+            CallModel callModel03 = new CallModel(0);
+            callModel03.ContactModel.Name = "Johnny Lunch-Pail";
+            callModel03.CallerNumber = "+386691614669";
 
             CallManager callManager = new CallManager();
-            callManager.Calls.Add(callModelAS);
-            callManager.Calls.Add(callModelGA);
-            callManager.Calls.Add(callModelRZ);
+            callManager.Calls.Add(callModel01);
+            callManager.Calls.Add(callModel02);
+            callManager.Calls.Add(callModel03);
 
             return new ConferenceCallViewModel(callManager);
         }
@@ -85,8 +85,28 @@ namespace CallApp.Tizen.Call.Helper
                 }
             };
 
-            vm.EndCall.ContactModel.Name = "Ruslan Zakharov";
-            vm.EndCall.CallerNumber = "+380676470707";
+            vm.EndCall.ContactModel.Name = "John Doe";
+            vm.EndCall.CallerNumber = "+321224994574";
+
+            return vm;
+        }
+
+        /// <summary>
+        /// Create test IncomingCallViewModel
+        /// </summary>
+        /// <returns>IncomingCallViewModel</returns>
+        public static IncomingCallViewModel CreateIncomingCallViewModel()
+        {
+            IncomingCallViewModel vm = new IncomingCallViewModel(new CallManager())
+            {
+                IncomingCall = new CallModel(0)
+                {
+                    Status = CallStatus.Incoming
+                }
+            };
+
+            vm.IncomingCall.ContactModel.Name = "John Doe";
+            vm.IncomingCall.CallerNumber = "+321224994574";
 
             return vm;
         }
index dad8d4d..78fdf19 100644 (file)
@@ -14,7 +14,8 @@
  * limitations under the License.
  */
 
-using System.Collections.Generic;
+using CallApp.Tizen.Call.Helper;
+using System.Collections.ObjectModel;
 
 namespace CallApp.Tizen.Call.Manager
 {
@@ -36,9 +37,18 @@ namespace CallApp.Tizen.Call.Manager
         /// Gets default messages answers
         /// </summary>
         /// <returns>List of default messages answers</returns>
-        public List<string> GetMessageList()
+        public ObservableCollection<RejectMessage> GetMessageList()
         {
-            return null;
+            // FIXME: This block of code only for testing and should be removed after real API implementation
+            return new ObservableCollection<RejectMessage>()
+            {
+                new RejectMessage(Localization.Localization.PleaseTextMeRejectMessage),
+                new RejectMessage(Localization.Localization.WhatsUpRejectMessage),
+                new RejectMessage(Localization.Localization.InMeetingRejectMessage),
+                new RejectMessage(Localization.Localization.DrivingNowRejectMessage),
+                new RejectMessage(Localization.Localization.CallYouLaterRejectMessage)
+            };
+            //
         }
 
         /// <summary>
index 5f433de..2f4c29a 100644 (file)
             <Color x:Key="BottomInlineButtonNormalColor">#FFFAFAFA</Color>
 
             <ControlTemplate x:Key="TopOpenDirectionPanel">
-                <TizenUtilityControls:CustomGrid HeightRequest="{TemplateBinding DefaultHeight}">
-                    <Grid.RowDefinitions>
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="78" />
-                        <RowDefinition Height="22" />
-                        <RowDefinition Height="Auto" />
-                    </Grid.RowDefinitions>
-
-                    <TizenUtilityControls:GesturesContainer Grid.Row="0" PanUpdated="OnPanUpdated">
-                        <TizenUtilityControls:CustomGrid>
-                            <Grid.RowDefinitions>
-                                <RowDefinition Height="12" />
-                                <RowDefinition Height="18" />
-                                <RowDefinition Height="20" />
-                            </Grid.RowDefinitions>
-
-                            <TizenUtilityControls:CustomImage Grid.Row="1" BlendingColor="{StaticResource TopInlineButtonNormalColor}" Source="call_inline_btn_open.png">
-                                <TizenUtilityControls:CustomImage.Triggers>
-                                    <DataTrigger TargetType="TizenUtilityControls:CustomImage" Binding="{TemplateBinding IsOpen}" Value="True">
-                                        <Setter Property="Source" Value="call_inline_btn_close.png" />
-                                    </DataTrigger>
-                                </TizenUtilityControls:CustomImage.Triggers>
-                            </TizenUtilityControls:CustomImage>
-                        </TizenUtilityControls:CustomGrid>
+                <StackLayout HeightRequest="{TemplateBinding DefaultHeight}">
+                    <TizenUtilityControls:GesturesContainer PanUpdated="OnPanUpdated">
+                        <TizenUtilityControls:CustomImage Margin="0,12,0,10" HeightRequest="18"
+                                                          BlendingColor="{StaticResource TopInlineButtonNormalColor}"
+                                                          Source="call_inline_btn_open.png">
+                            <TizenUtilityControls:CustomImage.Triggers>
+                                <DataTrigger TargetType="TizenUtilityControls:CustomImage" Binding="{TemplateBinding IsOpen}" Value="True">
+                                    <Setter Property="Margin" Value="0,12,0,20" />
+                                    <Setter Property="Source" Value="call_inline_btn_close.png" />
+                                </DataTrigger>
+                            </TizenUtilityControls:CustomImage.Triggers>
+                        </TizenUtilityControls:CustomImage>
                     </TizenUtilityControls:GesturesContainer>
 
-                    <Label Grid.Row="1" HorizontalOptions="Center" VerticalOptions="Center"
-                           TextColor="{StaticResource TopInlineButtonNormalColor}" Text="{x:Static Localization:Localization.RejectCallWithMessage}">
+                    <Label Margin="0,0,0,12" HorizontalOptions="Center"
+                           TextColor="{StaticResource TopInlineButtonNormalColor}" FontSize="26"
+                           Text="{x:Static Localization:Localization.RejectCallWithMessage}">
                         <Label.Triggers>
                             <DataTrigger TargetType="Label" Binding="{TemplateBinding IsOpen}" Value="True">
                                 <Setter Property="IsVisible" Value="False" />
@@ -47,7 +36,7 @@
                         </Label.Triggers>
                     </Label>
 
-                    <Button Grid.Row="1" HorizontalOptions="Center" VerticalOptions="Center"
+                    <Button Margin="32,0,32,22" WidthRequest="655" HeightRequest="78" HorizontalOptions="Center"
                             Text="{x:Static Localization:Localization.ComposeMessageToSend}" IsVisible="False">
                         <Button.Triggers>
                             <DataTrigger TargetType="Button" Binding="{TemplateBinding IsOpen}" Value="True">
@@ -56,8 +45,8 @@
                         </Button.Triggers>
                     </Button>
 
-                    <ContentPresenter Grid.Row="3" />
-                </TizenUtilityControls:CustomGrid>
+                    <ContentPresenter />
+                </StackLayout>
             </ControlTemplate>
 
             <ControlTemplate x:Key="BottomOpenDirectionPanel">
index bb5fb49..ddb7cfa 100644 (file)
@@ -77,7 +77,7 @@ namespace CallApp.Tizen.Call.View.Controls
             "DefaultHeight",
             typeof(double),
             typeof(RejectCallPanel),
-            150.0);
+            104.0);
 
         public double DefaultHeight
         {
@@ -158,6 +158,8 @@ namespace CallApp.Tizen.Call.View.Controls
             {
                 case GestureStatus.Started:
                     _lastHeight = Height;
+
+                    /* // TODO: Need to fix a bug in this place https://106.125.46.213/youtrack/issue/TizenRefApp-9373
                     double contentHeight = Content.Height + Height;
 
                     if (MaxOpenedHeight.Equals(0.0) || MaxOpenedHeight > contentHeight)
@@ -168,6 +170,9 @@ namespace CallApp.Tizen.Call.View.Controls
                     {
                         _maxOpenedHeight = MaxOpenedHeight;
                     }
+                    */
+
+                    _maxOpenedHeight = MaxOpenedHeight;
 
                     break;
 
index 1bd28b9..51b382d 100644 (file)
@@ -1,6 +1,53 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ContentView xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
-             x:Class="CallApp.Tizen.Call.View.IncomingCallView">
+             x:Class="CallApp.Tizen.Call.View.IncomingCallView"
+             x:Name="This"
+             xmlns:CallControls="clr-namespace:CallApp.Tizen.Call.View.Controls"
+             xmlns:Localization="clr-namespace:CallApp.Tizen.Localization"
+             xmlns:TizenUtilityControls="clr-namespace:Tizen.Utility.Controls">
 
+    <ContentView.Resources>
+        <ResourceDictionary>
+            <Color x:Key="ContactInfoPanelDimColor">#7D000000</Color>
+            <Color x:Key="RejectMessageListItemPressColor">#4C000000</Color>
+        </ResourceDictionary>
+    </ContentView.Resources>
+
+    <TizenUtilityControls:CustomGrid>
+        <StackLayout>
+            <TizenUtilityControls:CustomGrid>
+                <CallControls:ContactInfoPanel LayoutType="Single" StatusText="{x:Static Localization:Localization.IncomingCall}"
+                                               Image="{Binding IncomingCall.ContactModel.Image}"
+                                               PrimaryText="{Binding IncomingCall.ContactModel.Name}" SecondaryText="{Binding IncomingCall.CallerNumber}" />
+
+                <ContentView>
+                    <ContentView.Triggers>
+                        <DataTrigger TargetType="ContentView" Binding="{Binding Source={x:Reference This}, Path=IsDimmed}" Value="True">
+                            <Setter Property="BackgroundColor" Value="{StaticResource ContactInfoPanelDimColor}" />
+                        </DataTrigger>
+                    </ContentView.Triggers>
+                </ContentView>
+            </TizenUtilityControls:CustomGrid>
+
+            <StackLayout HeightRequest="424" Orientation="Horizontal" BackgroundColor="{StaticResource BGColor}">
+                <CallControls:AnimatedCircleButton x:Name="xAcceptCallButton" HorizontalOptions="Start" MaxScaleFactor="3" Radius="100"
+                                                   AnimationColor="{StaticResource CircleButtonAcceptBGColor}"
+                                                   NormalColor="{StaticResource CircleButtonAcceptNormalColor}"
+                                                   PressColor="{StaticResource CircleButtonAcceptPressColor}"
+                                                   Image="call_btn_ic_accept.png" />
+
+                <CallControls:AnimatedCircleButton x:Name="xRejectCallButton" HorizontalOptions="EndAndExpand" MaxScaleFactor="3" Radius="100"
+                                                   AnimationColor="{StaticResource CircleButtonRejectBGColor}"
+                                                   NormalColor="{StaticResource CircleButtonRejectNormalColor}"
+                                                   PressColor="{StaticResource CircleButtonRejectPressColor}"
+                                                   Image="call_btn_ic_reject.png" />
+            </StackLayout>
+        </StackLayout>
+
+        <CallControls:RejectCallPanel x:Name="xRejectCallPanel" VerticalOptions="End" HeightRequest="104" MaxOpenedHeight="640"
+                                      OpenDirection="ToTop" BackgroundColor="{StaticResource BGColor}">
+            <CallControls:RejectMessageList Items="{Binding RejectMessages}" PressColor="{StaticResource RejectMessageListItemPressColor}" />
+        </CallControls:RejectCallPanel>
+    </TizenUtilityControls:CustomGrid>
 </ContentView>
\ No newline at end of file
index d2862be..1aa354d 100644 (file)
@@ -26,6 +26,56 @@ namespace CallApp.Tizen.Call.View
         public IncomingCallView()
         {
             InitializeComponent();
+
+            xAcceptCallButton.OnAnimationCompleted += OnAcceptCallButtonAnimationCompleted;
+            xRejectCallButton.OnAnimationCompleted += OnRejectCallButtonAnimationCompleted;
+
+            xRejectCallPanel.OnSlideEvent += OnRejectCallPanelSlideEvent;
+        }
+
+        /// <summary>
+        /// Is contact info panel dim or not
+        /// </summary>
+        public static readonly BindableProperty IsDimmedProperty = BindableProperty.Create(
+            "IsDimmed",
+            typeof(bool),
+            typeof(IncomingCallView),
+            false);
+
+        public bool IsDimmed
+        {
+            get
+            {
+                return (bool)GetValue(IsDimmedProperty);
+            }
+            set
+            {
+                SetValue(IsDimmedProperty, value);
+            }
+        }
+
+        private void OnAcceptCallButtonAnimationCompleted(object sender)
+        {
+        }
+
+        private void OnRejectCallButtonAnimationCompleted(object sender)
+        {
+        }
+
+        private void OnRejectCallPanelSlideEvent(object sender, PanUpdatedEventArgs e)
+        {
+            switch (e.StatusType)
+            {
+                case GestureStatus.Started:
+                case GestureStatus.Running:
+                    IsDimmed = true;
+                    break;
+
+                case GestureStatus.Canceled:
+                case GestureStatus.Completed:
+                    IsDimmed = false;
+                    break;
+            }
         }
     }
 }
index 6304167..965896c 100644 (file)
  * limitations under the License.
  */
 
+using CallApp.Tizen.Call.Helper;
 using CallApp.Tizen.Call.Manager;
+using CallApp.Tizen.Call.Model;
+using System.Collections.ObjectModel;
+using System.Windows.Input;
 using Tizen.Utility.Helpers;
+using Xamarin.Forms;
 
 namespace CallApp.Tizen.Call.ViewModel
 {
@@ -30,26 +35,77 @@ namespace CallApp.Tizen.Call.ViewModel
         public IncomingCallViewModel(CallManager callManager)
         {
             _callManager = callManager;
+
+            AcceptCallCommand = new Command(OnAcceptCall);
+            RejectCallCommand = new Command(OnRejectCall);
+            RejectCallWithMessageCommand = new Command(OnRejectCallWithMessage);
+        }
+
+        /// <summary>
+        /// Command for accept call
+        /// </summary>
+        public ICommand AcceptCallCommand
+        {
+            get;
+            private set;
         }
 
         /// <summary>
-        /// Accept a call
+        /// Command for reject call
         /// </summary>
-        public void AcceptCall()
+        public ICommand RejectCallCommand
         {
+            get;
+            private set;
         }
 
         /// <summary>
-        /// Reject a call
+        /// Command for reject call with message
         /// </summary>
-        public void RejectCall()
+        public ICommand RejectCallWithMessageCommand
         {
+            get;
+            private set;
         }
 
         /// <summary>
-        /// Reject a call with message
+        /// Call in incoming status
         /// </summary>
-        public void RejectCallWithMessage(string text)
+        private CallModel _incomingCall = null;
+        public CallModel IncomingCall
+        {
+            get
+            {
+                return _incomingCall;
+            }
+            set
+            {
+                _incomingCall = value;
+
+                OnPropertyChanged();
+            }
+        }
+
+        /// <summary>
+        /// List of reject messages
+        /// </summary>
+        public ObservableCollection<RejectMessage> RejectMessages
+        {
+            get
+            {
+                return _messagesManager.GetMessageList();
+            }
+        }
+
+        private void OnAcceptCall(object obj)
+        {
+        }
+
+        private void OnRejectCall(object obj)
+        {
+        }
+
+        private void OnRejectCallWithMessage(object obj)
         {
         }
     }
index e3858d4..e16395b 100644 (file)
@@ -56,6 +56,7 @@
     </Compile>
     <Compile Include="CallApp.Tizen.cs" />
     <Compile Include="Call\Helper\TestModelCreator.cs" />
+    <Compile Include="Call\Helper\RejectMessage.cs" />
     <Compile Include="Call\Helper\TimeDuration.cs" />
     <Compile Include="Call\Manager\CallManager.cs" />
     <Compile Include="Call\Manager\MessagesManager.cs" />
index bfe445b..7225fb8 100644 (file)
@@ -6,6 +6,7 @@
     <Color x:Key="BGColor">#FFF7F7F7</Color>
     <Color x:Key="DefaultTextColor">#FFFAFAFA</Color>
 
+    <Color x:Key="CircleButtonAcceptBGColor">#4D59B03A</Color>
     <Color x:Key="CircleButtonAcceptNormalColor">#FF59B03A</Color>
     <Color x:Key="CircleButtonAcceptPressColor">#FF268035</Color>