Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XF Upgrade 4.4 #644

Merged
merged 11 commits into from
Feb 10, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type RootPageKind =
| SkiaCanvas
| MapSamples
| OxyPlotSamples
| SwipeSample
//| VideoSamples
//| CachedImageSamples

Expand Down Expand Up @@ -395,6 +396,7 @@ module App =
View.Button(text = "Skia Canvas", command = (fun () -> dispatch (SetRootPageKind SkiaCanvas)))
View.Button(text = "Map Samples", command = (fun () -> dispatch (SetRootPageKind MapSamples)))
View.Button(text = "OxyPlot Samples", command = (fun () -> dispatch (SetRootPageKind OxyPlotSamples)))
View.Button(text = "SwipeView Samples", command = (fun () -> dispatch (SetRootPageKind SwipeSample)))
//View.Button(text = "VideoManager Samples", command = (fun () -> dispatch (SetRootPageKind VideoSamples)))
//View.Button(text = "CachedImage Samples", command = (fun () -> dispatch (SetRootPageKind CachedImageSamples)))
])),
Expand Down Expand Up @@ -950,10 +952,12 @@ module App =
let carouselViewSample model dispatch =
match Device.RuntimePlatform with
| Device.iOS | Device.Android ->
let carouselRef = ViewRef<CustomCarouselView>()
View.ContentPage(
View.StackLayout
[
mainPageButton dispatch

View.CarouselView(items =
[
View.Label(text="Person1")
Expand All @@ -969,7 +973,8 @@ module App =
View.Label(text="Person12")
View.Label(text="Person13")
View.Label(text="Person14")
], margin= Thickness 10.)
], margin= Thickness 10., ref=carouselRef)
View.IndicatorView(itemsSourceBy=carouselRef)
]
)

Expand Down Expand Up @@ -1261,7 +1266,34 @@ module App =
View.Label(text="OxyPlot for XamarinForms 1.0.0 does not support your platform")
View.Label(text="For status see https://github.com/oxyplot/oxyplot-xamarin")
])


let swipeViewSample model dispatch =
View.ContentPage(
View.SwipeView(
leftItems = View.SwipeItems(
sItems = [
View.SwipeItem(text="Left 1", backgroundColor=Color.LightPink)
View.SwipeItem(text="Left 2", backgroundColor=Color.LightGreen)
]
),
rightItems = View.SwipeItems(
sItems = [
View.SwipeItem(text="Right 1", backgroundColor=Color.LightPink)
View.SwipeItem(text="Right 2", backgroundColor=Color.LightGreen)
]
),
content = View.Grid(
height=60.0,
width=300.0,
backgroundColor=Color.LightGray,

children = [
View.BoxView(Color.Blue)
]
)
)
)

// let videoSamples model dispatch =
// View.ScrollingContentPage("VideoManager Sample", [
// mainPageButton dispatch
Expand Down Expand Up @@ -1321,6 +1353,7 @@ module App =
//| VideoSamples -> videoSamples model dispatch
//| CachedImageSamples -> chachedImageSamples model dispatch
| OxyPlotSamples -> oxyPlotSamples model dispatch
| SwipeSample -> swipeViewSample model dispatch


type App () as app =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ type MainActivity() =

override this.OnCreate (bundle: Bundle) =
base.OnCreate (bundle)
global.Xamarin.Forms.Forms.SetFlags([|"Shell_Experimental"; "CollectionView_Experimental"; "Visual_Experimental"|])
global.Xamarin.Forms.Forms.SetFlags([|"Shell_Experimental"; "CollectionView_Experimental"; "Visual_Experimental";
"IndicatorView_Experimental"; "SwipeView_Experimental"|])

Xamarin.Forms.Forms.Init (this, bundle)
Xamarin.FormsMaps.Init(this, bundle)
Expand Down
3 changes: 2 additions & 1 deletion Fabulous.XamarinForms/samples/AllControls/iOS/AppDelegate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ type AppDelegate () =
let mutable _app: AllControls.App option = None

