Exemplo n.º 1
0
        public override View OnCreateView(LayoutInflater inflater,
                                          ViewGroup parent, Bundle savedInstanceState)
        {
            /* Inflate the layout for the fragment                           */
            AnnouncementsView = inflater.Inflate(
                Resource.Layout.AnnouncementsFragmentLayout, parent, false);

            /* Get the recyclerview layout                                   */
            AnnouncementRecyclerView =
                AnnouncementsView.FindViewById <RecyclerView>(
                    Resource.Id.AnnouncementsRecyclerView);

            /* Create a new layout manager using the activity containing     */
            /* this fragment as the context                                  */
            AnnouncementLayoutManager = new LinearLayoutManager(Activity);

            /* Create a custom adapter and pass it the data that it will be  */
            /* recycling through                                             */
            AnnouncementAdapter =
                new announcementsRecyclerViewAdapter(Activity as mainActivity, Announcements);

            /* Helps with performance: HasStableIds = true
             * ALTHOUGH FOR NOW, DO NOT INCLUDE THIS: DATA DOES NOT DISPLAY
             * CORRECTLY                                                     */
            //AnnouncementAdapter.HasStableIds = true;

            /* Selecting the tab will automatically scroll back to the top   */
            /* of the list                                                   */
            TabLayout = ParentFragment.View.FindViewById <TabLayout>(
                Resource.Id.MainTabLayout);
            TabLayout.TabReselected += TabReselected;

            /* "Pulling" down on the page will refresh the view              */
            RefreshLayout =
                AnnouncementsView.FindViewById <SwipeRefreshLayout>(
                    Resource.Id.SwipeRefreshAnnouncements);

            RefreshLayout.SetColorSchemeResources(Resource.Color.primary,
                                                  Resource.Color.accent, Resource.Color.primary_text,
                                                  Resource.Color.secondary_text);
            RefreshLayout.Refresh += RefreshLayoutRefresh;

            /* Setup the recyclerview with the created adapter and layout    */
            /* manager                                                       */
            AnnouncementRecyclerView.SetLayoutManager(AnnouncementLayoutManager);
            AnnouncementRecyclerView.SetAdapter(AnnouncementAdapter);


            return(AnnouncementsView);
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            _adapter = Vm.Places.GetRecyclerAdapter(
                BindViewHolder,
                Resource.Layout.PlaceTemplate,
                OnItemClick);

            _bindings.Add(this.SetBinding(
                              () => Vm.Loading,
                              () => RefreshLayout.Refreshing));

            PlacesList.SetLayoutManager(new LinearLayoutManager(this));
            PlacesList.SetAdapter(_adapter);
            RefreshLayout.SetColorSchemeColors(Color.Red, Color.Yellow, Color.Green);
            RefreshLayout.Refresh += RefreshLayoutOnRefresh;
        }
Exemplo n.º 3
0
        /*********************************************************************/
        /* On CreateView                                                     */
        /*********************************************************************/
        public override View OnCreateView(LayoutInflater inflater,
                                          ViewGroup container, Bundle savedInstanceState)
        {
            /* Inflate the layout for the fragment                                 */
            _gradesView = inflater.Inflate(Resource.Layout.GradesFragmentLayout,
                                           container, false);

            /* Get the parent recyclerview                                         */
            _gradesRecyclerView =
                _gradesView.FindViewById <RecyclerView>(
                    Resource.Id.GradesRecyclerView);

            _gradesAdapter =
                ViewModel.Grades.GetRecyclerAdapter(BindViewHolder,
                                                    Resource.Layout.GradesCardLayout);

            /* Setup the recyclerview with the created adapter and layout manager  */
            _gradesRecyclerView.SetLayoutManager(new LinearLayoutManager(Activity));
            _gradesRecyclerView.SetAdapter(_gradesAdapter);

            /* Get the tablayout so we can scroll back up                          */
            _currentTabLayout =
                ParentFragment.View.FindViewById <TabLayout>(Resource.Id.MainTabLayout);

            _currentTabLayout.TabReselected += TabLayoutTabReselected;

            /* "Pulling" down on the page will refresh the view              */
            RefreshLayout =
                _gradesView.FindViewById <SwipeRefreshLayout>(
                    Resource.Id.SwipeRefreshGrades);

            RefreshLayout.SetColorSchemeResources(Resource.Color.primary,
                                                  Resource.Color.accent, Resource.Color.primary_text,
                                                  Resource.Color.secondary_text);
            RefreshLayout.Refresh += RefreshLayoutRefresh;

            return(_gradesView);
        }
