diff --git a/.gitignore b/.gitignore index 10f16da..b0eb4b4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ ## files generated by popular Visual Studio add-ons. .vs/ +mono_crash.* # User-specific files *.suo diff --git a/README-ja.md b/README-ja.md index 65d115b..b2e5467 100644 --- a/README-ja.md +++ b/README-ja.md @@ -657,8 +657,6 @@ ValueTextは使用できません。 iOSではタップ時にページ遷移し遷移先ページでピッカーが表示されます。 Androidではタップ時にダイアログでピッカーが表示されます。 -> PickerCellは、iOSのShell上では動作しません。 - ### Properties * PageTitle diff --git a/README.md b/README.md index 9836c78..eb8b837 100644 --- a/README.md +++ b/README.md @@ -649,8 +649,6 @@ This is a LabelCell calling a multiple select picker. When tapped on iOS, move next page and show picker there. When tapped on Android, show the picker on a dialog. -> Note that the PickerCell is not supported in Shell on iOS. - ### Properties * PageTitle diff --git a/Sample/Sample/App.xaml.cs b/Sample/Sample/App.xaml.cs index 704bfcf..1f99c23 100644 --- a/Sample/Sample/App.xaml.cs +++ b/Sample/Sample/App.xaml.cs @@ -22,7 +22,7 @@ protected override void OnInitialized() NavigationService.NavigateAsync("MyNavigationPage/MainPage"); //MainPage = new AppShell(); - } + } protected override void RegisterTypes(IContainerRegistry containerRegistry) { diff --git a/Sample/Sample/Properties/AssemblyInfo.cs b/Sample/Sample/Properties/AssemblyInfo.cs index 017d48a..f4ed131 100644 --- a/Sample/Sample/Properties/AssemblyInfo.cs +++ b/Sample/Sample/Properties/AssemblyInfo.cs @@ -3,3 +3,4 @@ using Xamarin.Forms; [assembly: ExportFont("APJapanesefont.ttf", Alias = "Anzu")] +[assembly: ExportFont("icomoon.ttf", Alias = "Moon")] \ No newline at end of file diff --git a/Sample/Sample/Resources/icomoon.ttf b/Sample/Sample/Resources/icomoon.ttf new file mode 100644 index 0000000..532def5 Binary files /dev/null and b/Sample/Sample/Resources/icomoon.ttf differ diff --git a/Sample/Sample/Resources/ionicons.ttf b/Sample/Sample/Resources/ionicons.ttf new file mode 100644 index 0000000..ffd7d6f Binary files /dev/null and b/Sample/Sample/Resources/ionicons.ttf differ diff --git a/Sample/Sample/Sample.csproj b/Sample/Sample/Sample.csproj index 302654d..cebe9f1 100644 --- a/Sample/Sample/Sample.csproj +++ b/Sample/Sample/Sample.csproj @@ -1,10 +1,16 @@ - netstandard2.0 + netstandard2.1 SettingsSample + + 8.0 + + + 8.0 + @@ -22,9 +28,13 @@ + + + + \ No newline at end of file diff --git a/Sample/Sample/Views/SettingsViewPage.xaml b/Sample/Sample/Views/SettingsViewPage.xaml index 7fd73f0..3378a78 100644 --- a/Sample/Sample/Views/SettingsViewPage.xaml +++ b/Sample/Sample/Views/SettingsViewPage.xaml @@ -61,7 +61,7 @@ @@ -72,7 +72,14 @@ - + + + + + diff --git a/Sample/Sample/Views/ShellTestPage.xaml b/Sample/Sample/Views/ShellTestPage.xaml index c6f6527..d4a9f48 100644 --- a/Sample/Sample/Views/ShellTestPage.xaml +++ b/Sample/Sample/Views/ShellTestPage.xaml @@ -3,11 +3,14 @@ xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:ai="clr-namespace:AiForms.Renderers;assembly=SettingsView" - x:Class="Sample.Views.ShellTestPage"> - + x:Class="Sample.Views.ShellTestPage" + NavigationPage.BackButtonTitle="" + Title="ShellTest" + > + - + diff --git a/Sample/Sample/Views/SurveyPage.xaml b/Sample/Sample/Views/SurveyPage.xaml index 0883506..40bd7f6 100644 --- a/Sample/Sample/Views/SurveyPage.xaml +++ b/Sample/Sample/Views/SurveyPage.xaml @@ -5,15 +5,7 @@ xmlns:sv="clr-namespace:AiForms.Renderers;assembly=SettingsView" x:Class="Sample.Views.SurveyPage"> - - - + diff --git a/SettingsView.Droid/SettingsViewRecyclerAdapter.cs b/SettingsView.Droid/SettingsViewRecyclerAdapter.cs index 3338b21..6f770a3 100644 --- a/SettingsView.Droid/SettingsViewRecyclerAdapter.cs +++ b/SettingsView.Droid/SettingsViewRecyclerAdapter.cs @@ -325,9 +325,16 @@ void BindHeaderView(HeaderViewHolder holder) { cellHeight = (int)_context.ToPixels(_settingsView.HeaderHeight); } + else + { + cellHeight = -1; // Height Auto + } - view.SetMinimumHeight(cellHeight); - view.LayoutParameters.Height = cellHeight; + if (cellHeight >= 0) + { + view.SetMinimumHeight(cellHeight); + view.LayoutParameters.Height = cellHeight; + } //textview setting holder.TextView.SetPadding( @@ -342,9 +349,11 @@ void BindHeaderView(HeaderViewHolder holder) holder.TextView.Typeface = FontUtility.CreateTypeface(_settingsView.HeaderFontFamily, _settingsView.HeaderFontAttributes); holder.TextView.SetTextSize(Android.Util.ComplexUnitType.Sp, (float)_settingsView.HeaderFontSize); holder.TextView.SetBackgroundColor(_settingsView.HeaderBackgroundColor.ToAndroid()); - holder.TextView.SetMaxLines(1); - holder.TextView.SetMinLines(1); - holder.TextView.Ellipsize = TextUtils.TruncateAt.End; + + // Single line was done away with. + //holder.TextView.SetMaxLines(1); + //holder.TextView.SetMinLines(1); + //holder.TextView.Ellipsize = TextUtils.TruncateAt.End; if (_settingsView.HeaderTextColor != Xamarin.Forms.Color.Default) { diff --git a/SettingsView.iOS/Cells/CellBaseView.cs b/SettingsView.iOS/Cells/CellBaseView.cs index 2647bb2..37925b1 100644 --- a/SettingsView.iOS/Cells/CellBaseView.cs +++ b/SettingsView.iOS/Cells/CellBaseView.cs @@ -7,6 +7,7 @@ using Xamarin.Forms.Platform.iOS; using Foundation; using CoreGraphics; +using CoreFoundation; namespace AiForms.Renderers.iOS { @@ -514,7 +515,16 @@ void LoadIconImage(IImageSourceHandler handler, ImageSource source) var scale = (float)UIScreen.MainScreen.Scale; Task.Run(async () => { - image = await handler.LoadImageAsync(source, token, scale: scale); + if(source is FontImageSource) + { + DispatchQueue.MainQueue.DispatchSync(async () => { + image = await handler.LoadImageAsync(source, token, scale: scale); + }); + } + else + { + image = await handler.LoadImageAsync(source, token, scale: scale); + } token.ThrowIfCancellationRequested(); }, token).ContinueWith(t => { diff --git a/SettingsView.iOS/Cells/PickerCellRenderer.cs b/SettingsView.iOS/Cells/PickerCellRenderer.cs index 4f2be4b..a97dd99 100644 --- a/SettingsView.iOS/Cells/PickerCellRenderer.cs +++ b/SettingsView.iOS/Cells/PickerCellRenderer.cs @@ -1,12 +1,12 @@ -using AiForms.Renderers; +using System.Collections.Specialized; +using System.Linq; +using AiForms.Renderers; using AiForms.Renderers.iOS; +using Foundation; +using ObjCRuntime; using UIKit; using Xamarin.Forms; -using System.Collections.Specialized; -using System; -using Foundation; -using System.Linq; -using System.ComponentModel; +using Xamarin.Forms.Platform.iOS; [assembly: ExportRenderer(typeof(PickerCell), typeof(PickerCellRenderer))] namespace AiForms.Renderers.iOS @@ -82,10 +82,34 @@ public override void RowSelected(UITableView tableView, NSIndexPath indexPath) return; } - var naviCtrl = GetUINavigationController(UIApplication.SharedApplication.KeyWindow.RootViewController); _pickerVC?.Dispose(); - _pickerVC = new PickerTableViewController(this, tableView); - BeginInvokeOnMainThread(() => naviCtrl.PushViewController(_pickerVC, true)); + + var naviCtrl = GetUINavigationController(UIApplication.SharedApplication.KeyWindow.RootViewController); + if(naviCtrl is ShellSectionRenderer shell) + { + // When use Shell, the NativeView is wrapped in a Forms.ContentPage. + _pickerVC = new PickerTableViewController(this, tableView, shell.ShellSection.Navigation); + // Fix height broken. For some reason, TableView ContentSize is broken. + _pickerVC.TableView.ContentInset = new UIEdgeInsets(44, 0, 44, 0); + var page = new ContentPage(); + page.Content = _pickerVC.TableView.ToView(); ; + page.Title = _PickerCell.PageTitle; + + // Fire manually because INavigation.PushAsync does not work ViewDidAppear and ViewWillAppear. + _pickerVC.ViewDidAppear(false); + _pickerVC.InitializeView(); + BeginInvokeOnMainThread(async () => { + await shell.ShellSection.Navigation.PushAsync(page, true); + _pickerVC.InitializeScroll(); + }); + } + else + { + // When use traditional navigation. + _pickerVC = new PickerTableViewController(this, tableView); + BeginInvokeOnMainThread(() => naviCtrl.PushViewController(_pickerVC, true)); + } + if (!_PickerCell.KeepSelectedUntilBack) { @@ -93,6 +117,25 @@ public override void RowSelected(UITableView tableView, NSIndexPath indexPath) } } + class NavDelegate : UINavigationControllerDelegate + { + readonly ShellSectionRenderer _self; + + public NavDelegate(ShellSectionRenderer renderer) + { + _self = renderer; + } + + public override void DidShowViewController(UINavigationController navigationController, [Transient] UIViewController viewController, bool animated) + { + } + + public override void WillShowViewController(UINavigationController navigationController, [Transient] UIViewController viewController, bool animated) + { + navigationController.SetNavigationBarHidden(false, true); + } + } + /// /// Updates the cell. /// diff --git a/SettingsView.iOS/Cells/PickerTableViewController.cs b/SettingsView.iOS/Cells/PickerTableViewController.cs index ea82ac1..eba31a3 100644 --- a/SettingsView.iOS/Cells/PickerTableViewController.cs +++ b/SettingsView.iOS/Cells/PickerTableViewController.cs @@ -4,6 +4,7 @@ using System.Linq; using Foundation; using UIKit; +using Xamarin.Forms; using Xamarin.Forms.Platform.iOS; namespace AiForms.Renderers.iOS @@ -24,25 +25,27 @@ internal class PickerTableViewController : UITableViewController nfloat _detailFontSize; UIColor _background; UITableView _tableView; + INavigation _shellNavigation; - internal PickerTableViewController(PickerCellView pickerCellView, UITableView tableView):base(UITableViewStyle.Grouped) + internal PickerTableViewController(PickerCellView pickerCellView, UITableView tableView,INavigation shellNavigation = null):base(UITableViewStyle.Grouped) { _pickerCell = pickerCellView.Cell as PickerCell; _pickerCellNative = pickerCellView; _parent = pickerCellView.CellParent; _source = _pickerCell.ItemsSource as IList; _tableView = tableView; + _shellNavigation = shellNavigation; if (_pickerCell.SelectedItems == null) { _pickerCell.SelectedItems = new List(); - } + } SetUpProperties(); } void SetUpProperties() - { + { if (_pickerCell.AccentColor != Xamarin.Forms.Color.Default) { _accentColor = _pickerCell.AccentColor.ToUIColor(); } @@ -203,7 +206,14 @@ void DoPickToClose() { if (_pickerCell.UsePickToClose && _selectedCache.Count == _pickerCell.MaxSelectedNumber) { - this.NavigationController.PopViewController(true); + if(_shellNavigation != null) + { + _shellNavigation.PopAsync(true); + } + else + { + this.NavigationController.PopViewController(true); + } } } @@ -215,35 +225,49 @@ public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); + InitializeView(); + InitializeScroll(); + } + + public void InitializeView() + { Title = _pickerCell.PageTitle; var parent = _pickerCell.Parent as SettingsView; - if (parent != null) { + if (parent != null) + { TableView.SeparatorColor = parent.SeparatorColor.ToUIColor(); TableView.BackgroundColor = parent.BackgroundColor.ToUIColor(); } + } + public void InitializeScroll() + { IList selectedList = _pickerCell.MergedSelectedList; - foreach (var item in selectedList) { + foreach (var item in selectedList) + { var idx = _source.IndexOf(item); - if (idx < 0) { + if (idx < 0) + { continue; } _selectedCache[idx] = _source[idx]; - if (_pickerCell.MaxSelectedNumber >= 1 && _selectedCache.Count >= _pickerCell.MaxSelectedNumber) { + if (_pickerCell.MaxSelectedNumber >= 1 && _selectedCache.Count >= _pickerCell.MaxSelectedNumber) + { break; } } - if (selectedList.Count > 0) { + if (selectedList.Count > 0) + { var idx = _source.IndexOf(selectedList[0]); - if(idx < 0){ + if (idx < 0) + { return; } - BeginInvokeOnMainThread(() => - { + BeginInvokeOnMainThread(() => { TableView.ScrollToRow(NSIndexPath.Create(new nint[] { 0, idx }), UITableViewScrollPosition.Middle, false); }); } @@ -274,11 +298,6 @@ public override void ViewWillDisappear(bool animated) _pickerCell.InvokeCommand(); } - public override void ViewDidDisappear(bool animated) - { - - } - /// /// Dispose the specified disposing. /// diff --git a/SettingsView/SettingsView.csproj b/SettingsView/SettingsView.csproj index 73679d7..2b22c22 100644 --- a/SettingsView/SettingsView.csproj +++ b/SettingsView/SettingsView.csproj @@ -1,7 +1,7 @@ - netstandard2.0 + netstandard2.1 @@ -15,6 +15,7 @@ + diff --git a/nuget/AzurePipelines.nuspec b/nuget/AzurePipelines.nuspec index d342261..af9b2c2 100644 --- a/nuget/AzurePipelines.nuspec +++ b/nuget/AzurePipelines.nuspec @@ -24,9 +24,14 @@ There are various cells such as (LabelCell,ButtonCell,CommandCell,SwitchCell,Che ## Changes * [Header/Footer] Section header/footer does not respect SafeAreaInsets #83 +* Support .NETStandard2.1 +* Minimum Xamarin.Forms version >= 4.6.0.800 + ## Bug fixes +* [PickerCell] PickerCell is now supported on Shell. #67 +* FontImageSource is not displayed. #95 * [TextPickerCell] The last item is selected by default #93 * [HintText] HintText does not respect SafeAreaInsets. #90 * [Header/Footer] Header / Footer is broken the layout #87 #88 #89 @@ -36,21 +41,29 @@ There are various cells such as (LabelCell,ButtonCell,CommandCell,SwitchCell,Che Xamarin.Forms TableView Cell Setting Configuration Option ListView UITableView RecyclerView ReOrder DragDrop en-US + + + - + - + - + - + + + + + +