Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var info = FamiStudioForm.Instance != null ? FamiStudioForm.Instance.ActiveDialog as PropertyDialogActivityInfo : null;

            if (savedInstanceState != null || info == null)
            {
                Finish();
                return;
            }

            dlg = info.Dialog;
            dlg.CloseRequested += Dlg_CloseRequested;

            var appBarLayoutParams = new AppBarLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, DroidUtils.GetSizeAttributeInPixel(this, Android.Resource.Attribute.ActionBarSize));

            appBarLayoutParams.ScrollFlags = 0;

            toolbar = new AndroidX.AppCompat.Widget.Toolbar(new ContextThemeWrapper(this, Resource.Style.ToolbarTheme));
            toolbar.LayoutParameters = appBarLayoutParams;
            toolbar.SetTitleTextAppearance(this, Resource.Style.LightGrayTextMediumBold);
            SetSupportActionBar(toolbar);

            ActionBar actionBar = SupportActionBar;

            if (actionBar != null)
            {
                actionBar.SetDisplayHomeAsUpEnabled(true);
                actionBar.SetHomeButtonEnabled(true);
                actionBar.SetHomeAsUpIndicator(Android.Resource.Drawable.IcMenuCloseClearCancel);
                actionBar.Title = dlg.Title;
            }

            appBarLayout = new AppBarLayout(this);
            appBarLayout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            appBarLayout.AddView(toolbar);

            fragmentView = new FragmentContainerView(this);
            fragmentView.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            fragmentView.Id = FragmentViewId;

            var scrollViewLayoutParams = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            scrollViewLayoutParams.Behavior = new AppBarLayout.ScrollingViewBehavior(this, null);

            scrollView = new NestedScrollView(new ContextThemeWrapper(this, Resource.Style.DarkBackgroundStyle));
            scrollView.LayoutParameters = scrollViewLayoutParams;
            scrollView.AddView(fragmentView);

            coordLayout = new CoordinatorLayout(this);
            coordLayout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            coordLayout.AddView(appBarLayout);
            coordLayout.AddView(scrollView);

            SetContentView(coordLayout);

            SupportFragmentManager.BeginTransaction().SetReorderingAllowed(true).Add(fragmentView.Id, dlg.Properties, "PropertyDialog").Commit();
        }
        public override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var shellSection = ShellSection;

            if (shellSection == null)
            {
                return(null);
            }

            var root = inflater.Inflate(Resource.Layout.RootLayout, null).JavaCast <CoordinatorLayout>();

            _toolbar    = root.FindViewById <Toolbar>(Resource.Id.main_toolbar);
            _scrollview = root.FindViewById <NestedScrollView>(Resource.Id.main_scrollview);
            _tablayout  = root.FindViewById <TabLayout>(Resource.Id.main_tablayout);

            _viewPager = new FormsViewPager(Context)
            {
                LayoutParameters = new LP(LP.MatchParent, LP.MatchParent),
                EnableGesture    = false
            };

            _viewPager.AddOnPageChangeListener(this);
            _viewPager.Id = Platform.GenerateViewId();

            _viewPager.Adapter        = new ShellFragmentPagerAdapter(shellSection, ChildFragmentManager);
            _viewPager.OverScrollMode = OverScrollMode.Never;

            _tablayout.SetupWithViewPager(_viewPager);

            var currentPage  = ((IShellContentController)shellSection.CurrentItem).GetOrCreateContent();
            var currentIndex = ShellSection.Items.IndexOf(ShellSection.CurrentItem);

            _toolbarTracker      = _shellContext.CreateTrackerForToolbar(_toolbar);
            _toolbarTracker.Page = currentPage;

            _viewPager.CurrentItem = currentIndex;
            _scrollview.AddView(_viewPager);

            if (shellSection.Items.Count == 1)
            {
                _tablayout.Visibility = ViewStates.Gone;
            }

            _tabLayoutAppearanceTracker = _shellContext.CreateTabLayoutAppearanceTracker(ShellSection);
            _toolbarAppearanceTracker   = _shellContext.CreateToolbarAppearanceTracker();

            HookEvents();

            return(_rootView = root);
        }