Exemplo n.º 4
0
        public override View OnCreateView(LayoutInflater inflater,
                                          ViewGroup container, Bundle savedInstanceState)
        {
            // Inflate the layout for the fragment
            _eventSignUpView =
                inflater.Inflate(Resource.Layout.EventsFragmentLayout,
                                 container, false);
            /* Get the view pager                                            */
            _eventRecyclerView =
                _eventSignUpView.FindViewById <RecyclerView>(
                    Resource.Id.EventSignUpRecyclerView);

            _adapter = ViewModel.Events.GetRecyclerAdapter(
                BindViewHolder,
                Resource.Layout.EventCardLayout,
                OnItemClick);


            /* "Pulling" down on the page will refresh the view              */
            RefreshLayout =
                _eventSignUpView.FindViewById <SwipeRefreshLayout>(
                    Resource.Id.SwipeRefreshEvents);

            RefreshLayout.SetColorSchemeResources(Resource.Color.primary,
                                                  Resource.Color.accent, Resource.Color.primary_text,
                                                  Resource.Color.secondary_text);
            RefreshLayout.Refresh += RefreshLayoutRefresh;


            _eventRecyclerView.SetLayoutManager(new LinearLayoutManager(Activity));
            _eventRecyclerView.SetAdapter(_adapter);

            _currentTabLayout = ParentFragment.View.FindViewById <TabLayout>(Resource.Id.MainTabLayout);
            _currentTabLayout.TabReselected += TabLayoutTabReselected;

            return(_eventSignUpView);
        }
        public override View Run()
        {
            var main = new View
            {
                Layout = new LinearLayout
                {
                    LinearOrientation = LinearLayout.Orientation.Vertical
                },
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
            };

            main.Add(new Label
            {
                Text                  = "Refresh Layout Test",
                TextColor             = Color.White,
                FontSize              = 9,
                FontAttributes        = Tizen.UIExtensions.Common.FontAttributes.Bold,
                VerticalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Center,
                WidthSpecification    = LayoutParamPolicies.MatchParent,
                SizeHeight            = 100,
                Padding               = new Extents(20, 10, 10, 10),
                BackgroundColor       = Color.FromHex("#2196f3").ToNative(),
                BoxShadow             = new Shadow(5, Color.FromHex("#bbbbbb").ToNative(), new Vector2(0, 5))
            });

            var scrollview = new Tizen.UIExtensions.NUI.ScrollView()
            {
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
            };

            scrollview.ContentContainer.Layout = new LinearLayout
            {
                LinearOrientation = LinearLayout.Orientation.Vertical,
            };

            for (int i = 0; i < 3; i++)
            {
                var rnd   = new Random();
                var child = new View
                {
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                    SizeHeight         = 50,
                };
                child.BackgroundColor = new Tizen.NUI.Color(rnd.NextSingle(), rnd.NextSingle(), rnd.NextSingle(), 1);
                scrollview.Add(child);
            }

            var startRefresh = new Tizen.UIExtensions.NUI.Button()
            {
                Text = "StartRefresh"
            };

            scrollview.Add(startRefresh);

            var changeBg = new Tizen.UIExtensions.NUI.Button()
            {
                Text = "Change background"
            };

            scrollview.Add(changeBg);


            var changeColor = new Tizen.UIExtensions.NUI.Button()
            {
                Text = "Change Color"
            };

            scrollview.Add(changeColor);

            for (int i = 0; i < 100; i++)
            {
                var rnd   = new Random();
                var child = new View
                {
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                    SizeHeight         = 50,
                };
                child.BackgroundColor = new Tizen.NUI.Color(rnd.NextSingle(), rnd.NextSingle(), rnd.NextSingle(), 1);
                scrollview.Add(child);
            }



            var wrapperView = new View
            {
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
            };

            wrapperView.Add(scrollview);

            var refreshView = new RefreshLayout()
            {
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                Content             = wrapperView,
            };

            refreshView.Refreshing += async(s, e) =>
            {
                await System.Threading.Tasks.Task.Delay(2000);

                refreshView.IsRefreshing = false;
            };
            main.Add(refreshView);


            startRefresh.Clicked += (s, e) => refreshView.IsRefreshing = true;
            changeBg.Clicked     += (s, e) =>
            {
                if (refreshView.IconBackgroundColor == Color.Default)
                {
                    refreshView.IconBackgroundColor = Color.Green;
                }
                else
                {
                    refreshView.IconBackgroundColor = Color.Default;
                }
            };
            changeColor.Clicked += (s, e) =>
            {
                if (refreshView.IconColor == Color.Default)
                {
                    refreshView.IconColor = Color.Red;
                }
                else
                {
                    refreshView.IconColor = Color.Default;
                }
            };

            return(main);
        }
