123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System;
- using InABox.Mobile;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- namespace PRS.Mobile
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class SelectionPage
- {
- private SelectionPageMode _mode;
- private Action<MobileGridColumns, MobileButtonStripItems> _configure;
- private Func<SelectionViewRefreshArgs,object> _refresh;
- private Action<object[]> _selected;
-
- public SelectionPage(
- String title,
- SelectionPageMode mode,
- Action<MobileGridColumns, MobileButtonStripItems> configure,
- Func<SelectionViewRefreshArgs,object> refresh,
- Action<object[]> selected)
- {
- _mode = mode;
- _configure = configure;
- _refresh = refresh;
- _selected = selected;
-
- InitializeComponent();
-
-
- Title = title;
- _selection.Mode = mode;
-
- if (_mode != SelectionPageMode.Immediate)
- {
- ToolbarItems.Clear();
- ToolbarItems.Add(new ToolbarItem("Select", null, DoSelectItems));
- }
- ProgressVisible = true;
-
- }
- protected override void OnAppearing()
- {
- _selection.Load();
- base.OnAppearing();
- }
- private void DoSelectItems()
- {
- _selected?.Invoke(_selection.SelectedItems);
- Navigation.PopAsync();
- }
- private void _selection_OnConfigure(object sender, SelectionViewConfigureArgs args)
- {
- _configure?.Invoke(args.Columns, args.Filters);
- }
- private object _selection_OnRefresh(object sender, SelectionViewRefreshArgs args)
- {
- ProgressVisible = true;
- var result = _refresh?.Invoke(args);
- ProgressVisible = false;
- return result;
- }
- private void _selection_OnSelectionChanged(object sender, SelectionViewSelectionChangedArgs args)
- {
- if (_mode == SelectionPageMode.Immediate)
- DoSelectItems();
- }
- }
- }
|