override this.FinishedLaunching (uiApp, options) =
Xamarin.Forms.Forms.SetFlags([|"Shell_Experimental"; "CollectionView_Experimental"; "Visual_Experimental"|]);
Xamarin.Forms.Forms.SetFlags([|"Shell_Experimental"; "CollectionView_Experimental"; "Visual_Experimental";
"IndicatorView_Experimental"; "SwipeView_Experimental"|]);
Forms.Init()
Xamarin.FormsMaps.Init()
OxyPlot.Xamarin.Forms.Platform.iOS.PlotViewRenderer.Init()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,21 @@ type CustomTimePicker() =
if propertyName = "Time" then
timeChanged.Trigger(this, this.Time)

type CustomIndicatorView() =
inherit IndicatorView(IndicatorTemplate = ViewElementDataTemplateSelector())

/// Itemslayout for CarouselView
type VerticalLinearItemsLayout() =
inherit LinearItemsLayout(ItemsLayoutOrientation.Vertical)

type HorizontalLinearItemsLayout() =
inherit LinearItemsLayout(ItemsLayoutOrientation.Horizontal)

type CarouselVerticalItemsLayout() =
inherit LinearItemsLayout(ItemsLayoutOrientation.Vertical,
SnapPointsType = SnapPointsType.MandatorySingle,
SnapPointsAlignment = SnapPointsAlignment.Center)

/////////////////
/// Pages
/////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,9 @@ module ViewConverters =
let makeCustomTimePickerTimeChangedEventHandler f =
System.EventHandler<System.TimeSpan>(fun sender args ->
f args
)

let makeSwipeItemsChangedEventHandler f =
System.Collections.Specialized.NotifyCollectionChangedEventHandler(fun sender args ->
f args
)
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@ module ViewHelpers =
let update (_prevOpt: ViewElement voption) (_source: ViewElement) (_target: obj) = ()
let res = ViewElement(externalObj.GetType(), create, update, attribs)
externalsTable.Add(externalObj, res)
res
res
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,18 @@ module ViewUpdaters =
let realTarget = (target :> Xamarin.Forms.IShellContentController).Page
if realTarget <> null then currValue.UpdateIncremental(prevValue, realTarget)
| ValueSome _, ValueNone -> target.ContentTemplate <- null

let updateShellNavBarHasShadow prevValueOpt currValueOpt target =
match prevValueOpt, currValueOpt with
| ValueSome prevValue, ValueSome currValue when prevValue = currValue -> ()
| ValueNone, ValueNone -> ()
| _, ValueSome currValue -> Shell.SetNavBarHasShadow(target, currValue)
| ValueSome _, ValueNone ->
let hasShadow =
match Device.RuntimePlatform with
| Device.Android -> true
| _ -> false
Shell.SetNavBarHasShadow(target, hasShadow)

let updatePageUseSafeArea (prevValueOpt: bool voption) (currValueOpt: bool voption) (target: Xamarin.Forms.Page) =
let setUseSafeArea newValue =
Expand Down Expand Up @@ -723,4 +735,20 @@ module ViewUpdaters =
| ValueSome prevValue, ValueSome currValue when prevValue = currValue -> ()
| ValueNone, ValueNone -> ()
| _, ValueSome currValue -> Element.SetMenu(target, currValue.Create() :?> Menu)
| ValueSome _, ValueNone -> Element.SetMenu(target, null)
| ValueSome _, ValueNone -> Element.SetMenu(target, null)

let updateIndicatorViewItemsSourceBy (prevValueOpt: ViewRef<CustomCarouselView> voption) (currValueOpt: ViewRef<CustomCarouselView> voption) (target: Xamarin.Forms.IndicatorView) =
match prevValueOpt, currValueOpt with
| ValueSome prevValue, ValueSome currValue when prevValue = currValue -> ()
| ValueNone, ValueNone -> ()
| _, ValueSome currValue ->
match currValue.TryValue with
| Some v -> IndicatorView.SetItemsSourceBy(target, v)
| None -> IndicatorView.SetItemsSourceBy(target, null)
| ValueSome _, ValueNone -> IndicatorView.SetItemsSourceBy(target, null)

let updateSwipeItems (prevCollOpt: ViewElement array voption) (collOpt: ViewElement array voption) (target: Xamarin.Forms.SwipeItems) =
let create (desc: ViewElement) =
desc.Create() :?> Xamarin.Forms.ISwipeItem

updateCollectionGeneric prevCollOpt collOpt target create (fun _ _ _ -> ()) (fun _ _ -> true) updateChild
Loading