Example #1
0
        public FirstView()
        {
            InitializeComponent();

            // Navigation to detail page
            this.listCharacters.ItemSelected += (object sender, SelectedItemChangedEventArgs e) =>
            {
                TVShowItemViewModel show = (TVShowItemViewModel)e.SelectedItem;
                var detailVm             = new DetailViewModel(show.Id);

                var detailView = new DetailView(detailVm);

                this.Navigation.PushAsync(detailView);
            };


            Device.OnPlatform(WinPhone: () =>
                              listCharacters.ItemTemplate = new DataTemplate(() =>
            {
                var nativeCell = new NativeCell();
                nativeCell.SetBinding(NativeCell.NameProperty, "Name");
                nativeCell.SetBinding(NativeCell.ThumbnailProperty, "Thumbnail");

                return(nativeCell);
            }));

            _vm            = new FirstViewModel();
            BindingContext = _vm;
        }
Example #2
0
        public NativeiOSCell(string cellId, NativeCell cell) : base(UITableViewCellStyle.Default, cellId)
        {
            NativeCell = cell;

            SelectionStyle = UITableViewCellSelectionStyle.Gray;
            ContentView.BackgroundColor = UIColor.FromRGB(255, 255, 224);
            CellImageView = new UIImageView();

            HeadingLabel = new UILabel()
            {
                Font            = UIFont.FromName("Cochin-BoldItalic", 22f),
                TextColor       = UIColor.FromRGB(127, 51, 0),
                BackgroundColor = UIColor.Clear
            };

            SubheadingLabel = new UILabel()
            {
                Font            = UIFont.FromName("AmericanTypewriter", 12f),
                TextColor       = UIColor.FromRGB(38, 127, 0),
                TextAlignment   = UITextAlignment.Center,
                BackgroundColor = UIColor.Clear
            };

            ContentView.Add(HeadingLabel);
            ContentView.Add(SubheadingLabel);
            ContentView.Add(CellImageView);
        }
Example #3
0
        public NativeAndroidCell(Context context, NativeCell cell) : base(context)
        {
            NativeCell = cell;

            var view = (context as Activity).LayoutInflater.Inflate(Resource.Layout.NativeAndroidCell, null);

            HeadingTextView    = view.FindViewById <TextView>(Resource.Id.HeadingText);
            SubheadingTextView = view.FindViewById <TextView>(Resource.Id.SubheadingText);
            ImageView          = view.FindViewById <ImageView>(Resource.Id.Image);

            AddView(view);
        }
        public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
        {
            cellId = cellId ?? new NSString (item.GetType ().FullName);
            var nativeCell = reusableCell as NativeCell;
            var viewCell = item as FastCell;

            Device.BeginInvokeOnMainThread (new Action (viewCell.SendAppearing));

            if (reusableCell == null) {
                nativeCell = new NativeCell (cellId, viewCell);
            } else {
                nativeCell.RecycleCell (viewCell);
            }

            return nativeCell;
        }
        public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
        {
            cellId = cellId ?? new NSString (item.GetType ().FullName);
            var cellCache = FastCellCache.Instance.GetCellCache (tv);
            var fastCell = item as FastCell;
            var nativeCell = reusableCell as NativeCell;

            if (reusableCell != null && cellCache.IsCached (nativeCell)) {
                cellCache.RecycleCell (nativeCell, fastCell);
            } else {
                if (!fastCell.IsInitialized) {
                    fastCell.PrepareCell ();
                }
                nativeCell = new NativeCell (cellId, fastCell);
                cellCache.CacheCell (fastCell, nativeCell);
            }
            return nativeCell;
        }
        public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
        {
            cellId = cellId ?? new NSString (item.GetType ().FullName);
            var cellCache = FastCellCache.Instance.GetCellCache (tv);
            var fastCell = item as FastCell;
            var nativeCell = reusableCell as NativeCell;

            if (reusableCell != null && cellCache.IsCached (nativeCell, fastCell.ReuseIdentifier)) {
                cellCache.RecycleCell (nativeCell, fastCell);
            } else {
                var newCell = (FastCell)Activator.CreateInstance (item.GetType ());
                newCell.BindingContext = item.BindingContext;
                newCell.Parent = item.Parent;

                if (!newCell.IsInitialized) {
                    newCell.PrepareCell ();
                }
                nativeCell = new NativeCell (cellId, newCell);
                cellCache.CacheCell (newCell, nativeCell);
            }
            return nativeCell;
        }
