Added new button sample.
This commit is contained in:
Родитель
1cbbc769cf
Коммит
75c999f5ad
|
@ -42,18 +42,15 @@ namespace HotUI.Samples
|
|||
{
|
||||
(state.CanEdit
|
||||
? (View) new TextField(() => state.Text, onCommit: value => state.Text = value)
|
||||
: new Text(() => $"{state.Text}: multiText")), // Fromated Text will warn you. This should be done by TextBinding
|
||||
: new Text(() => $"{state.Text}: multiText")), // Text will warn you. This should be done by TextBinding
|
||||
new Text(state.Text),
|
||||
new HStack
|
||||
{
|
||||
new Button("Toggle Entry/Label")
|
||||
{
|
||||
OnClick = () => state.CanEdit = !state.CanEdit
|
||||
}.Background(Color.Salmon),
|
||||
new Button("Update Text")
|
||||
{
|
||||
OnClick = () => { state.Text = $"Click Count: {clickCount.Value++}"; }
|
||||
}
|
||||
new Button("Toggle Entry/Label",
|
||||
() => state.CanEdit = !state.CanEdit)
|
||||
.Background(Color.Salmon),
|
||||
new Button("Update Text",
|
||||
() => state.Text = $"Click Count: {clickCount.Value++}" )
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -40,24 +40,18 @@ namespace HotUI.Samples {
|
|||
new Text(state.Text),
|
||||
new HStack
|
||||
{
|
||||
new Button("Toggle Entry/Label")
|
||||
{
|
||||
OnClick = () => state.CanEdit = !state.CanEdit
|
||||
},
|
||||
new Button("Update Text")
|
||||
{
|
||||
OnClick = () => { state.Text = $"Click Count: {clickCount.Value++}"; }
|
||||
},
|
||||
new Button("Update FontSize")
|
||||
{
|
||||
OnClick = () => {
|
||||
new Button("Toggle Entry/Label",
|
||||
() => state.CanEdit = !state.CanEdit),
|
||||
new Button("Update Text",
|
||||
() => state.Text = $"Click Count: {clickCount.Value++}"),
|
||||
new Button("Update FontSize",
|
||||
() => {
|
||||
|
||||
var font = View.GetGlobalEnvironment<Font>(EnvironmentKeys.Fonts.Font) ?? Font.System(14);
|
||||
var size = font.Attributes.Size + 5;
|
||||
var newFont = Font.System(size);
|
||||
var font = View.GetGlobalEnvironment<Font>(EnvironmentKeys.Fonts.Font) ?? Font.System(14);
|
||||
var size = font.Attributes.Size + 5;
|
||||
var newFont = Font.System(size);
|
||||
View.SetGlobalEnvironment (EnvironmentKeys.Fonts.Font, newFont);
|
||||
}
|
||||
},
|
||||
}),
|
||||
},
|
||||
new Toggle(() =>state.CanEdit)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HotUI.Samples
|
||||
{
|
||||
public class ButtonSample1 : View
|
||||
{
|
||||
readonly State<int> count = 0;
|
||||
|
||||
public ButtonSample1()
|
||||
{
|
||||
Body = () => new VStack
|
||||
{
|
||||
new Button("Increment Value", () => count.Value = count + 1),
|
||||
new Text($"Value: {count.Value}"),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,9 +7,9 @@ namespace HotUI.Samples {
|
|||
{
|
||||
Body = () => {
|
||||
var stack = new VStack {
|
||||
new Button (()=> myBoolean.Value ? myText.Value : $"State: {myBoolean.Value}") {
|
||||
OnClick = ()=> myBoolean.Value = !myBoolean.Value,
|
||||
},
|
||||
new Button
|
||||
(()=> myBoolean.Value ? myText.Value : $"State: {myBoolean.Value}",
|
||||
()=> myBoolean.Value = !myBoolean.Value),
|
||||
};
|
||||
for (var i = 0; i < 100; i++) {
|
||||
stack.Add (new Text (i.ToString ()));
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace HotUI.Samples {
|
|||
new MenuItem("ListPage1", ()=> new ListPage()),
|
||||
new MenuItem("ListPage2", ()=> new ListPage2()),
|
||||
new MenuItem("Insane Diff", ()=> new InsaneDiffPage()),
|
||||
new MenuItem("ButtonSample1", ()=> new ButtonSample1()),
|
||||
new MenuItem("SecureFieldSample1", ()=> new SecureFieldSample1()),
|
||||
new MenuItem("SecureFieldSample2", ()=> new SecureFieldSample2()),
|
||||
new MenuItem("SecureFieldSample3", ()=> new SecureFieldSample3()),
|
||||
|
|
|
@ -1,25 +1,33 @@
|
|||
using System;
|
||||
namespace HotUI {
|
||||
public class Button : View {
|
||||
|
||||
namespace HotUI
|
||||
{
|
||||
public class Button : View
|
||||
{
|
||||
public Button ()
|
||||
{
|
||||
|
||||
}
|
||||
public Button (string text) : base (true)
|
||||
|
||||
public Button (string text, Action action = null) : base (true)
|
||||
{
|
||||
Text = text;
|
||||
OnClick = action;
|
||||
}
|
||||
public Button (Func<string> formatedText)
|
||||
|
||||
public Button (Func<string> text, Action action = null)
|
||||
{
|
||||
TextBinding = formatedText;
|
||||
TextBinding = text;
|
||||
OnClick = action;
|
||||
}
|
||||
private string text;
|
||||
|
||||
private string _text;
|
||||
public string Text {
|
||||
get => text;
|
||||
private set => this.SetValue (State, ref text, value, ViewPropertyChanged);
|
||||
get => _text;
|
||||
private set => this.SetValue (State, ref _text, value, ViewPropertyChanged);
|
||||
}
|
||||
|
||||
public Action OnClick { get; set; }
|
||||
public Action OnClick { get; private set; }
|
||||
|
||||
public Func<string> TextBinding { get; private set; }
|
||||
|
||||
|
@ -37,6 +45,5 @@ namespace HotUI {
|
|||
Text = text;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
using System;
|
||||
namespace HotUI {
|
||||
public class NavigationButton : ContentView {
|
||||
namespace HotUI
|
||||
{
|
||||
public class NavigationButton : ContentView
|
||||
{
|
||||
public NavigationButton(Func<View> destination)
|
||||
{
|
||||
Destination = destination;
|
||||
}
|
||||
public NavigationButton (Func<string> text,Func<View> destination)
|
||||
{
|
||||
Content = new Button (text) {
|
||||
OnClick = Navigate,
|
||||
};
|
||||
Content = new Button (text, Navigate);
|
||||
|
||||
Destination = destination;
|
||||
}
|
||||
public NavigationButton (string text, Func<View> destination)
|
||||
{
|
||||
Content = new Button (text) {
|
||||
OnClick = Navigate,
|
||||
};
|
||||
Content = new Button (text,Navigate);
|
||||
Destination = destination;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче