Skip to content

Commit

Permalink
Merge pull request #85 from muak/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
muak authored Feb 22, 2020
2 parents 4467233 + eb7bee6 commit 47d7fa3
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 36 deletions.
2 changes: 2 additions & 0 deletions README-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,8 @@ Xamarin.Forms.EntryCellとは別物です。
> 有効にした場合、アイコンの設定は無効になります。
* Command
* CommandParameter
* LongCommand
* 長押し時に発火するコマンド
* KeepSelectedUntilBack
* タップして次のページに遷移した時、遷移先ページから戻ってくるまで選択状態をそのままにしておくかの設定
* trueの場合は選択状態をキープして、falseの場合は選択はすぐに解除されます。
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,8 @@ It is envisaged that makes use of subclass of CustomCell.
* Command
* Invoked action.
* CommandParameter
* LongCommand
* Long tap command action.
* KeepSelectedUntilBack
* When moving next page, whether keep the cell selected until being back to the page.

Expand Down
4 changes: 2 additions & 2 deletions Sample/Sample.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<key>CFBundleDisplayName</key>
<string>SettingsView</string>
<key>CFBundleIdentifier</key>
<string>jp.kamusoft.sample</string>
<string>jp.kamusoft.settingsview</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>MinimumOSVersion</key>
<string>7.0</string>
<string>10.1</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
Expand Down
3 changes: 2 additions & 1 deletion Sample/Sample.iOS/Sample.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<CodesignKey>Apple Development: Satoshi Nakamura (249YM2WC3W)</CodesignKey>
<DeviceSpecificBuild>true</DeviceSpecificBuild>
<MtouchDebug>true</MtouchDebug>
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
Expand All @@ -29,6 +29,7 @@
<MtouchArch>i386, x86_64</MtouchArch>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
<PlatformTarget>x86</PlatformTarget>
<CodesignProvision>WildcardDev</CodesignProvision>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<DebugType>pdbonly</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion Sample/Sample/Views/RowManipulation.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

</StackLayout>

<sv:SettingsView Grid.Column="1" Style="{StaticResource settingsView}" x:Name="settings">
<sv:SettingsView Grid.Column="1" HeaderHeight="36" Style="{StaticResource settingsView}" x:Name="settings">
<sv:Section Title="Header" FooterText="Footer" x:Name="section">
<sv:LabelCell IconSource="icon.png" Title="LabelCell" Description="HogeFuga" HintText="hint" ValueText="Value"/>
<sv:CommandCell IconSource="icon.png" Title="CommandCell" Description="HogeFuga" HintText="hint" ValueText="Value"/>
Expand Down
13 changes: 13 additions & 0 deletions Sample/Sample/Views/SettingsViewPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@
<sv:EntryCell Title="EntryCell" ValueText="{Binding InputText.Value}" Placeholder="Input text" Keyboard="Email" TextAlignment="End" HintText="{Binding InputError.Value}" />
</sv:Section>

<sv:Section>
<sv:Section.HeaderView>
<FlexLayout Direction="Row" JustifyContent="SpaceBetween" AlignItems="End" HeightRequest="50" Padding="10,0,10,6">
<Label Text="CustomHeaderView" TextColor="DeepSkyBlue" />
<ImageButton Source="icon.png" WidthRequest="20" HeightRequest="20" />
</FlexLayout>
</sv:Section.HeaderView>
<sv:Section.FooterView>
<Label Text="CustomFooterView. " TextColor="DeepSkyBlue" Padding="10,6,10,0" />
</sv:Section.FooterView>
<cell:SliderCell Value="0.5" HintText="CustomCell" />
</sv:Section>

<sv:Section Title="FormsCell">
<ViewCell>
<StackLayout Padding="14,8,8,8" BackgroundColor="White">
Expand Down
2 changes: 1 addition & 1 deletion SettingsView.iOS/CustomHeaderFooterView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public override void LayoutSubviews()
//This sets the content views frame.
base.LayoutSubviews();

var contentFrame = ContentView.Frame;
var contentFrame = ContentView.Bounds;
var view = FormsCell;

Layout.LayoutChildIntoBoundingRegion(view, contentFrame.ToRectangle());
Expand Down
4 changes: 2 additions & 2 deletions SettingsView.iOS/SettingsTableSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public override UIView GetViewForHeader(UITableView tableView, nint section)


var headerView = _tableView.DequeueReusableHeaderFooterView(SettingsViewRenderer.TextHeaderId) as TextHeaderView;
headerView.Initialzie(_settingsView.HeaderPadding.ToUIEdgeInsets(),_settingsView.HeaderTextVerticalAlign);
headerView.Initialzie(_settingsView.HeaderPadding.ToUIEdgeInsets(),_settingsView.HeaderTextVerticalAlign,_tableView);

headerView.Label.Text = _settingsView.Model.GetSectionTitle((int)section);
headerView.Label.TextColor = _settingsView.HeaderTextColor == Color.Default ?
Expand Down Expand Up @@ -224,7 +224,7 @@ public override UIView GetViewForFooter(UITableView tableView, nint section)
}

var footerView = _tableView.DequeueReusableHeaderFooterView(SettingsViewRenderer.TextFooterId) as TextFooterView;
footerView.Initialzie(_settingsView.FooterPadding.ToUIEdgeInsets());
footerView.Initialzie(_settingsView.FooterPadding.ToUIEdgeInsets(), _tableView);

footerView.Label.Text = text;
footerView.Label.TextColor = _settingsView.FooterTextColor == Color.Default ?
Expand Down
8 changes: 4 additions & 4 deletions SettingsView.iOS/SettingsView.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@
<Compile Include="FormsInternals.cs" />
<Compile Include="Cells\CustomCellContent.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SettingsView\SettingsView.csproj">
<Project>{8FFB1EF3-FAF3-478C-B9F1-4D02E599C3C6}</Project>
<Project>{1BE95507-DABA-43AD-954A-6CDFEB25B5E4}</Project>
<Name>SettingsView</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<Import Project="..\packages\Xamarin.Forms.4.4.0.991477\build\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.4.4.0.991477\build\Xamarin.Forms.targets')" />
<Import Project="..\packages\Xamarin.Android.Support.CustomTabs.28.0.0.3\build\monoandroid90\Xamarin.Android.Support.CustomTabs.targets" Condition="Exists('..\packages\Xamarin.Android.Support.CustomTabs.28.0.0.3\build\monoandroid90\Xamarin.Android.Support.CustomTabs.targets')" />
Expand Down
24 changes: 22 additions & 2 deletions SettingsView.iOS/TextFooterView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class TextFooterView : UITableViewHeaderFooterView
List<NSLayoutConstraint> _constraints = new List<NSLayoutConstraint>();
UIEdgeInsets _curPadding;
bool _isInitialized;
NSLayoutConstraint _leftConstraint;
UITableView _tableView;

public TextFooterView(IntPtr handle):base(handle)
{
Expand All @@ -24,7 +26,22 @@ public TextFooterView(IntPtr handle):base(handle)
this.BackgroundView = new UIView();
}

public void Initialzie(UIEdgeInsets padding)
public override void LayoutSubviews()
{
base.LayoutSubviews();

if (_leftConstraint != null)
{
_leftConstraint.Active = false;
_leftConstraint.Dispose();
_leftConstraint = null;
}

_leftConstraint = Label.LeftAnchor.ConstraintEqualTo(LeftAnchor, _curPadding.Left + _tableView.SafeAreaInsets.Left);
_leftConstraint.Active = true;
}

public void Initialzie(UIEdgeInsets padding, UITableView tableView)
{
if(_isInitialized && _curPadding == padding)
{
Expand All @@ -39,7 +56,6 @@ public void Initialzie(UIEdgeInsets padding)
_constraints.Clear();

_constraints.Add(Label.TopAnchor.ConstraintEqualTo(this.TopAnchor, padding.Top));
_constraints.Add(Label.LeftAnchor.ConstraintEqualTo(this.LeftAnchor, padding.Left));
_constraints.Add(Label.RightAnchor.ConstraintEqualTo(this.RightAnchor, -padding.Right));
_constraints.Add(Label.BottomAnchor.ConstraintEqualTo(this.BottomAnchor, -padding.Bottom));

Expand All @@ -49,6 +65,7 @@ public void Initialzie(UIEdgeInsets padding)
});

_curPadding = padding;
_tableView = tableView;
_isInitialized = true;
}

