diff --git a/src/TravelMonkey.iOS/Effects/SafeAreaPaddingEffect.cs b/src/TravelMonkey.iOS/Effects/SafeAreaPaddingEffect.cs
index c668630..8b2bc60 100644
--- a/src/TravelMonkey.iOS/Effects/SafeAreaPaddingEffect.cs
+++ b/src/TravelMonkey.iOS/Effects/SafeAreaPaddingEffect.cs
@@ -1,4 +1,6 @@
-using TravelMonkey.iOS.Effects;
+using System.Linq;
+using TravelMonkey.Effects;
+using TravelMonkey.iOS.Effects;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
@@ -12,22 +14,36 @@ public class SafeAreaPaddingEffect_iOS : PlatformEffect
Thickness _padding;
protected override void OnAttached()
{
- if (Element is Layout element)
+ try
{
- if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
+ var effect = (SafeAreaPaddingEffect)Element.Effects.FirstOrDefault(e => e is SafeAreaPaddingEffect);
+ if (effect != null && Element is Layout element)
{
- _padding = element.Padding;
- var insets = UIApplication.SharedApplication.Windows[0].SafeAreaInsets;
-
- if (insets.Top > 0)
+ if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
{
- element.Padding = new Thickness(_padding.Left + insets.Left, _padding.Top + insets.Top, _padding.Right + insets.Right, _padding.Bottom + insets.Bottom);
- return;
+ _padding = element.Padding;
+ var insets = UIApplication.SharedApplication.Windows[0].SafeAreaInsets;
+
+ if (insets.Top > 0)
+ {
+ if (!effect.Revert)
+ element.Padding = new Thickness(_padding.Left + insets.Left, _padding.Top + insets.Top, _padding.Right + insets.Right, _padding.Bottom + insets.Bottom);
+ else
+ element.Padding = new Thickness(_padding.Left - insets.Left, _padding.Top - insets.Top, _padding.Right - insets.Right, _padding.Bottom - insets.Bottom);
+ return;
+ }
}
+ if (!effect.Revert)
+ element.Padding = new Thickness(_padding.Left, _padding.Top + 20, _padding.Right, _padding.Bottom + 20);
+ else
+ element.Padding = new Thickness(_padding.Left, _padding.Top - 20, _padding.Right, _padding.Bottom - 20);
}
-
- element.Padding = new Thickness(_padding.Left, _padding.Top + 20, _padding.Right, _padding.Bottom + 20);
}
+ catch (System.Exception ex)
+ {
+ System.Console.WriteLine("Cannot set property on attached control. Error: ", ex.Message);
+ }
+
}
protected override void OnDetached()
diff --git a/src/TravelMonkey/AppShell.xaml b/src/TravelMonkey/AppShell.xaml
new file mode 100644
index 0000000..18cb98c
--- /dev/null
+++ b/src/TravelMonkey/AppShell.xaml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/TravelMonkey/AppShell.xaml.cs b/src/TravelMonkey/AppShell.xaml.cs
new file mode 100644
index 0000000..d3a874d
--- /dev/null
+++ b/src/TravelMonkey/AppShell.xaml.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using Xamarin.Forms;
+
+namespace TravelMonkey
+{
+ public partial class AppShell : Shell
+ {
+ public AppShell()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/src/TravelMonkey/Effects/SafeAreaPaddingEffect.cs b/src/TravelMonkey/Effects/SafeAreaPaddingEffect.cs
index 4a37075..e2a5fd7 100644
--- a/src/TravelMonkey/Effects/SafeAreaPaddingEffect.cs
+++ b/src/TravelMonkey/Effects/SafeAreaPaddingEffect.cs
@@ -4,6 +4,8 @@ namespace TravelMonkey.Effects
{
public class SafeAreaPaddingEffect : RoutingEffect
{
+ public bool Revert { get; set; }
+
public SafeAreaPaddingEffect() : base("TravelMonkey.SafeAreaPaddingEffect")
{
}
diff --git a/src/TravelMonkey/Views/AddPicturePage.xaml b/src/TravelMonkey/Views/AddPicturePage.xaml
index 8a6f98a..971f965 100644
--- a/src/TravelMonkey/Views/AddPicturePage.xaml
+++ b/src/TravelMonkey/Views/AddPicturePage.xaml
@@ -1,5 +1,12 @@
-
+
diff --git a/src/TravelMonkey/Views/AddPicturePage.xaml.cs b/src/TravelMonkey/Views/AddPicturePage.xaml.cs
index 3ea8d36..0222d10 100644
--- a/src/TravelMonkey/Views/AddPicturePage.xaml.cs
+++ b/src/TravelMonkey/Views/AddPicturePage.xaml.cs
@@ -12,14 +12,15 @@ public AddPicturePage()
BindingContext = new AddPicturePageViewModel();
- MessagingCenter.Subscribe(this, Constants.PictureAddedMessage, async (vm) => await Navigation.PopModalAsync(true));
+ MessagingCenter.Subscribe(this, Constants.PictureAddedMessage, async (vm) => await Shell.Current.GoToAsync("//main"));
MessagingCenter.Subscribe(this, Constants.PictureFailedMessage, async (vm) => await DisplayAlert("Uh-oh!", "Can you hand me my glasses? Something went wrong while analyzing this image", "OK"));
}
- private void Button_Clicked(object sender, EventArgs e)
+ private async void Button_Clicked(object sender, EventArgs e)
{
- Navigation.PopModalAsync();
+ //await Shell.Current.Navigation.PopModalAsync();
+ await Shell.Current.GoToAsync("//main");
}
}
}
\ No newline at end of file
diff --git a/src/TravelMonkey/Views/MainPage.xaml b/src/TravelMonkey/Views/MainPage.xaml
index ee8eb69..41e98f1 100644
--- a/src/TravelMonkey/Views/MainPage.xaml
+++ b/src/TravelMonkey/Views/MainPage.xaml
@@ -1,6 +1,19 @@
-
+
+
+
+
@@ -22,7 +35,7 @@
-
+
diff --git a/src/TravelMonkey/Views/MainPage.xaml.cs b/src/TravelMonkey/Views/MainPage.xaml.cs
index 8b2b41f..594c8e3 100644
--- a/src/TravelMonkey/Views/MainPage.xaml.cs
+++ b/src/TravelMonkey/Views/MainPage.xaml.cs
@@ -33,7 +33,8 @@ protected override void OnDisappearing()
private async void AddNewPicture_Tapped(object sender, EventArgs e)
{
- await Navigation.PushModalAsync(new AddPicturePage());
+ //await Navigation.PushModalAsync(new AddPicturePage());
+ await Shell.Current.GoToAsync("//picture");
}
private async void Entry_Completed(object sender, EventArgs e)
@@ -43,8 +44,8 @@ private async void Entry_Completed(object sender, EventArgs e)
await DisplayAlert("No text entered", "You didn't enter any text!", "OK");
return;
}
-
- await Navigation.PushModalAsync(new TranslationResultPage(TranslateTextEntry.Text));
+ await Shell.Current.GoToAsync($"//translation?inputText={TranslateTextEntry.Text}");
+ //await Shell.Current.Navigation.PushModalAsync(new TranslationResultPage(TranslateTextEntry.Text));
TranslateTextEntry.Text = "";
}
}
diff --git a/src/TravelMonkey/Views/SplashScreen.xaml.cs b/src/TravelMonkey/Views/SplashScreen.xaml.cs
index dcb71c3..488df00 100644
--- a/src/TravelMonkey/Views/SplashScreen.xaml.cs
+++ b/src/TravelMonkey/Views/SplashScreen.xaml.cs
@@ -61,7 +61,8 @@ private void NavigateToMainPage()
{
MainThread.BeginInvokeOnMainThread(() =>
{
- Application.Current.MainPage = new MainPage();
+ Application.Current.MainPage = new AppShell();
+ Shell.Current.GoToAsync("//main");
});
}
}
diff --git a/src/TravelMonkey/Views/TranslationResultPage.xaml b/src/TravelMonkey/Views/TranslationResultPage.xaml
index 0fcf116..81128a8 100644
--- a/src/TravelMonkey/Views/TranslationResultPage.xaml
+++ b/src/TravelMonkey/Views/TranslationResultPage.xaml
@@ -1,5 +1,15 @@
-
+
diff --git a/src/TravelMonkey/Views/TranslationResultPage.xaml.cs b/src/TravelMonkey/Views/TranslationResultPage.xaml.cs
index bf8553c..b19d99e 100644
--- a/src/TravelMonkey/Views/TranslationResultPage.xaml.cs
+++ b/src/TravelMonkey/Views/TranslationResultPage.xaml.cs
@@ -4,11 +4,33 @@
namespace TravelMonkey.Views
{
+ [QueryProperty("InputText", "inputText")]
public partial class TranslationResultPage : ContentPage
{
private readonly TranslateResultPageViewModel _translateResultPageViewModel =
new TranslateResultPageViewModel();
+ public string InputText
+ {
+ set
+ {
+ _translateResultPageViewModel.InputText = value;
+ BindingContext = _translateResultPageViewModel;
+ }
+ }
+
+ public TranslationResultPage()
+ {
+ InitializeComponent();
+
+ MessagingCenter.Subscribe(this,
+ Constants.TranslationFailedMessage,
+ async (s) =>
+ {
+ await DisplayAlert("Whoops!", "We lost our dictionary, something went wrong while translating", "OK");
+ });
+ }
+
public TranslationResultPage(string inputText)
{
InitializeComponent();
@@ -20,14 +42,17 @@ public TranslationResultPage(string inputText)
await DisplayAlert("Whoops!", "We lost our dictionary, something went wrong while translating", "OK");
});
+
_translateResultPageViewModel.InputText = inputText;
BindingContext = _translateResultPageViewModel;
+
}
private async void Button_Clicked(object sender, EventArgs e)
{
- await Navigation.PopModalAsync();
+ //await Navigation.PopModalAsync();
+ await Shell.Current.GoToAsync("//main");
}
}
}
\ No newline at end of file