Exemplo n.º 6
0
        public override void Run(ElmSharp.Box parent)
        {
            var refreshLayout = new RefreshLayout(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
            };

            var contentBox = new Box(parent)
            {
                WeightX         = 1,
                WeightY         = 1,
                AlignmentY      = -1,
                AlignmentX      = -1,
                BackgroundColor = ElmSharp.Color.Gray
            };

            var statusLabel = new Label(parent)
            {
                Text       = "Idle",
                WeightX    = 1,
                WeightY    = 1,
                AlignmentX = -1,
                AlignmentY = -1,
                TextColor  = Color.Beige,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                FontAttributes          = FontAttributes.Bold,
                FontSize = 30
            };

            statusLabel.Move(100, 200);
            statusLabel.Resize(300, 100);
            statusLabel.Show();

            var changeIconColorButton = new Button(parent)
            {
                Text       = "Change Icon Color",
                WeightX    = 1,
                WeightY    = 1,
                AlignmentX = -1,
                AlignmentY = -1,
            };

            changeIconColorButton.Move(100, 300);
            changeIconColorButton.Resize(400, 100);
            changeIconColorButton.Clicked += (s, e) =>
            {
                if (refreshLayout.IconColor == Color.Default)
                {
                    refreshLayout.IconColor = Color.Red;
                }
                else
                {
                    refreshLayout.IconColor = Color.Default;
                }
            };
            changeIconColorButton.Show();

            var changeIconBackgroundColorButton = new Button(parent)
            {
                Text       = "Change BackgroundColor",
                WeightX    = 1,
                WeightY    = 1,
                AlignmentX = -1,
                AlignmentY = -1,
            };

            changeIconBackgroundColorButton.Move(100, 400);
            changeIconBackgroundColorButton.Resize(400, 100);
            changeIconBackgroundColorButton.Clicked += (s, e) =>
            {
                if (refreshLayout.IconBackgroundColor == Color.Yellow)
                {
                    refreshLayout.IconBackgroundColor = Color.White;
                }
                else
                {
                    refreshLayout.IconBackgroundColor = Color.Yellow;
                }
            };
            changeIconBackgroundColorButton.Show();

            var changeRefreshingButton = new Button(parent)
            {
                Text       = $"Start Refreshing",
                WeightX    = 1,
                WeightY    = 1,
                AlignmentX = -1,
                AlignmentY = -1,
            };

            changeRefreshingButton.Move(100, 500);
            changeRefreshingButton.Resize(400, 100);
            changeRefreshingButton.Clicked += (s, e) =>
            {
                refreshLayout.IsRefreshing = true;
            };
            changeRefreshingButton.Show();

            contentBox.PackEnd(statusLabel);
            contentBox.PackEnd(changeIconColorButton);
            contentBox.PackEnd(changeIconBackgroundColorButton);
            contentBox.PackEnd(changeRefreshingButton);
            contentBox.Show();

            var scrollView = new ScrollView(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
                HorizontalScrollBarVisibility = ScrollBarVisibility.Default,
            };

            scrollView.SetScrollCanvas(contentBox);
            scrollView.SetContentSize(720, 2000);
            scrollView.Show();

            refreshLayout.Content          = scrollView;
            refreshLayout.IsRefreshEnabled = true;
            refreshLayout.IsEdgeScrolling  = () =>
            {
                if (scrollView.ScrollBound.Y == 0)
                {
                    return(true);
                }
                return(false);
            };
            refreshLayout.Refreshing += async(s, e) =>
            {
                statusLabel.Text = "Refreshing";
                await Task.Delay(2000);

                refreshLayout.IsRefreshing = false;
                statusLabel.Text           = "Refreshed";
            };
            refreshLayout.Show();
            parent.PackEnd(refreshLayout);
        }
