Skip to content
This repository has been archived by the owner on Apr 2, 2022. It is now read-only.

Add more NavigationPage extension #14

Merged
merged 1 commit into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 46 additions & 43 deletions samples/Xamarin.Forms/CounterApp/CounterApp/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -58,52 +58,55 @@ module App =

let view model =
Application(
ContentPage("Counter",
VerticalStackLayout([
Label(string model.Count)
.automationId("CountLabel")
.centerTextHorizontal()
.style (
createStyleFor [ Label.TextColorProperty, box Color.Green
Label.FontSizeProperty, box 24. ]
)

Button("Increment", Increment)
.style(
createStyleFor [ Button.BackgroundColorProperty, box Color.Green
Button.TextColorProperty, box Color.White ]
NavigationPage([
ContentPage("Counter",
VerticalStackLayout([
Label(string model.Count)
.automationId("CountLabel")
.centerTextHorizontal()
.style (
createStyleFor [ Label.TextColorProperty, box Color.Green
Label.FontSizeProperty, box 24. ]
)
.automationId("IncrementButton")

Button("Decrement", Decrement)
.automationId("DecrementButton")
.alignStartVertical(expand = true)

HorizontalStackLayout([
Label("Timer")

Switch(model.TimerOn, TimerToggled)
.automationId("TimerSwitch")
Button("Increment", Increment)
.style(
createStyleFor [ Button.BackgroundColorProperty, box Color.Green
Button.TextColorProperty, box Color.White ]
)
.automationId("IncrementButton")

Button("Decrement", Decrement)
.automationId("DecrementButton")
.alignStartVertical(expand = true)

HorizontalStackLayout([
Label("Timer")

Switch(model.TimerOn, TimerToggled)
.automationId("TimerSwitch")
])
.paddingLayout(20.)
.centerHorizontal()

Slider(min = 0., max = 10., value = float model.Step, onValueChanged = StepChanged)
.automationId("StepSlider")
.centerHorizontal()

Label($"Step size: {model.Step}")
.automationId("StepSizeLabel")
.centerHorizontal()

Button("Reset", Reset)
.automationId("ResetButton")
.isEnabled(model <> initModel ())
.centerHorizontal()
])
.paddingLayout(20.)
.centerHorizontal()

Slider(min = 0., max = 10., value = float model.Step, onValueChanged = StepChanged)
.automationId("StepSlider")
.centerHorizontal()

Label($"Step size: {model.Step}")
.automationId("StepSizeLabel")
.centerHorizontal()

Button("Reset", Reset)
.automationId("ResetButton")
.isEnabled(model <> initModel ())
.centerHorizontal()
])
.paddingLayout(30.)
.centerVertical()
)
.paddingLayout(30.)
.centerVertical()
).hasNavigationBar(false)
])

)

let program = Program.statefulApplicationWithCmdMsg init update view mapCmdMsgToCmd
2 changes: 2 additions & 0 deletions src/Fabulous.XamarinForms/Xamarin.Forms.Core.Attributes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ module NavigationPage =
let Pages = Attributes.defineWidgetCollectionWithConverter "NavigationPage_Pages" ViewUpdaters.applyDiffNavigationPagePages ViewUpdaters.updateNavigationPagePages
let BarBackgroundColor = Attributes.defineBindable<Color> Xamarin.Forms.NavigationPage.BarBackgroundColorProperty
let BarTextColor = Attributes.defineBindable<Color> Xamarin.Forms.NavigationPage.BarTextColorProperty
let HasNavigationBar = Attributes.defineBindable<bool> Xamarin.Forms.NavigationPage.HasNavigationBarProperty
let HasBackButton = Attributes.defineBindable<bool> Xamarin.Forms.NavigationPage.HasBackButtonProperty
let Popped = Attributes.defineEvent<NavigationEventArgs> ViewNode.getViewNode "NavigationPage_Popped" (fun target -> (target :?> Xamarin.Forms.NavigationPage).Popped)

module Entry =
Expand Down
9 changes: 8 additions & 1 deletion