-
-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
010982b
commit 4f9f46c
Showing
18 changed files
with
443 additions
and
459 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using Xamarin.Forms; | ||
|
||
namespace Ooui.Forms.Cells | ||
{ | ||
public class CellElement : Div, INativeElementView | ||
{ | ||
Cell cell; | ||
|
||
public Cell Cell { | ||
get => cell; | ||
set { | ||
if (cell == value) | ||
return; | ||
|
||
if (cell != null) | ||
UnbindCell (); | ||
|
||
cell = value; | ||
|
||
if (cell != null) | ||
BindCell (); | ||
} | ||
} | ||
|
||
public virtual Xamarin.Forms.Element Element => Cell; | ||
|
||
public CellElement () | ||
{ | ||
Style.Width = "100%"; | ||
} | ||
|
||
protected virtual void UnbindCell () | ||
{ | ||
Device.BeginInvokeOnMainThread (Cell.SendDisappearing); | ||
} | ||
|
||
protected virtual void BindCell () | ||
{ | ||
Device.BeginInvokeOnMainThread (cell.SendAppearing); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using Ooui.Forms.Extensions; | ||
using Xamarin.Forms; | ||
|
||
namespace Ooui.Forms.Cells | ||
{ | ||
public class EntryCellElement : CellElement | ||
{ | ||
public Label TextLabel { get; } = new Label (); | ||
public TextInput TextInput { get; } = new TextInput (); | ||
|
||
public EntryCellElement () | ||
{ | ||
AppendChild (TextLabel); | ||
AppendChild (TextInput); | ||
|
||
TextInput.Change += TextInput_Change; | ||
} | ||
|
||
protected override void BindCell () | ||
{ | ||
Cell.PropertyChanged += Cell_PropertyChanged; | ||
|
||
if (Cell is EntryCell cell) { | ||
UpdateLabel (cell); | ||
UpdateText (cell); | ||
UpdatePlaceholder (cell); | ||
UpdateLabelColor (cell); | ||
} | ||
|
||
base.BindCell (); | ||
} | ||
|
||
protected override void UnbindCell () | ||
{ | ||
Cell.PropertyChanged -= Cell_PropertyChanged; | ||
base.UnbindCell (); | ||
} | ||
|
||
void Cell_PropertyChanged (object sender, PropertyChangedEventArgs e) | ||
{ | ||
var entryCell = (EntryCell)sender; | ||
|
||
if (e.PropertyName == EntryCell.LabelProperty.PropertyName) | ||
UpdateLabel (entryCell); | ||
else if (e.PropertyName == EntryCell.TextProperty.PropertyName) | ||
UpdateText (entryCell); | ||
else if (e.PropertyName == EntryCell.PlaceholderProperty.PropertyName) | ||
UpdatePlaceholder (entryCell); | ||
else if (e.PropertyName == EntryCell.LabelColorProperty.PropertyName) | ||
UpdateLabelColor (entryCell); | ||
} | ||
|
||
void UpdateLabel (EntryCell entryCell) | ||
{ | ||
TextLabel.Text = entryCell.Label ?? string.Empty; | ||
} | ||
|
||
void UpdateLabelColor (EntryCell entryCell) | ||
{ | ||
TextLabel.Style.Color = entryCell.LabelColor.ToOouiColor (OouiTheme.TextColor); | ||
} | ||
|
||
void UpdatePlaceholder (EntryCell entryCell) | ||
{ | ||
TextInput.Placeholder = entryCell.Placeholder ?? string.Empty; | ||
} | ||
|
||
void UpdateText (EntryCell entryCell) | ||
{ | ||
TextInput.Value = entryCell.Text ?? string.Empty; | ||
} | ||
|
||
void TextInput_Change (object sender, EventArgs e) | ||
{ | ||
if (Cell is EntryCell cell) | ||
cell.Text = TextInput.Text; | ||
} | ||
} | ||
} |
Oops, something went wrong.