Exemplo n.º 1
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            ViewHolder holder;

            if (convertView == null)
            {
                convertView     = DroidFactory.MainActivity.LayoutInflater.Inflate(Resource.Layout.ab_main_view, parent, false);
                convertView.Tag = holder = new ViewHolder
                {
                    Title    = convertView.FindViewById <TextView>(Resource.Id.ab_basemaps_title),
                    Subtitle = convertView.FindViewById <TextView>(Resource.Id.ab_basemaps_subtitle),
                };
            }
            else
            {
                holder = (ViewHolder)convertView.Tag;
            }

            var titleView = PaneManager.Instance.FromNavContext(Pane.Master, position)?.CurrentView as IView;
            var title     = titleView?.Title;

            var stack = PaneManager.Instance.FromNavContext(Pane.Detail, position);

            titleView = stack?.CurrentView as IView;
            if (titleView != null && stack.FindPane() == Pane.Detail && !string.IsNullOrWhiteSpace(titleView.Title))
            {
                title += " | " + titleView.Title;
            }

            holder.Title.Text = string.IsNullOrEmpty(title) ?
                                TabItems.ElementAtOrDefault(position)?.Title ?? Title
                    : title;
            holder.Subtitle.Text = TabItems.ElementAtOrDefault(position)?.Title ?? string.Empty;
            if (!TitleColor.IsDefaultColor)
            {
                holder.Title.SetTextColor(TitleColor.ToColor());
                holder.Subtitle.SetTextColor(TitleColor.ToColor());
            }
            holder.Title.Visibility    = string.IsNullOrWhiteSpace(holder.Title.Text) ? ViewStates.Invisible : ViewStates.Visible;
            holder.Subtitle.Visibility = string.IsNullOrWhiteSpace(holder.Subtitle.Text) ? ViewStates.Gone : ViewStates.Visible;
            return(convertView);
        }