Skip to content

Commit

Permalink
Merge pull request #1 from muak/fixPre1
Browse files Browse the repository at this point in the history
Release 0.0.1-pre5
  • Loading branch information
muak authored Nov 13, 2017
2 parents 0a5ea3d + da86002 commit ba6864f
Show file tree
Hide file tree
Showing 21 changed files with 139 additions and 28 deletions.
17 changes: 12 additions & 5 deletions README-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ SettingsViewのプロパティ設定はApp.xamlに記述した方が良いかも
* HasUnevenRowがfalseの時は、全行の高さ
* それ以外は最小の行の高さ
* HasUnevenRows
* 行の高さを固定にするかどうか。デフォルトはfalse
* 行の高さを固定にするかどうか。デフォルトはfalse。true推奨。
* CellTitleColor
* CellTitleFontSize
* CellValueTextColor
Expand All @@ -190,11 +190,11 @@ SettingsViewのプロパティ設定はApp.xamlに記述した方が良いかも
* UseDescriptionAsValue (Androidのみ有効)
* Description項目をValue項目として使用するかどうか。
* (一般的なAndroidアプリにありがちな設定値を下に書くレイアウトにするかどうか)
* デフォルトはtrue(Androidっぽくする
* デフォルトはfalse(DescriptionとValueは個別に使う
* ShowSectionTopBottomBorder (Androidのみ有効)
* 行の境界線をセクションの上と下にも表示するかどうか
* (一般的なAndroidアプリでありがちな上と下は表示しないようにしないかどうか)
* デフォルトはfalse(Androidっぽくする
* デフォルトはtrue(表示する

## SettingsViewのメソッド

Expand Down Expand Up @@ -403,12 +403,15 @@ Androidではタップ時にダイアログでピッカーが表示されます
* nullを指定することはできません。
* DisplayMember
* Pickerに選択肢として表示させるメンバー名(プロパティ名)。省略時はToStringの値が使用されます。
* * SelectedItems
* SelectedItems
* 選択したItemを保存するためのIList。ItemsSourceと同じ型のものを指定。
* 選択済み要素をあらかじめ設定する場合は、ItemsSourceの要素と同一インスタンスの要素にする必要があります。
* 指定する場合は必ずnullではなくインスタンス設定済みのものを指定する。
* SelectedItemsOrderKey
* 選択済みItemを文字列として表示する時のソートのキーとなるメンバー(プロパティ)名
* 指定しない場合はNaturalSortとなります。
* SelectedCommand
* 選択が完了した時に発火するコマンド
* iOSの場合はピッカーページから戻る時、Androidの場合はダイアログのOKをタップした時に発火します。
* MaxSelectedNumber
* 選択可能な最大数。
* 0指定で無制限、1指定で単一選択モード(ラジオボタン的なやつ)、2以上は制限付きの複数選択となります。
Expand All @@ -417,6 +420,10 @@ Androidではタップ時にダイアログでピッカーが表示されます
* trueの場合は選択状態をキープして、falseの場合は選択はすぐに解除されます。
* AccentColor
* Pickerのチェックマークの色
* UseNaturalSort
* 並べ替え方法にNaturalSortを使うかどうか。デフォルト false。
* trueの場合、例えば通常 1,10,2,3,4 と並ぶところが 1,2,3,4,10 という並びになります。
* 日本語以外の言語で使用する場合、誤動作する可能性があります。


## EntryCell
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Whereby any SettingsView in App will become the same property setttings.
* If HasUnevenRows is false, this value apply to each row height;
* Otherwise this value is used as minimum row height.
* HasUnevenRows
* Whether row height is fixed. Default false.
* Whether row height is fixed. Default false.(recomend true)
* CellTitleColor
* CellTitleFontSize
* CellValueTextColor
Expand All @@ -191,10 +191,10 @@ Whereby any SettingsView in App will become the same property setttings.
* They are bulk cell options.
* UseDescriptionAsValue (for Android)
* Whether description field is used as value field. (like general android app)
* Default true
* Default false
* ShowSectionTopBottomBorder (for Android)
* Whether a separator is shown at section top and bottom. (like general android app)
* Default false
* Default true

## SettingsView Methods

Expand Down Expand Up @@ -403,15 +403,19 @@ When tapped on Android, show the picker on a dialog.
* This have to assing a instance and must not null.
* SelectedItemsOrderKey
* Class member(Property) name that becomes a order key when selected items is displayed as text.
* If this property is null, order type becomes naturalsort.
* SelectedCommand
* A command invoked When finished being selected items.
* MaxSelectedNumber
* Selectable items number.
* If zero, unlimited multi select mode. Else if One, single select mode. Otherwise limited multi select mode.
* KeepSelectedUntilBack
* When moving next page or showing a dialog, whether keep the cell selected until being back to the page.
* AccentColor
* Picker checkbox color.

* UseNaturalSort
* Whether use NaturalSort as sort method. default false.
* If true, for example, if the order is normally "1,10,2,3,4", is "1,2,3,4,10".
* This option may not correctly work if not used Japanese language.

## EntryCell

Expand Down
11 changes: 11 additions & 0 deletions Sample/Sample/ViewModels/PickerCellTestViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ public class PickerCellTestViewModel:ViewModelBase
public ReactiveProperty<int> MaxSelectedNumber { get; } = new ReactiveProperty<int>();
public ReactiveProperty<bool> KeepSelected { get; } = new ReactiveProperty<bool>();
public ReactiveProperty<string> SelectedItemsOrderKey { get; } = new ReactiveProperty<string>();
public ReactiveProperty<bool> UseNaturalSort { get; } = new ReactiveProperty<bool>();

public ObservableCollection<Person> ItemsSource { get; } = new ObservableCollection<Person>();
public ObservableCollection<int> ItemsSource2 { get; } = new ObservableCollection<int>();

public ObservableCollection<Person> SelectedItems { get; set; } = new ObservableCollection<Person>();
public ObservableCollection<int> SelectedItems2 { get; } = new ObservableCollection<int>();

public ReactiveCommand SelectedCommand { get; } = new ReactiveCommand();

static string[] PageTitles = { "", "Select value", "LongTitleTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextEnd" };
static string[] DisplayMembers = { "Name", "Age",""};
static int[] MaxSelectedNumbers = { 0, 1, 3 };
Expand Down Expand Up @@ -50,6 +53,11 @@ public PickerCellTestViewModel()
KeepSelected.Value = bools[0];
SelectedItemsOrderKey.Value = DisplayMembers[0];
ChangeSelectedItems();

SelectedCommand.Subscribe(obj=>{
var list = obj as ObservableCollection<Person>;
System.Diagnostics.Debug.WriteLine(list);
});
}

protected override void CellChanged(object obj)
Expand Down Expand Up @@ -81,6 +89,9 @@ protected override void CellChanged(object obj)
case nameof(SelectedItemsOrderKey):
NextVal(SelectedItemsOrderKey, DisplayMembers);
break;
case nameof(UseNaturalSort):
NextVal(UseNaturalSort, bools);
break;
}
}

Expand Down
4 changes: 3 additions & 1 deletion Sample/Sample/ViewModels/ViewModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ protected virtual void ParentChanged(object obj)
case nameof(SettingsView.RowHeight):
ChangeRowHeight(RowHeight);
break;

case "CacheClear":
SettingsView.ClearCache();
break;
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions Sample/Sample/Views/ParentController.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@
<Label Text="CellIconSize" ef:AddCommand.On="true" ef:AddCommand.Command="{Binding PropertyChangeCommand}" ef:AddCommand.EffectColor="#80FFFF00" />
<Label Text="CellIconRadius" ef:AddCommand.On="true" ef:AddCommand.Command="{Binding PropertyChangeCommand}" ef:AddCommand.EffectColor="#80FFFF00" />
<Label Text="CellHintFontSize" ef:AddCommand.On="true" ef:AddCommand.Command="{Binding PropertyChangeCommand}" ef:AddCommand.EffectColor="#80FFFF00" />
<Label Text="CacheClear" ef:AddCommand.On="true" ef:AddCommand.Command="{Binding PropertyChangeCommand}" ef:AddCommand.EffectColor="#80FFFF00" />
</l:WrapLayout>
</ContentView>
5 changes: 3 additions & 2 deletions Sample/Sample/Views/PickerCellTest.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<Label Text="SelectedItemsOrderKey" ef:AddCommand.On="true" ef:AddCommand.Command="{Binding CellChangeCommand}" ef:AddCommand.EffectColor="#80FFFF00" />
<Label Text="MaxSelectedNumber" ef:AddCommand.On="true" ef:AddCommand.Command="{Binding CellChangeCommand}" ef:AddCommand.EffectColor="#80FFFF00" />
<Label Text="KeepSelected" ef:AddCommand.On="true" ef:AddCommand.Command="{Binding CellChangeCommand}" ef:AddCommand.EffectColor="#80FFFF00" />
<Label Text="UseNaturalSort" ef:AddCommand.On="true" ef:AddCommand.Command="{Binding CellChangeCommand}" ef:AddCommand.EffectColor="#80FFFF00" />
</l:WrapLayout>
</ScrollView>
<ScrollView VerticalOptions="Start" HeightRequest="100" BackgroundColor="#efefef">
Expand Down Expand Up @@ -66,8 +67,8 @@
ShowSectionTopBottomBorder="{Binding ShowSectionTopBottomBorder.Value}"
>
<ai:Section Title="Section1" FooterText="Footer1" >
<ai:PickerCell IconSource="{Binding IconSource.Value}" Title="{Binding Title.Value}" Description="{Binding Description.Value}" HintText="{Binding HintText.Value}" BackgroundColor="{Binding BgColor.Value}" TitleColor="{Binding TitleColor.Value}" TitleFontSize="{Binding TitleFontSize.Value}" ValueTextColor="{Binding ValueTextColor.Value}" ValueTextFontSize="{Binding ValueTextFontSize.Value}" DescriptionColor="{Binding DescriptionColor.Value}" DescriptionFontSize="{Binding DescriptionFontSize.Value}" HintTextColor="{Binding HintTextColor.Value}" HintFontSize="{Binding HintFontSize.Value}" IconSize="{Binding IconSize.Value}" IconRadius="{Binding IconRadius.Value}" Tapped="Handle_Tapped" AccentColor="{Binding OwnAccentColor.Value}" PageTitle="{Binding PageTitle.Value}" ItemsSource="{Binding ItemsSource}" DisplayMember="{Binding DisplayMember.Value}" SelectedItems="{Binding SelectedItems}" MaxSelectedNumber="{Binding MaxSelectedNumber.Value}" KeepSelectedUntilBack="{Binding KeepSelected.Value}" SelectedItemsOrderKey="{Binding SelectedItemsOrderKey.Value}" />
<ai:PickerCell IconSource="{Binding IconSource.Value}" Title="{Binding Title.Value}" Description="{Binding Description.Value}" HintText="{Binding HintText.Value}" BackgroundColor="{Binding BgColor.Value}" TitleColor="{Binding TitleColor.Value}" TitleFontSize="{Binding TitleFontSize.Value}" ValueTextColor="{Binding ValueTextColor.Value}" ValueTextFontSize="{Binding ValueTextFontSize.Value}" DescriptionColor="{Binding DescriptionColor.Value}" DescriptionFontSize="{Binding DescriptionFontSize.Value}" HintTextColor="{Binding HintTextColor.Value}" HintFontSize="{Binding HintFontSize.Value}" IconSize="{Binding IconSize.Value}" IconRadius="{Binding IconRadius.Value}" Tapped="Handle_Tapped" AccentColor="{Binding OwnAccentColor.Value}" PageTitle="{Binding PageTitle.Value}" ItemsSource="{Binding ItemsSource2}" DisplayMember="{Binding DisplayMember2.Value}" SelectedItems="{Binding SelectedItems2}" MaxSelectedNumber="{Binding MaxSelectedNumber.Value}" KeepSelectedUntilBack="{Binding KeepSelected.Value}" SelectedItemsOrderKey="{Binding SelectedItemsOrderKey.Value}" />
<ai:PickerCell IconSource="{Binding IconSource.Value}" Title="{Binding Title.Value}" Description="{Binding Description.Value}" HintText="{Binding HintText.Value}" BackgroundColor="{Binding BgColor.Value}" TitleColor="{Binding TitleColor.Value}" TitleFontSize="{Binding TitleFontSize.Value}" ValueTextColor="{Binding ValueTextColor.Value}" ValueTextFontSize="{Binding ValueTextFontSize.Value}" DescriptionColor="{Binding DescriptionColor.Value}" DescriptionFontSize="{Binding DescriptionFontSize.Value}" HintTextColor="{Binding HintTextColor.Value}" HintFontSize="{Binding HintFontSize.Value}" IconSize="{Binding IconSize.Value}" IconRadius="{Binding IconRadius.Value}" Tapped="Handle_Tapped" AccentColor="{Binding OwnAccentColor.Value}" PageTitle="{Binding PageTitle.Value}" ItemsSource="{Binding ItemsSource}" DisplayMember="{Binding DisplayMember.Value}" SelectedItems="{Binding SelectedItems}" MaxSelectedNumber="{Binding MaxSelectedNumber.Value}" KeepSelectedUntilBack="{Binding KeepSelected.Value}" SelectedItemsOrderKey="{Binding SelectedItemsOrderKey.Value}" SelectedCommand="{Binding SelectedCommand}" UseNaturalSort="{Binding UseNaturalSort.Value}" />
<ai:PickerCell IconSource="{Binding IconSource.Value}" Title="{Binding Title.Value}" Description="{Binding Description.Value}" HintText="{Binding HintText.Value}" BackgroundColor="{Binding BgColor.Value}" TitleColor="{Binding TitleColor.Value}" TitleFontSize="{Binding TitleFontSize.Value}" ValueTextColor="{Binding ValueTextColor.Value}" ValueTextFontSize="{Binding ValueTextFontSize.Value}" DescriptionColor="{Binding DescriptionColor.Value}" DescriptionFontSize="{Binding DescriptionFontSize.Value}" HintTextColor="{Binding HintTextColor.Value}" HintFontSize="{Binding HintFontSize.Value}" IconSize="{Binding IconSize.Value}" IconRadius="{Binding IconRadius.Value}" Tapped="Handle_Tapped" AccentColor="{Binding OwnAccentColor.Value}" PageTitle="{Binding PageTitle.Value}" ItemsSource="{Binding ItemsSource2}" DisplayMember="{Binding DisplayMember2.Value}" SelectedItems="{Binding SelectedItems2}" MaxSelectedNumber="{Binding MaxSelectedNumber.Value}" KeepSelectedUntilBack="{Binding KeepSelected.Value}" SelectedItemsOrderKey="{Binding SelectedItemsOrderKey.Value}" UseNaturalSort="{Binding UseNaturalSort.Value}"/>

</ai:Section>
</ai:SettingsView>
Expand Down
2 changes: 2 additions & 0 deletions SettingsView.Droid/Cells/PickerCellRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public override void CellPropertyChanged(object sender, System.ComponentModel.Pr
base.CellPropertyChanged(sender, e);
if (e.PropertyName == PickerCell.SelectedItemsProperty.PropertyName ||
e.PropertyName == PickerCell.DisplayMemberProperty.PropertyName ||
e.PropertyName == PickerCell.UseNaturalSortProperty.PropertyName ||
e.PropertyName == PickerCell.SelectedItemsOrderKeyProperty.PropertyName) {
UpdateSelectedItems(true);
}
Expand Down Expand Up @@ -121,6 +122,7 @@ void CreateDialog()
{
_adapter.DoneSelect();
UpdateSelectedItems(true);
_PickerCell.InvokeCommand();
ClearFocus();
});

Expand Down
2 changes: 1 addition & 1 deletion SettingsView.Droid/Resources/layout/CellBaseView.axml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_height="match_parent"
android:minHeight="44dp"
android:paddingLeft="10dp"
android:paddingRight="8dp"
android:paddingRight="10dp"
android:paddingTop="4dp"
android:paddingBottom="4dp">
<ImageView
Expand Down
1 change: 1 addition & 0 deletions SettingsView.Droid/SettingsView.Droid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
<ReleaseVersion>1.05</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
2 changes: 1 addition & 1 deletion SettingsView.iOS/Cells/CellBaseView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ void SetUpContentView()
Distribution = UIStackViewDistribution.Fill
};
//set margin
_stackH.LayoutMargins = new UIEdgeInsets(6, 16, 6, 10);
_stackH.LayoutMargins = new UIEdgeInsets(6, 16, 6, 16);
_stackH.LayoutMarginsRelativeArrangement = true;