Exemplo n.º 7
0
        public override View OnCreateView(LayoutInflater inflater,
                                          ViewGroup container, Bundle savedInstanceState)
        {
            StudentCourtView = inflater.Inflate(Resource.Layout.StudentCourtFragmentLayout,
                                                container, false);

            #region NICK's REFRESH LAYOUT CODE
            /* "Pulling" down on the page will refresh the view              */

            /*RefreshLayout =
             *  StudentCourtView.FindViewById<SwipeRefreshLayout>(
             *      Resource.Id.SwipeRefreshStudentCourt);*/

            /*RefreshLayout.SetColorSchemeResources(Resource.Color.primary,
             *  Resource.Color.accent, Resource.Color.primary_text,
             *      Resource.Color.secondary_text);
             * RefreshLayout.Refresh += RefreshLayoutRefresh;*/
            #endregion

            RecyclerView _recyclerview =
                StudentCourtView.FindViewById <RecyclerView>(Resource.Id.PendingReportSlips);

            _adapter = ViewModel.StudentOffenseCard.Offenses.GetRecyclerAdapter
                       (
                BindViewHolder, Resource.Layout.StudentCourtInfractionCardLayout
                       );

            /* "Pulling" down on the page will refresh the view              */
            RefreshLayout =
                StudentCourtView.FindViewById <SwipeRefreshLayout>(
                    Resource.Id.SwipeRefreshStudentCourt);

            RefreshLayout.SetColorSchemeResources(Resource.Color.primary,
                                                  Resource.Color.accent, Resource.Color.primary_text,
                                                  Resource.Color.secondary_text);
            RefreshLayout.Refresh += RefreshLayoutRefresh;

            _recyclerview.SetLayoutManager(new LinearLayoutManager(Activity));
            _recyclerview.SetAdapter(_adapter);

            ParentFragment.View.FindViewById <TabLayout>(Resource.Id.MainTabLayout).TabReselected += TabReselected;

            /* Student court progress bars                                   */
            DemeritsProgBar        = new ProgressBar(Activity);
            DormInfractionsProgBar = new ProgressBar(Activity);
            AbsencesProgBar        = new ProgressBar(Activity);
            LateDormProgBar        = new ProgressBar(Activity);

            DemeritsProgBar =
                StudentCourtView.FindViewById <ProgressBar>(Resource.Id.DemeritsProgressBar);
            DormInfractionsProgBar =
                StudentCourtView.FindViewById <ProgressBar>(Resource.Id.DormInfractionsProgressBar);
            AbsencesProgBar =
                StudentCourtView.FindViewById <ProgressBar>(Resource.Id.AbsencesProgressBar);
            LateDormProgBar =
                StudentCourtView.FindViewById <ProgressBar>(Resource.Id.LateDormProgressBar);

            /* Set max value for progress bars                               */
            DemeritsProgBar.Max        = App.StudentCourt.MaxDemerits;
            DormInfractionsProgBar.Max = App.StudentCourt.MaxDormInfractions;
            AbsencesProgBar.Max        = App.StudentCourt.MaxAbsences;
            LateDormProgBar.Max        = App.StudentCourt.MaxLateDormInfraction;

            StudentCourtView.Post(() => SetUpProgressBars());

            /*****************************************************************/
            /* Create Student Court Gradient                                 */
            /*****************************************************************/

            int      startColor = Color.Transparent;
            int      endColor;
            Color    startColorAndroidGraphics;
            TextView statusText =
                StudentCourtView.FindViewById <TextView>(Resource.Id.StudentCourtStatusText);
            ImageView studentCourtImage =
                StudentCourtView.FindViewById <ImageView>(Resource.Id.StudentCourtCircle);
            Drawable imageBackground = studentCourtImage.Background;

            /* Convert dp stroke width to pixels for student court circle    */
            int            strokeWidthDp  = 4;
            DisplayMetrics displayMetrics = Resources.DisplayMetrics;
            float          strokeWidth    = TypedValue.ApplyDimension(
                ComplexUnitType.Dip, strokeWidthDp, displayMetrics);

            switch (ViewModel.StudentOffenseCard.StudentCourtStatus)
            {
            case App.StudentCourtStatus.Green:
            {
                startColor = ResourcesCompat.GetColor(
                    Resources, Resource.Color.green_500, null);
                statusText.Text =
                    "You are not required to attend Student Court.";
            }
            break;

            case App.StudentCourtStatus.Gray:
            {
                startColor = ResourcesCompat.GetColor(
                    Resources, Resource.Color.body_text_soft_light_theme, null);
                statusText.Text =
                    "You are not required to attend Student Court.";
            }
            break;

            case App.StudentCourtStatus.Red:
            {
                startColor = ResourcesCompat.GetColor(
                    Resources, Resource.Color.red_a700, null);
                statusText.Text =
                    "You are required to attend Student Court.";
            }
            break;
            }

            /* Set color for circle image                                    */
            startColorAndroidGraphics = new Color(startColor);
            GradientDrawable shapeDrawable = (GradientDrawable)imageBackground;
            shapeDrawable.SetStroke((int)strokeWidth, startColorAndroidGraphics);

            /* Set text color for student court status                       */
            StudentCourtView.FindViewById <TextView>(Resource.Id.StudentCourtStatusText)
            .SetTextColor(startColorAndroidGraphics);

            /* Get the name of the current theme                             */
            TypedValue attrValue = new TypedValue();
            Activity.Theme.ResolveAttribute(
                Resource.Attribute.modThemeName, attrValue, true);

            /* Set the end color for gradient based on the current theme     */
            if (attrValue.String.ToString() == "ModAppCompatLightTheme")
            {
                endColor = ResourcesCompat.GetColor(
                    Resources, Resource.Color.window_background, null);
            }
            else
            {
                endColor = ResourcesCompat.GetColor(
                    Resources, Resource.Color.window_background_dark_theme, null);
            }

            int[] gradientColors = { startColor, endColor };

            /* Set the gradient's start and end colors                       */
            GradientDrawable gradient = new GradientDrawable(
                GradientDrawable.Orientation.TopBottom, gradientColors);
            StudentCourtView.FindViewById <ImageView>(Resource.Id.GradientStudentCourt)
            .Background = gradient;



            /*****************************************************************/
            /* Click events for info icons                                   */
            /*****************************************************************/
            StudentCourtView.FindViewById <ImageView>(Resource.Id.DormInfractionsInfoIcon).Click += ShowInfoIconDialog;
            StudentCourtView.FindViewById <ImageView>(Resource.Id.AbsencesInfoIcon).Click        += ShowInfoIconDialog;
            StudentCourtView.FindViewById <ImageView>(Resource.Id.LateDormInfoIcon).Click        += ShowInfoIconDialog;

            /* Use this to return your custom view for this Fragment         */
            return(StudentCourtView);
        }