Skip to content

Commit

Permalink
Merge pull request #110 from muak/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
muak authored May 31, 2020
2 parents 83f5ebe + 38339aa commit 032280a
Show file tree
Hide file tree
Showing 17 changed files with 162 additions and 57 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
## files generated by popular Visual Studio add-ons.

.vs/
mono_crash.*

# User-specific files
*.suo
Expand Down
2 changes: 0 additions & 2 deletions README-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,6 @@ ValueTextは使用できません。
iOSではタップ時にページ遷移し遷移先ページでピッカーが表示されます。
Androidではタップ時にダイアログでピッカーが表示されます。

> PickerCellは、iOSのShell上では動作しません。
### Properties

* PageTitle
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sample/Sample/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected override void OnInitialized()

NavigationService.NavigateAsync("MyNavigationPage/MainPage");
//MainPage = new AppShell();
}
}

protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
Expand Down
1 change: 1 addition & 0 deletions Sample/Sample/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
using Xamarin.Forms;

[assembly: ExportFont("APJapanesefont.ttf", Alias = "Anzu")]
[assembly: ExportFont("icomoon.ttf", Alias = "Moon")]
Binary file added Sample/Sample/Resources/icomoon.ttf
Binary file not shown.
Binary file added Sample/Sample/Resources/ionicons.ttf
Binary file not shown.
12 changes: 11 additions & 1 deletion Sample/Sample/Sample.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<AssemblyName>SettingsSample</AssemblyName>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AiForms.Layouts" Version="1.0.4" />
<PackageReference Include="Xamarin.Forms.Svg" Version="1.0.0-pre4" />
Expand All @@ -22,9 +28,13 @@
</ItemGroup>
<ItemGroup>
<None Remove="Resources\APJapanesefont.ttf" />
<None Remove="Resources\ionicons.ttf" />
<None Remove="Resources\icomoon.ttf" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\APJapanesefont.ttf" />
<EmbeddedResource Include="Resources\ionicons.ttf" />
<EmbeddedResource Include="Resources\icomoon.ttf" />
</ItemGroup>
<Import Project="..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.28.0.0.3\build\monoandroid90\Xamarin.Android.Support.Animated.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.28.0.0.3\build\monoandroid90\Xamarin.Android.Support.Animated.Vector.Drawable.targets')" />
</Project>
11 changes: 9 additions & 2 deletions Sample/Sample/Views/SettingsViewPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
</ContentPage.Resources>

<sv:SettingsView HasUnevenRows="true" HeaderHeight="36" HeaderPadding="14,0,0,6" HeaderTextVerticalAlign="End" FooterPadding="14,4,4,6"
ShowArrowIndicatorForAndroid="True" CellTitleFontFamily="Anzu"
ShowArrowIndicatorForAndroid="True"
>

<sv:Section FooterText="This is a footer. optionaly you can write here.">
Expand All @@ -72,7 +72,14 @@
</sv:Section>

<sv:Section Title="LabelCell">
<sv:LabelCell Title="Storage" ValueText="3,065MB" TitleFontFamily="" />
<sv:LabelCell Title="Storage" ValueText="3,065MB">
<sv:LabelCell.IconSource>
<FontImageSource Glyph="&#xe901;"
Color="Blue"
FontFamily="Moon"
Size="30" />
</sv:LabelCell.IconSource>
</sv:LabelCell>
</sv:Section>

<sv:Section Title="CheckableCell">
Expand Down
9 changes: 6 additions & 3 deletions Sample/Sample/Views/ShellTestPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<ai:SettingsView BackgroundColor="White" >
x:Class="Sample.Views.ShellTestPage"
NavigationPage.BackButtonTitle=""
Title="ShellTest"
>
<ai:SettingsView BackgroundColor="AliceBlue" SeparatorColor="Brown" >
<ai:Section Title="Section1" FooterText="Footer1" >

<ai:PickerCell ItemsSource="{Binding ItemsSource}" BackgroundColor="White" />
<ai:PickerCell PageTitle="Hoge" ItemsSource="{Binding ItemsSource}" BackgroundColor="Beige" DisplayMember="Name" SubDisplayMember="Age" UsePickToClose="True" SelectionMode="Single" AccentColor="Red" TitleColor="Chocolate" DescriptionColor="BlueViolet" ValueTextColor="MediumSeaGreen" />
</ai:Section>
</ai:SettingsView>
</ContentPage>
10 changes: 1 addition & 9 deletions Sample/Sample/Views/SurveyPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@
xmlns:sv="clr-namespace:AiForms.Renderers;assembly=SettingsView"
x:Class="Sample.Views.SurveyPage">


<sv:SettingsView HeaderPadding="14" HeaderFontSize="30" HeaderTextVerticalAlign="End">
<!--<sv:SettingsView.ItemTemplate>
<DataTemplate>
<sv:Section>
<sv:LabelCell Title="{Binding Name}" ValueText="{Binding Value}"/>
</sv:Section>
</DataTemplate>
</sv:SettingsView.ItemTemplate>-->
<sv:SettingsView HeaderPadding="10" HeaderFontSize="16" HeaderTextVerticalAlign="Center">
<sv:Section ItemsSource="{Binding ItemsSource}" Title="headerd fsdfjslkdfjlさkjdflさjflさkjfafsadfsadfjs;dlfjslakdfj;sadjf;lsadjfkasdfjeiofjaw" FooterText="footer">
<sv:Section.ItemTemplate>
<DataTemplate>
Expand Down
19 changes: 14 additions & 5 deletions SettingsView.Droid/SettingsViewRecyclerAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
{
Expand Down
12 changes: 11 additions & 1 deletion SettingsView.iOS/Cells/CellBaseView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Xamarin.Forms.Platform.iOS;
using Foundation;
using CoreGraphics;
using CoreFoundation;

namespace AiForms.Renderers.iOS
{
Expand Down Expand Up @@ -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 =>
{
Expand Down
61 changes: 52 additions & 9 deletions SettingsView.iOS/Cells/PickerCellRenderer.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -82,17 +82,60 @@ 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)
{
tableView.DeselectRow(indexPath, true);
}
}

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);
}
}

/// <summary>
/// Updates the cell.
/// </summary>
Expand Down
Loading

0 comments on commit 032280a

Please sign in to comment.