IconView = new UIImageView();
Expand Down
1 change: 1 addition & 0 deletions SettingsView.iOS/Cells/PickerCellRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public override void CellPropertyChanged(object sender, System.ComponentModel.Pr
base.CellPropertyChanged(sender, e);
if (e.PropertyName == PickerCell.SelectedItemsProperty.PropertyName ||
e.PropertyName == PickerCell.DisplayMemberProperty.PropertyName ||
e.PropertyName == PickerCell.UseNaturalSortProperty.PropertyName ||
e.PropertyName == PickerCell.SelectedItemsOrderKeyProperty.PropertyName) {
UpdateSelectedItems(true);
}
Expand Down
5 changes: 4 additions & 1 deletion SettingsView.iOS/Cells/PickerTableViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal class PickerTableViewController : UITableViewController
UIColor _background;
UITableView _tableView;

internal PickerTableViewController(PickerCellView pickerCellView, UITableView tableView)
internal PickerTableViewController(PickerCellView pickerCellView, UITableView tableView):base(UITableViewStyle.Grouped)
{
_pickerCell = pickerCellView.Cell as PickerCell;
_pickerCellNative = pickerCellView;
Expand All @@ -37,6 +37,7 @@ internal PickerTableViewController(PickerCellView pickerCellView, UITableView ta
SetUpProperties();
}


void SetUpProperties()
{
if (_pickerCell.AccentColor != Xamarin.Forms.Color.Default) {
Expand Down Expand Up @@ -224,6 +225,8 @@ public override void ViewWillDisappear(bool animated)
if (_pickerCell.KeepSelectedUntilBack) {
_tableView.DeselectRow(_tableView.IndexPathForSelectedRow, true);
}

_pickerCell.InvokeCommand();
}

/// <summary>
Expand Down
7 changes: 6 additions & 1 deletion SettingsView.iOS/SettingsTableSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,12 @@ UINavigationController GetUINavigationController(UIViewController controller)
{
return (controller as UINavigationController);
}

if (controller is UITabBarController)
{
//in case Root->Tab->Navi->Page
var tabCtrl = controller as UITabBarController;
return GetUINavigationController(tabCtrl.SelectedViewController);
}
if (controller.ChildViewControllers.Count() != 0)
{
var count = controller.ChildViewControllers.Count();
Expand Down
1 change: 1 addition & 0 deletions SettingsView.iOS/SettingsView.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<RootNamespace>AiForms.Renderers.iOS</RootNamespace>
<AssemblyName>SettingsView.iOS</AssemblyName>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
<ReleaseVersion>1.05</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
2 changes: 1 addition & 1 deletion SettingsView.iOS/SettingsViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected override void OnElementChanged(ElementChangedEventArgs<SettingsView> e
break;
}
}

_parentPage = elm as Page;
_parentPage.Appearing += ParentPageAppearing;

Expand Down
2 changes: 1 addition & 1 deletion SettingsView/Cells/ButtonCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ButtonCell:CellBase
nameof(TitleAlignment),
typeof(TextAlignment),
typeof(ButtonCell),
default(TextAlignment),
TextAlignment.Center,
defaultBindingMode: BindingMode.OneWay
);

Expand Down
Loading

0 comments on commit ba6864f

Please sign in to comment.