Expand All @@ -58,10 +75,13 @@ protected override void Dispose(bool disposing)
if (disposing)
{
_constraints.ForEach(c => c.Dispose());
_leftConstraint?.Dispose();
_leftConstraint = null;
Label?.Dispose();
Label = null;
BackgroundView?.Dispose();
BackgroundView = null;
_tableView = null;
}
}
}
Expand Down
30 changes: 26 additions & 4 deletions SettingsView.iOS/TextHeaderView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ public class TextHeaderView : UITableViewHeaderFooterView
{
public UILabel Label { get; set; }
List<NSLayoutConstraint> _constraints = new List<NSLayoutConstraint>();
NSLayoutConstraint _leftConstraint;
UIEdgeInsets _curPadding;
UITableView _tableView;
LayoutAlignment _curAlignment;
bool _isInitialized;

public TextHeaderView(IntPtr handle): base(handle)
{
{
Label = new UILabel();
Label.Lines = 1;
Label.LineBreakMode = UILineBreakMode.TailTruncation;
Expand All @@ -24,7 +26,23 @@ public TextHeaderView(IntPtr handle): base(handle)

this.BackgroundView = new UIView();
}
public void Initialzie(UIEdgeInsets padding, LayoutAlignment align)

public override void LayoutSubviews()
{
base.LayoutSubviews();

if(_leftConstraint != null)
{
_leftConstraint.Active = false;
_leftConstraint.Dispose();
_leftConstraint = null;
}

_leftConstraint = Label.LeftAnchor.ConstraintEqualTo(LeftAnchor, _curPadding.Left + _tableView.SafeAreaInsets.Left);
_leftConstraint.Active = true;
}

public void Initialzie(UIEdgeInsets padding, LayoutAlignment align, UITableView tableView)
{
if(_isInitialized && _curPadding == padding && align == _curAlignment)
{
Expand All @@ -37,8 +55,8 @@ public void Initialzie(UIEdgeInsets padding, LayoutAlignment align)
c.Dispose();
}
_constraints.Clear();

_constraints.Add(Label.LeftAnchor.ConstraintEqualTo(this.LeftAnchor, padding.Left));
//_constraints.Add(Label.LeftAnchor.ConstraintEqualTo(this.LeftAnchor, padding.Left + safeAreaInsets.Left));
_constraints.Add(Label.RightAnchor.ConstraintEqualTo(this.RightAnchor, -padding.Right));

if (align == LayoutAlignment.Start)
Expand All @@ -61,6 +79,7 @@ public void Initialzie(UIEdgeInsets padding, LayoutAlignment align)

_curPadding = padding;
_curAlignment = align;
_tableView = tableView;
_isInitialized = true;
}

Expand All @@ -70,10 +89,13 @@ protected override void Dispose(bool disposing)
if(disposing)
{
_constraints.ForEach(c => c.Dispose());
_leftConstraint?.Dispose();
_leftConstraint = null;
Label?.Dispose();
Label = null;
BackgroundView?.Dispose();
BackgroundView = null;
_tableView = null;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion SettingsView/Section.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ void OnItemsSourceCollectionChanged(object sender, NotifyCollectionChangedEventA

RemoveAt(e.OldStartingIndex + TemplateStartIndex);

var item = e.NewItems[e.NewStartingIndex];
var item = e.NewItems[0];
var view = CreateChildViewFor(ItemTemplate, item, this);

Insert(e.NewStartingIndex + TemplateStartIndex, view);
Expand Down
2 changes: 1 addition & 1 deletion SettingsView/SettingsView.DefineProperites.cs
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ void OnItemsSourceCollectionChanged(object sender, NotifyCollectionChangedEventA

Root.RemoveAt(e.OldStartingIndex + TemplateStartIndex);

var item = e.NewItems[e.NewStartingIndex];
var item = e.NewItems[0];
var view = CreateChildViewFor(this.ItemTemplate, item, this);

Root.Insert(e.NewStartingIndex + TemplateStartIndex, view);
Expand Down
19 changes: 2 additions & 17 deletions nuget/AzurePipelines.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,13 @@ There are various cells such as (LabelCell,ButtonCell,CommandCell,SwitchCell,Che
</description>
<summary></summary>
<releaseNotes>
## New Features

* [CustomCell] set XAML in SettingsView's cell
* [EntryCell] SetFocus method #63
* [EntryCell] CompletedCommand property
* [PickerCell] SelectionMode property
* [PickerCell] SelectedItem property
* [SettingsView] ShowArrowIndicatorForAndroid Property – show an arrow indicator at the right side of CommandCell and PickerCell.
* [SettingsView][Section] TemplateStartIndex property – the index that starts inserting the template.
* [Section] HeaderView and FooterView property – can set a Forms view to a section header / footer.


## Changes

* EntryCell's keyboard is now hidden when scrolling on iOS. #59
* EntryCell Completed event is now occurred when a cell is lost focus too.
* Improved cell maniputation performance.
* [Header/Footer] Section header/footer does not respect SafeAreaInsets #83

## Bug fixes

* [TextPickerCell] Show the soft keyboard when tapping the dialog. #68
* [EntryCell][Android] A binding sometimes lost.
* [SettingsView][Section] Crash when ItemsSource element is replaced.

</releaseNotes>
<tags>Xamarin.Forms TableView Cell Setting Configuration Option ListView UITableView RecyclerView ReOrder DragDrop</tags>
Expand Down

0 comments on commit 47d7fa3

Please sign in to comment.