Example #7
0
        public void UpdateCell(NativeCell cell)
        {
            HeadingTextView.Text    = cell.Name;
            SubheadingTextView.Text = cell.Category;

            // Dispose of the old image
            if (ImageView.Drawable != null)
            {
                using (var image = ImageView.Drawable as BitmapDrawable)
                {
                    if (image != null)
                    {
                        if (image.Bitmap != null)
                        {
                            image.Bitmap.Dispose();
                        }
                    }
                }
            }

            SetImage(cell.ImageFilename);
        }
        public FirstView()
        {
            InitializeComponent();

            // Navigation to detail page
            this.listCharacters.ItemSelected += (object sender, SelectedItemChangedEventArgs e) =>
            {
                var character = (CharacterItemViewModel)e.SelectedItem;
                var detailVm  = new DetailViewModel(character);

                var detailView = new DetailView(detailVm);

                this.Navigation.PushAsync(detailView);
            };

            switch (Device.RuntimePlatform)
            {
            case Device.UWP:
                listCharacters.ItemTemplate = new DataTemplate(() =>
                {
                    var nativeCell = new NativeCell();
                    nativeCell.SetBinding(NativeCell.NameProperty, "Name");
                    nativeCell.SetBinding(NativeCell.ThumbnailProperty, "Thumbnail");

                    return(nativeCell);
                });
                break;

            case Device.macOS:
                searchBar.FontSize = 14;
                break;
            }

            _vm            = new FirstViewModel();
            BindingContext = _vm;
            Task.Run(async() => await _vm.Init());
        }
Example #9
0
 public void UpdateCell(NativeCell cell)
 {
     HeadingLabel.Text    = cell.Name;
     SubheadingLabel.Text = cell.Category;
     CellImageView.Image  = GetImage(cell.ImageFilename);
 }
        protected override ElmSharp.EvasObject OnGetContent(Cell cell, string part)
        {
            if (part != MainContentPart)
            {
                return(null);
            }
            NativeCell viewCell      = (NativeCell)cell;
            var        minimumHeight = PageHeight > 800 ? 96 : 76;

            ElmSharp.Box mainBox = new ElmSharp.Box(Forms.NativeParent);
            mainBox.BackgroundColor = Color.LightYellow.ToNative();
            mainBox.MinimumHeight   = minimumHeight;
            mainBox.IsHorizontal    = false;
            mainBox.SetAlignment(-1, -1);
            mainBox.Show();

            ElmSharp.Box contentBox = new ElmSharp.Box(Forms.NativeParent);
            contentBox.MinimumHeight = minimumHeight;
            contentBox.IsHorizontal  = true;
            contentBox.SetAlignment(-1, -1);
            contentBox.Show();

            ElmSharp.Box left = new ElmSharp.Box(Forms.NativeParent);
            left.IsHorizontal = false;
            left.Show();
            left.SetWeight(4.0, 1);
            left.SetAlignment(-1, -1);
            contentBox.PackEnd(left);

            ElmSharp.Label titleName = new ElmSharp.Label(Forms.NativeParent);
            left.PackEnd(titleName);
            titleName.Show();
            titleName.Text         = $"<span font_size=34 font_style=italic color=#7F3300>   {viewCell.Name}</span>";
            titleName.MinimumWidth = 250;
            titleName.SetAlignment(-1, -1);

            ElmSharp.Label titleCategory = new ElmSharp.Label(Forms.NativeParent);
            left.PackEnd(titleCategory);
            titleCategory.Show();
            titleCategory.Text = $"<span align=center font_size=24 color=#008000>{viewCell.Category}</span>";
            titleCategory.SetAlignment(-1, -1);

            ElmSharp.Box right = new ElmSharp.Box(Forms.NativeParent);
            right.Show();
            right.MinimumWidth  = 96;
            right.MinimumHeight = minimumHeight;
            right.SetWeight(1, 1);
            right.SetAlignment(-1, 0);

            ElmSharp.Image image;

            if (viewCell.ImageFilename != "")
            {
                image = new ElmSharp.Image(right);
                image.Load(global::Tizen.Applications.Application.Current.DirectoryInfo.Resource + viewCell.ImageFilename + ".jpg");
                image.SetAlignment(0.5, 0.5);
                image.MinimumHeight = minimumHeight;
                image.MinimumWidth  = minimumHeight;
                image.Show();
                right.PackEnd(image);
            }

            ElmSharp.Rectangle rec = new ElmSharp.Rectangle(left);
            rec.MinimumHeight = 1;
            rec.MinimumWidth  = 400;
            rec.AlignmentX    = -1;
            rec.Color         = ElmSharp.Color.Gray;
            rec.Show();

            contentBox.PackEnd(right);

            mainBox.PackEnd(contentBox);
            mainBox.PackEnd(rec);

            return(mainBox);
        }