Exemplo n.º 3
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (Vm == null)
            {
                throw new ArgumentNullException();
            }
            var scrollView = new NestedScrollView(container.Context)
            {
                LayoutParameters = container.LayoutParameters
            };
            var layout = new LinearLayout(container.Context)
            {
                LayoutParameters = scrollView.LayoutParameters,
                Orientation      = Orientation.Vertical
            };

            var view = inflater.Inflate(Resource.Layout.ItemEditWiki, layout, true);

            TitleText   = view.FindViewById <EditText>(Resource.Id.editText1);
            SummaryText = view.FindViewById <EditText>(Resource.Id.editText2);

            _bindings.Add(this.SetBinding(() => Vm.Model.Title, () => TitleText.Text, BindingMode.TwoWay));
            _bindings.Add(this.SetBinding(() => Vm.Model.Title, () => SummaryText.Text, BindingMode.TwoWay));

            var counter = 0;

            foreach (var section in Vm.Model.Sections)
            {
                view = inflater.Inflate(Resource.Layout.ItemEditWiki, layout, true);
                TitleEditTexts.Add(view.FindViewById <EditText>(Resource.Id.editText1));
                SectionEditTexts.Add(view.FindViewById <EditText>(Resource.Id.editText2));

                // Attempted to bind. But setBinding doesn't work as edit texts are in a List. Don't see any other way of holding references to the edit texts as the number is dynamic.
                TitleEditTexts[counter].Text = section.Title;
                TitleEditTexts[counter].Text = section.Content;
                counter++;
            }
            scrollView.AddView(layout);
            return(scrollView);
        }
Exemplo n.º 4
0
        private View RenderForm(FormParameter formParameter, string submitAction)
        {
            var scroll       = new NestedScrollView(Application.Context);
            var linearLayout = new LinearLayout(Application.Context)
            {
                Orientation = Orientation.Vertical
            };

            if (formParameter != null)
            {
                InvokeForm.Response result = null;
                var inputsManager          = new List <FormInputManager>();
                var resultLayout           = new LinearLayout(Application.Context)
                {
                    Orientation      = Orientation.Vertical,
                    LayoutParameters = linearLayout.MatchParentWrapContent()
                };

                if (formParameter.Form.InputFields.Count > 0)
                {
                    var inputsLayout = new LinearLayout(Application.Context)
                    {
                        Orientation = Orientation.Vertical
                    };

                    this.RenderInputs(inputsLayout, formParameter, inputsManager);

                    if (formParameter.Form.InputFields.Count(a => !a.Hidden) > 0)
                    {
                        this.ManagersCollection.StyleRegister.ApplyStyle("FormLayout", inputsLayout);
                        var submitLabel       = "Submit";
                        var submitbuttonlabel = formParameter.Form.CustomProperties?.GetCustomProperty <string>("submitButtonLabel");

                        if (!string.IsNullOrEmpty(submitbuttonlabel))
                        {
                            submitLabel = submitbuttonlabel;
                        }
                        var btn = new Button(Application.Context)
                        {
                            Text             = submitLabel,
                            LayoutParameters = inputsLayout.MatchParentWrapContent()
                        };
                        this.ManagersCollection.StyleRegister.ApplyStyle("Button SubmitButton", btn);
                        inputsLayout.AddView(btn);

                        btn.Click += async(sender, args) =>
                        {
                            try
                            {
                                result = await this.SubmitFormAsync(resultLayout, formParameter.Form, inputsManager);

                                if (submitAction == FormLinkActions.OpenModal && result != null)
                                {
                                    this.FormWrapper.CloseForm();
                                }
                                else
                                {
                                    this.RenderOutput(resultLayout, result, formParameter.Form, inputsManager);
                                }
                            }
                            catch (Exception ex)
                            {
                                Toast.MakeText(Application.Context, ex.Message, ToastLength.Long).Show();
                            }
                        };
                    }
                    linearLayout.AddView(inputsLayout);
                }
                // run on response handled events
                EventsManager.OnFormLoadedEvent(formParameter);

                if (formParameter.Form.PostOnLoad || submitAction == FormLinkActions.Run)
                {
                    try
                    {
                        var taskToRun = Task.Run(() => this.SubmitFormAsync(resultLayout, formParameter.Form, inputsManager,
                                                                            formParameter.Form.PostOnLoadValidation));
                        result = taskToRun.Result;
                    }
                    catch (AggregateException ex)
                    {
                        ex.ThrowInnerException();
                    }

                    if (submitAction == FormLinkActions.Run)
                    {
                        this.FormWrapper.CloseForm();
                        return(null);
                    }
                    this.RenderOutput(resultLayout, result, formParameter.Form, inputsManager);
                }
                this.ManagersCollection.StyleRegister.ApplyStyle("ResultsLayout", resultLayout);

                linearLayout.AddView(resultLayout);
                scroll.AddView(linearLayout, scroll.MatchParentWrapContent());
            }
            return(scroll);
        }