Exemple #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var r         = new Random();
            var generator = new LoremIpsumGenerator();

            items = new NSMutableArray();
            for (int i = 0; i < 20; i++)
            {
                items.Add(new NSString(generator.GenerateString(2 + r.Next(30))));
            }

            dataSource = new TKDataSource(items);
            dataSource.Settings.ListView.DefaultCellClass = new ObjCRuntime.Class(typeof(ListViewVariableSizeCell));
            dataSource.Settings.ListView.InitCell((TKListView listView, NSIndexPath indexPath, TKListViewCell cell, NSObject item) => {
                var myCell        = cell as ListViewVariableSizeCell;
                myCell.label.Text = item.Description;
            });

            var list = new TKListView(this.View.Bounds);

            list.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            list.WeakDataSource   = dataSource;
            this.View.AddSubview(list);

            var layout = list.Layout as TKListViewLinearLayout;

            layout.DynamicItemSize = true;
        }
Exemple #2
0
            public override void DidReorderItemFromIndexPath(TKListView listView, NSIndexPath originalIndexPath, NSIndexPath targetIndexPath)
            {
                TKListViewCell cell = listView.CellForItem(originalIndexPath);

                cell.BackgroundView.BackgroundColor = UIColor.White;
                this.owner.dataSource.DidReorderItemFromTo(listView, originalIndexPath, targetIndexPath);
            }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            dataSource.LoadDataFromJSONResource ("ListViewSampleData", "json", "teams");
            dataSource.GroupItemSourceKey = "items";
            dataSource.FilterWithQuery ("key like 'Marketing'");
            dataSource.GroupWithKey ("key");

            this.UpdateData (3);

            this.listViewDataSource =  new ListViewDataSource (this);
            this.listViewDelegate = new ListViewDelegate (this);

            TKListView listView = new TKListView (this.View.Bounds);
            listView.RegisterClassForCell (new ObjCRuntime.Class (typeof(TKListViewCell)), "cell");
            listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            listView.DataSource = this.listViewDataSource;
            listView.Delegate = this.listViewDelegate;
            listView.AllowsPullToRefresh = true;
            listView.PullToRefreshTreshold = 70;
            listView.PullToRefreshView.BackgroundColor = UIColor.Blue;
            listView.PullToRefreshView.ActivityIndicator.Color = UIColor.White;
            this.View.AddSubview (listView);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            this.Photos = new TKDataSource ("PhotosWithNames", "json", "photos");
            this.Names = new TKDataSource ("PhotosWithNames", "json", "names");

            TKListView listView = new TKListView (this.View.Bounds);
            listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            listView.DataSource = new ListViewDataSource (this);
            this.View.AddSubview (listView);
            listView.RegisterClassForCell (new Class(typeof(ImageWithTextListViewCell)), "cell");

            TKListViewGridLayout layout = new TKListViewGridLayout();
            layout.ItemAlignment = TKListViewItemAlignment.Center;
            layout.SpanCount = 2;
            layout.ItemSize = new CGSize (150, 200);
            layout.LineSpacing = 60;
            layout.ItemSpacing = 10;
            listView.Layout = layout;

            TKView view = new TKView ();
            view.Fill = TKLinearGradientFill.WithColors (new UIColor[] {
                new UIColor (0.35f, 0.68f, 0.89f, 0.89f),
                new UIColor (0.35f, 0.68f, 1.0f, 1.0f),
                new UIColor (0.85f, 0.8f, 0.2f, 0.8f)
            });
            listView.BackgroundView = view;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.listViewDelegate = new NotificationsListViewDelegate(this);

            NSMutableArray types = new NSMutableArray();

            types.Add(new NSString("Error"));
            types.Add(new NSString("Warning"));
            types.Add(new NSString("Success"));
            types.Add(new NSString("Info"));

            dataSource = new TKDataSource(types);

            listView                  = new TKListView();
            listView.Frame            = this.View.Bounds;
            listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            listView.Delegate         = listViewDelegate;
            listView.WeakDataSource   = dataSource;
            this.View.AddSubview(listView);

            titles = new NSMutableArray();
            titles.Add(new NSString("Oh no!"));
            titles.Add(new NSString("Warning!"));
            titles.Add(new NSString("Well done!"));
            titles.Add(new NSString("Info."));

            messages = new NSMutableArray();
            messages.Add(new NSString("Change this and try again!"));
            messages.Add(new NSString("e careful next time"));
            messages.Add(new NSString("You successfully read this message"));
            messages.Add(new NSString("This is TKAlert dialog"));

            colors = new NSMutableArray();
            colors.Add(new UIColor(1f, 0f, 0.282f, 1f));
            colors.Add(new UIColor(1f, 0.733f, 0f, 1f));
            colors.Add(new UIColor(0.478f, 0.988f, 0.157f, 1f));
            colors.Add(new UIColor(0.231f, 0.678f, 1f, 1f));

            alert = new TKAlert();
            alert.Style.ContentSeparatorWidth = 0;
            alert.Style.TitleColor            = new UIColor(1f, 1f, 1f, 1f);
            alert.Style.MessageColor          = new UIColor(1f, 1f, 1f, 1f);
            alert.Style.CornerRadius          = 0;
            alert.Style.ShowAnimation         = TKAlertAnimation.SlideFromTop;
            alert.Style.DismissAnimation      = TKAlertAnimation.SlideFromTop;

            // >> alert-bg-cs
            alert.Style.BackgroundStyle = TKAlertBackgroundStyle.None;
            // << alert-bg-cs

            // >> alert-dismiss-cs
            alert.DismissMode = TKAlertDismissMode.Tap;
            // << alert-dismiss-cs

            // >> alert-layout-cs
            alert.ActionsLayout = TKAlertActionsLayout.Vertical;
            // << alert-layout-cs
        }
Exemple #6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            dataSource.LoadDataFromJSONResource("ListViewSampleData", "json", "teams");
            dataSource.GroupItemSourceKey = "items";
            dataSource.FilterWithQuery("key like 'Marketing'");
            dataSource.GroupWithKey("key");

            this.UpdateData(3);

            this.listViewDataSource = new ListViewDataSource(this);
            this.listViewDelegate   = new ListViewDelegate(this);

            TKListView listView = new TKListView(this.View.Bounds);

            listView.RegisterClassForCell(new ObjCRuntime.Class(typeof(TKListViewCell)), "cell");
            listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            listView.DataSource       = this.listViewDataSource;
            listView.Delegate         = this.listViewDelegate;

            // >> listview-pull-to-refresh-cs
            listView.AllowsPullToRefresh = true;
            // << listview-pull-to-refresh-cs

            listView.PullToRefreshTreshold                     = 70;
            listView.PullToRefreshView.BackgroundColor         = UIColor.Blue;
            listView.PullToRefreshView.ActivityIndicator.Color = UIColor.White;
            this.View.AddSubview(listView);
        }
Exemple #7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            for (int i = 0; i < 3; i++)
            {
                this.AddItem();
            }
            this.dataSource.ItemSource = this.items;

            this.toolbar       = new UIToolbar(new CGRect(0, this.View.Bounds.Y, this.View.Frame.Width, 44));
            this.toolbar.Items = new UIBarButtonItem[] {
                new UIBarButtonItem("Add", UIBarButtonItemStyle.Plain, this.AddTouched),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem("Remove", UIBarButtonItemStyle.Plain, this.RemoveTouched),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem("Update", UIBarButtonItemStyle.Plain, this.UpdateTouched),
            };
            toolbar.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            this.View.AddSubview(toolbar);

            this.listView = new TKListView(new CGRect(0, this.View.Bounds.Y + 44, this.View.Frame.Width, this.View.Bounds.Height - 44));
            this.listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            this.listView.WeakDataSource   = this.dataSource;
            this.listView.Delegate         = new ListViewDelegate(this);
            this.View.AddSubview(this.listView);

            this.toolbar.Items[2].Enabled = false;
            this.toolbar.Items[4].Enabled = false;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.sampleArrayOfStrings = NSArray.FromStrings(new String [] {
                "Kristina Wolfe",
                "Freda Curtis",
                "Jeffery Francis",
                "Eva Lawson",
                "Emmett Santos",
                "Theresa Bryan",
                "Jenny Fuller",
                "Terrell Norris",
                "Eric Wheeler",
                "Julius Clayton",
                "Alfredo Thornton",
                "Roberto Romero",
                "Orlando Mathis",
                "Eduardo Thomas",
                "Harry Douglas"
            });

            TKListView listView = new TKListView(this.View.Bounds);

            listView.RegisterClassForCell(new Class(typeof(TKListViewCell)), "cell");
            listView.DataSource = new ListViewDataSource(this);

            this.View.AddSubview(listView);
        }
            public override TKListViewCell CellForItem(TKListView listView, NSIndexPath indexPath)
            {
                TKListViewCell cell = listView.DequeueReusableCell("cell", indexPath) as TKListViewCell;

                cell.TextLabel.Text = this.owner.sampleArrayOfStrings.GetItem <NSString> ((uint)indexPath.Row);
                return(cell);
            }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            var r = new Random ();
            var generator = new LoremIpsumGenerator ();
            items = new NSMutableArray ();
            for (int i = 0; i < 20; i++) {
                items.Add (new NSString(generator.GenerateString (2 + r.Next (30))));
            }

            dataSource = new TKDataSource (items);
            dataSource.Settings.ListView.DefaultCellClass = new ObjCRuntime.Class (typeof(ListViewVariableSizeCell));
            dataSource.Settings.ListView.InitCell ((TKListView listView, NSIndexPath indexPath, TKListViewCell cell, NSObject item) => {
                var myCell = cell as ListViewVariableSizeCell;
                myCell.label.Text = item.Description;
            });

            var list = new TKListView (this.View.Bounds);
            list.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            list.WeakDataSource = dataSource;
            this.View.AddSubview (list);

            var layout = list.Layout as TKListViewLinearLayout;
            layout.DynamicItemSize = true;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.Photos = new TKDataSource("PhotosWithNames", "json", "photos");
            this.Names  = new TKDataSource("PhotosWithNames", "json", "names");

            this.Photos.Settings.ListView.CreateCell(delegate(TKListView listView, NSIndexPath indexPath, NSObject item) {
                TKListViewCell cell = listView.DequeueReusableCell("simpleCell", indexPath) as TKListViewCell;
                return(cell);
            });

            this.Photos.Settings.ListView.InitCell(delegate(TKListView listView, NSIndexPath indexPath, TKListViewCell cell, NSObject item) {
                NSString imageName      = (NSString)this.Photos.Items [indexPath.Row];
                cell.ImageView.Image    = new UIImage(imageName);
                cell.TextLabel.Text     = this.Names.Items [indexPath.Row] as NSString;
                TKView view             = (TKView)cell.BackgroundView;
                view.Stroke.StrokeSides = listView.Layout.IsKindOfClass(new Class(typeof(TKListViewColumnsLayout))) ? TKRectSide.Right | TKRectSide.Bottom : TKRectSide.All;
                view.SetNeedsDisplay();
            });

            this.ListView = new TKListView(this.View.Bounds);
            this.ListView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            this.ListView.WeakDataSource   = this.Photos;
            this.ListView.RegisterClassForCell(new Class(typeof(SimpleListViewCell)), "simpleCell");
            this.View.AddSubview(this.ListView);

            this.WrapLayoutSelected(this, EventArgs.Empty);
        }
        public override TKListViewReusableCell ViewForSupplementaryElementOfKind(TKListView listView, NSString kind, NSIndexPath indexPath)
        {
            TKListViewReusableCell headerCell = listView.DequeueReusableSupplementaryView(kind, "header", indexPath) as TKListViewReusableCell;

            headerCell.TextLabel.Text = String.Format("Group {0}", indexPath.Section);
            return(headerCell);
        }
Exemple #13
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            for (int i = 0; i<3; i++) {
                this.AddItem ();
            }
            this.dataSource.ItemSource = this.items;

            this.toolbar = new UIToolbar(new CGRect(0, this.View.Bounds.Y, this.View.Frame.Width, 44));
            this.toolbar.Items = new UIBarButtonItem[]{
                new UIBarButtonItem("Add", UIBarButtonItemStyle.Plain, this.AddTouched),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem("Remove", UIBarButtonItemStyle.Plain, this.RemoveTouched),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem("Update", UIBarButtonItemStyle.Plain, this.UpdateTouched),
            };
            toolbar.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            this.View.AddSubview (toolbar);

            this.listView = new TKListView (new CGRect(0, this.View.Bounds.Y + 44, this.View.Frame.Width, this.View.Bounds.Height - 44));
            this.listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            this.listView.WeakDataSource = this.dataSource;
            this.listView.Delegate = new ListViewDelegate(this);
            this.View.AddSubview (this.listView);

            this.toolbar.Items[2].Enabled = false;
            this.toolbar.Items[4].Enabled = false;
        }
Exemple #14
0
            public override TKListViewCell CellForItem(TKListView listView, NSIndexPath indexPath)
            {
                var cell = listView.DequeueReusableCell("cell", indexPath) as ListViewVariableSizeCell;

                cell.label.Text = this.items[indexPath.Row];
                return(cell);
            }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.Photos = new TKDataSource("PhotosWithNames", "json", "photos");
            this.Names  = new TKDataSource("PhotosWithNames", "json", "names");

            this.listViewDataSource = new ListViewDataSource(this);

            TKListView listView = new TKListView(this.View.Bounds);

            listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            listView.DataSource       = this.listViewDataSource;
            this.View.AddSubview(listView);
            listView.RegisterClassForCell(new Class(typeof(ImageWithTextListViewCell)), "cell");

            TKListViewGridLayout layout = new TKListViewGridLayout();

            layout.ItemAlignment = TKListViewItemAlignment.Center;
            layout.SpanCount     = 2;
            layout.ItemSize      = new CGSize(150, 200);
            layout.LineSpacing   = 60;
            layout.ItemSpacing   = 10;
            listView.Layout      = layout;

            TKView view = new TKView();

            view.Fill = TKLinearGradientFill.WithColors(new UIColor[] {
                new UIColor(0.35f, 0.68f, 0.89f, 0.89f),
                new UIColor(0.35f, 0.68f, 1.0f, 1.0f),
                new UIColor(0.85f, 0.8f, 0.2f, 0.8f)
            });
            listView.BackgroundView = view;
        }
        public override void ViewDidLoad()
        {
            // >> listview-groups-cs
            NSMutableArray items = new NSMutableArray();

            items.Add(new DataSourceItem("John", 50f, "A"));
            items.Add(new DataSourceItem("Abby", 33f, "A"));
            items.Add(new DataSourceItem("Smith", 42f, "B"));
            items.Add(new DataSourceItem("Peter", 28f, "B"));
            items.Add(new DataSourceItem("Paula", 25f, "B"));

            this.dataSource            = new TKDataSource();
            this.dataSource.ItemSource = items;
            this.dataSource.GroupWithKey("Group");
            dataSource.DisplayKey = "Name";

            TKListView listView = new TKListView(new CGRect(20, 20, this.View.Bounds.Size.Width - 40, this.View.Bounds.Size.Height - 40));

            listView.WeakDataSource = dataSource;
            this.View.AddSubview(listView);

            var layout = listView.Layout as TKListViewLinearLayout;

            layout.HeaderReferenceSize = new CGSize(200, 22);
            // << listview-groups-cs
        }
            public override TKListViewCell CellForItem(TKListView listView, NSIndexPath indexPath)
            {
                TKListViewCell cell      = (TKListViewCell)listView.DequeueReusableCell("cell", indexPath);
                NSString       imageName = (NSString)this.owner.Photos.Items [indexPath.Row];

                cell.ImageView.Image = UIImage.FromBundle(imageName);
                cell.TextLabel.Text  = (NSString)this.owner.Names.Items [indexPath.Row];
                return(cell);
            }
Exemple #18
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.View.BackgroundColor = UIColor.FromRGB(239, 239, 244);
            TKView view = new TKView(this.View.Bounds);

            view.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            view.Fill             = TKLinearGradientFill.WithColors(new UIColor[] {
                new UIColor(0.35f, 0.68f, 0.89f, 0.89f),
                new UIColor(0.35f, 0.68f, 1.0f, 1.0f),
                new UIColor(0.85f, 0.8f, 0.2f, 0.8f)
            });
            this.View.AddSubview(view);

            this.Autocomplete = new TKAutoCompleteTextView(new CGRect(10, this.View.Bounds.Y + 10, this.View.Bounds.Size.Width - 20, 35));
            this.Autocomplete.SuggestionViewOutOfFrame = true;
            this.AutomaticallyAdjustsScrollViewInsets  = false;

            this.Datasource = new TKDataSource();
            this.Datasource.LoadDataFromJSONResource("namesPhotos", "json", "data");
            this.Datasource.Settings.AutoComplete.CreateToken(delegate(nuint index, NSObject item) {
                TKAutoCompleteToken token = new TKAutoCompleteToken((NSString)(item.ValueForKey(new NSString("name"))));
                token.Image = UIImage.FromBundle((NSString)item.ValueForKey(new NSString("photo")));
                return(token);
            });

            TKListView listView = (TKListView)this.Autocomplete.WeakSuggestionView;

            listView.BackgroundColor = UIColor.Clear;
            listView.Frame           = new CGRect(10, this.View.Bounds.Y + 15 + this.Autocomplete.Bounds.Height, this.View.Bounds.Size.Width - 20, this.View.Bounds.Height - (15 + this.Autocomplete.Bounds.Height));
            listView.RemoveFromSuperview();
            listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            this.View.AddSubview(listView);
            listView.RegisterClassForCell(new Class(typeof(ImageWithTextListViewCell)), "cell");

            TKListViewGridLayout layout = new TKListViewGridLayout();

            layout.ItemAlignment = TKListViewItemAlignment.Center;
            layout.SpanCount     = 2;
            layout.ItemSize      = new CGSize(150, 200);
            layout.LineSpacing   = 60;
            layout.ItemSpacing   = 10;
            listView.Layout      = layout;

            this.Autocomplete.SuggestMode           = TKAutoCompleteSuggestMode.SuggestAppend;
            this.Autocomplete.AutoresizingMask      = UIViewAutoresizing.FlexibleWidth;
            this.Autocomplete.MaximumWrapHeight     = 80;
            this.Autocomplete.WeakDataSource        = this.Datasource;
            this.Autocomplete.TextField.Placeholder = "Enter Users";
            this.Autocomplete.NoResultsLabel.Text   = "No Users Found";
            this.Autocomplete.CloseButton.SetImage(UIImage.FromBundle("clear.png"), UIControlState.Normal);
            this.Autocomplete.ImageView.Image       = UIImage.FromBundle(new NSString("search.png"));
            this.Autocomplete.BackgroundColor       = UIColor.White;
            this.Autocomplete.WeakDelegate          = autocompleteDelegate;
            this.Autocomplete.ShowAllItemsInitially = true;
            this.View.AddSubview(this.Autocomplete);
        }
Exemple #19
0
            public override void DidHighlightItemAtIndexPath(TKListView listView, NSIndexPath indexPath)
            {
                Console.WriteLine("Did highlight item at row {0}", this.owner.dataSource.Items [indexPath.Row]);
                TKListViewCell cell = listView.CellForItem(indexPath);

                if (!cell.Selected && listView.SelectionBehavior == TKListViewSelectionBehavior.LongPress)
                {
                    cell.SelectedBackgroundView.Hidden = true;
                }
            }
		void useListView()
		{
			if (this.View.Subviews.Length > 0) {
				this.View.Subviews [0].RemoveFromSuperview ();
			}

			TKListView listView = new TKListView (this.View.Bounds);
			listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
			listView.WeakDataSource = this.dataSource;
			this.View.AddSubview (listView);
		}
Exemple #21
0
 public override void DidSelectItemAtIndexPath(TKListView listView, NSIndexPath indexPath)
 {
     if (listView.Tag == 0)
     {
         owner.alert.Style.ShowAnimation = (TKAlertAnimation)indexPath.Row;
     }
     else
     {
         owner.alert.Style.DismissAnimation = (TKAlertAnimation)indexPath.Row;
     }
 }
            public override bool ShouldLoadMoreDataAtIndexPath(TKListView listView, NSIndexPath indexPath)
            {
                DispatchQueue.DefaultGlobalQueue.DispatchAsync(() => {
                    this.owner.lastRetrievedDataIndex = Math.Min(this.owner.names.Items.Length, this.owner.lastRetrievedDataIndex + 10);
                    DispatchQueue.MainQueue.DispatchAfter(new DispatchTime(DispatchTime.Now, 2 * 400000000), new Action(delegate {
                        listView.DidLoadDataOnDemand();
                    }));
                });

                return(true);
            }
Exemple #23
0
            // >> listview-respond-cs
            public override void DidSelectItemAtIndexPath(TKListView listView, NSIndexPath indexPath)
            {
                this.owner.label.Text = string.Format("Selected: {0}", this.owner.dataSource.Items[indexPath.Row]);
                Console.WriteLine("Did select item at row {0}", this.owner.dataSource.Items [indexPath.Row]);
                TKListViewCell cell = listView.CellForItem(indexPath);

                if (cell != null)
                {
                    cell.SelectedBackgroundView.Hidden = false;
                }
            }
Exemple #24
0
 public override CGSize SizeForItem(TKListView listView, TKListViewLinearLayout layout, NSIndexPath indexPath)
 {
     if (layout.ScrollDirection == TKListViewScrollDirection.Vertical)
     {
         return(new CGSize(100, sizes[indexPath.Row]));
     }
     else
     {
         return(new CGSize(sizes[indexPath.Row], 100));
     }
 }
        void CreateListView()
        {
            var list = new TKListView (this.View.Bounds);
            list.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            list.RegisterClassForCell (new ObjCRuntime.Class(typeof(ListViewVariableSizeCell)), "cell");
            this.View.AddSubview (list);

            TKListViewLinearLayout layout = (TKListViewLinearLayout)list.Layout;
            layout.DynamicItemSize = true;

            list.WeakDataSource = new ListViewDataSource();
        }
        void useListView()
        {
            if (this.View.Subviews.Length > 0)
            {
                this.View.Subviews [0].RemoveFromSuperview();
            }

            TKListView listView = new TKListView(this.View.Bounds);

            listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            listView.WeakDataSource   = this.dataSource;
            this.View.AddSubview(listView);
        }
        public override void ViewDidLoad()
        {
            this.AddOption("Linear", "Layout", LinearLayoutSelected);
            this.AddOption("Grid", "Layout", GridLayoutSelected);
            this.AddOption("Staggered", "Layout", StaggeredLayoutSelected);
            this.AddOption("Flow", "Layout", FlowLayoutSelected);

            this.AddOption("Horiontal", "Orientation", HorizontalSelected);
            this.AddOption("Vertical", "Orientation", VerticalSelected);

            this.SetSelectedOption(1, 1);

            base.ViewDidLoad();

            dataSource = new TKDataSource();
            dataSource.LoadDataFromJSONResource("ListItems", "json", "items");

            string descriptor = string.Format("category LIKE '{0}' OR category LIKE '{1}' OR category LIKE '{2}'",
                                              categories [0], categories [1], categories [2]);

            dataSource.AddFilterDescriptor(new TKDataSourceFilterDescriptor(descriptor));

            itemsCount = dataSource.Items.Length;
            dataSource.ReloadData();
            dataSource.GroupWithKey("category");

            dataSource.Settings.ListView.CreateCell((TKListView listView, NSIndexPath indexPath, NSObject item) => {
                return(listView.DequeueReusableCell(new NSString("custom"), indexPath) as TKListViewCell);
            });

            dataSource.Settings.ListView.InitCell((TKListView listView, NSIndexPath indexPath, TKListViewCell cell, NSObject item) => {
                cell.ImageView.Image      = UIImage.FromBundle((NSString)item.ValueForKey(new NSString("photo")));
                cell.TextLabel.Text       = (NSString)item.ValueForKey(new NSString("title"));
                cell.DetailTextLabel.Text = (NSString)item.ValueForKey(new NSString("author"));
            });

            dataSource.Settings.ListView.InitHeader((TKListView listView, NSIndexPath indexPath, TKListViewHeaderCell headerCell, TKDataSourceGroup group) => {
                headerCell.TextLabel.TextAlignment = UITextAlignment.Center;
                headerCell.TextLabel.Text          = group.Key as NSString;
                headerCell.BackgroundColor         = UIColor.LightGray;
            });

            this.listView = new TKListView(this.View.Bounds);
            this.listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            this.listView.WeakDataSource   = this.dataSource;
            this.listView.RegisterClassForCell(new Class(typeof(CustomListCell)), "custom");
            this.View.AddSubview(this.listView);

            this.LinearLayoutSelected();
        }
Exemple #28
0
        void CreateListView()
        {
            var list = new TKListView(this.View.Bounds);

            list.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            list.RegisterClassForCell(new ObjCRuntime.Class(typeof(ListViewVariableSizeCell)), "cell");
            this.View.AddSubview(list);

            TKListViewLinearLayout layout = (TKListViewLinearLayout)list.Layout;

            layout.DynamicItemSize = true;

            list.WeakDataSource = new ListViewDataSource();
        }
Exemple #29
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			this.listViewDelegate = new NotificationsListViewDelegate(this);

			NSMutableArray types = new NSMutableArray ();
			types.Add (new NSString ("Error"));
			types.Add (new NSString ("Warning"));
			types.Add (new NSString ("Success"));
			types.Add (new NSString("Info"));

			dataSource = new TKDataSource(types);
		
			listView = new TKListView ();
			listView.Frame = this.View.Bounds;
			listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
			listView.Delegate = listViewDelegate;
			listView.WeakDataSource = dataSource;
			this.View.AddSubview (listView);

			titles = new NSMutableArray ();
			titles.Add (new NSString ("Oh no!"));
			titles.Add (new NSString ("Warning!"));
			titles.Add (new NSString ("Well done!"));
			titles.Add (new NSString ("Info."));

			messages = new NSMutableArray ();
			messages.Add (new NSString ("Change this and try again!"));
			messages.Add (new NSString ("e careful next time"));
			messages.Add (new NSString ("You successfully read this message"));
			messages.Add (new NSString ("This is TKAlert dialog"));

			colors = new NSMutableArray ();
			colors.Add(new UIColor(1f, 0f, 0.282f, 1f));
			colors.Add(new UIColor(1f, 0.733f, 0f, 1f));
			colors.Add(new UIColor(0.478f, 0.988f, 0.157f, 1f));
			colors.Add(new UIColor(0.231f, 0.678f, 1f, 1f));

			alert = new TKAlert ();
			alert.Style.ContentSeparatorWidth = 0;
			alert.Style.TitleColor = new UIColor (1f, 1f, 1f, 1f);
			alert.Style.MessageColor = new UIColor (1f, 1f, 1f, 1f);
			alert.Style.CornerRadius = 0;
			alert.Style.ShowAnimation = TKAlertAnimation.SlideFromTop;
			alert.Style.DismissAnimation = TKAlertAnimation.SlideFromTop;
			alert.Style.BackgroundStyle = TKAlertBackgroundStyle.None;
			alert.DismissMode = TKAlertDismissMode.Tap;
		}
Exemple #30
0
        public override void ViewDidLoad()
        {
            this.AddOption ("Linear", "Layout", LinearLayoutSelected);
            this.AddOption ("Grid", "Layout", GridLayoutSelected);
            this.AddOption ("Staggered", "Layout", StaggeredLayoutSelected);
            this.AddOption ("Flow",  "Layout", FlowLayoutSelected);

            this.AddOption ("Horiontal", "Orientation", HorizontalSelected);
            this.AddOption ("Vertical", "Orientation", VerticalSelected);

            this.SetSelectedOption (1, 1);

            base.ViewDidLoad ();

            dataSource = new TKDataSource ();
            dataSource.LoadDataFromJSONResource ("ListItems", "json", "items");

            string descriptor = string.Format ("category LIKE '{0}' OR category LIKE '{1}' OR category LIKE '{2}'",
                                    categories [0], categories [1], categories [2]);
            dataSource.AddFilterDescriptor (new TKDataSourceFilterDescriptor(descriptor));

            itemsCount = dataSource.Items.Length;
            dataSource.ReloadData ();
            dataSource.GroupWithKey ("category");

            dataSource.Settings.ListView.CreateCell ((TKListView listView, NSIndexPath indexPath, NSObject item) => {
                return listView.DequeueReusableCell(new NSString("custom"), indexPath) as TKListViewCell;
            });

            dataSource.Settings.ListView.InitCell ((TKListView listView, NSIndexPath indexPath, TKListViewCell cell, NSObject item) => {
                cell.ImageView.Image = UIImage.FromBundle((NSString)item.ValueForKey(new NSString("photo")));
                cell.TextLabel.Text = (NSString)item.ValueForKey(new NSString("title"));
                cell.DetailTextLabel.Text = (NSString)item.ValueForKey(new NSString("author"));
            });

            dataSource.Settings.ListView.InitHeader ((TKListView listView, NSIndexPath indexPath, TKListViewHeaderCell headerCell, TKDataSourceGroup group) => {
                headerCell.TextLabel.TextAlignment = UITextAlignment.Center;
                headerCell.TextLabel.Text = group.Key as NSString;
                headerCell.BackgroundColor = UIColor.LightGray;
            });

            this.listView = new TKListView (this.View.Bounds);
            this.listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            this.listView.WeakDataSource = this.dataSource;
            this.listView.RegisterClassForCell(new Class(typeof(CustomListCell)), "custom");
            this.View.AddSubview (this.listView);

            this.LinearLayoutSelected ();
        }
            public override TKListViewCell CellForItem(TKListView listView, NSIndexPath indexPath)
            {
                TKListViewCell cell = listView.DequeueReusableCell("cell", indexPath) as TKListViewCell;

                cell.BackgroundView.BackgroundColor = UIColor.FromWhiteAlpha(0.3f, 0.5f);
                string imageName = this.owner.photos.Items [indexPath.Row] as NSString;

                cell.ImageView.Image = new UIImage(imageName);
                cell.TextLabel.Text  = this.owner.names.Items [indexPath.Row] as NSString;
                Random r = new Random();

                cell.DetailTextLabel.Text            = this.owner.loremIpsum.RandomString(10 + r.Next(0, 16), indexPath);
                cell.DetailTextLabel.TextColor       = UIColor.White;
                ((TKView)cell.BackgroundView).Stroke = null;
                return(cell);
            }
Exemple #32
0
            public override TKListViewCell CellForItem(TKListView listView, NSIndexPath indexPath)
            {
                TKListViewCell cell      = listView.DequeueReusableCell("cell", indexPath) as TKListViewCell;
                bool           isUpdated = this.owner.IsUpdated(indexPath);

                cell.TextLabel.Text = this.owner.data [indexPath.Row];
                cell.BackgroundView.BackgroundColor = isUpdated ? new UIColor(1f, 1f, 0f, 0.4f) : UIColor.White;
                if (isUpdated)
                {
                    UIView.Animate(0.5f, () => {
                        cell.BackgroundView.Alpha = 1;
                    });
                }

                return(cell);
            }
Exemple #33
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.View.BackgroundColor = UIColor.FromRGB(239, 239, 244);

            this.Autocomplete = new TKAutoCompleteTextView(new CGRect(10, this.View.Bounds.Y + 10, this.View.Bounds.Size.Width - 10, 30));
            this.AutomaticallyAdjustsScrollViewInsets = false;

            this.Datasource = new TKDataSource();
            this.Datasource.LoadDataFromJSONResource("namesPhotos", "json", "data");
            this.Datasource.Settings.AutoComplete.CreateToken(delegate(nuint index, NSObject item) {
                TKAutoCompleteToken token = new TKAutoCompleteToken((NSString)(item.ValueForKey(new NSString("name"))));
                token.Image = UIImage.FromBundle((NSString)item.ValueForKey(new NSString("photo")));
                return(token);
            });

            TKListView listView = (TKListView)this.Autocomplete.WeakSuggestionView;

            listView.RegisterClassForCell(new Class(typeof(PersonListViewCell)), "cell");

            TKListViewGridLayout layout = new TKListViewGridLayout();

            layout.ItemAlignment = TKListViewItemAlignment.Center;
            layout.SpanCount     = 2;
            layout.ItemSize      = new CGSize(120, 150);
            layout.LineSpacing   = 20;
            layout.ItemSpacing   = 20;
            listView.Layout      = layout;

            // >> autocmp-display-mode-cs
            this.Autocomplete.DisplayMode = TKAutoCompleteDisplayMode.Tokens;
            // << autocmp-display-mode-cs

            // >> autocmp-layout-mode-cs
            this.Autocomplete.LayoutMode = TKAutoCompleteLayoutMode.Wrap;
            // << autocmp-layout-mode-cs
            this.Autocomplete.AutoresizingMask          = UIViewAutoresizing.FlexibleWidth;
            this.Autocomplete.MaximumWrapHeight         = 150;
            this.Autocomplete.WeakDataSource            = this.Datasource;
            this.Autocomplete.TextField.Placeholder     = "Enter Users";
            this.Autocomplete.NoResultsLabel.Text       = "No Users Found";
            this.Autocomplete.ImageView.Image           = UIImage.FromBundle(new NSString("search.png"));
            this.Autocomplete.MinimumCharactersToSearch = 1;
            this.Autocomplete.WeakDelegate         = autocompleteDelegate;
            this.Autocomplete.SuggestionViewHeight = this.View.Bounds.Height - this.View.Bounds.Y + 45;
            this.View.AddSubview(this.Autocomplete);
        }
Exemple #34
0
            // >> listview-should-refresh-cs
            public override bool ListViewShouldRefreshOnPull(TKListView listView)
            {
                DispatchQueue.DefaultGlobalQueue.DispatchAsync(() => {
                    Random r = new Random();
                    this.owner.newItemsCount = this.owner.UpdateData(1 + r.Next(0, 4));
                    DispatchQueue.MainQueue.DispatchAfter(new DispatchTime(DispatchTime.Now, 2 * 500000000), () => {
                        listView.DidRefreshOnPull();
                        if (this.owner.newItemsCount < 1)
                        {
                            UIAlertView alert = new UIAlertView("Pull to refresh", "No more data available!", null, "Close", null);
                            alert.Show();
                        }
                    });
                });

                return(true);
            }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            groups = new NSMutableArray();
            groups.Add(NSArray.FromStrings(new string[] { "John", "Abby" }));
            groups.Add(NSArray.FromStrings(new string[] { "Smith", "Peter", "Paula" }));

            TKListView listView = new TKListView(new CGRect(20, 20, this.View.Bounds.Size.Width - 40, this.View.Bounds.Size.Height - 40));

            listView.RegisterClassForCell(new Class(typeof(TKListViewCell)), "cell");

            listView.RegisterClassForSupplementaryView(new Class(typeof(TKListViewHeaderCell)), TKListViewElementKindSectionKey.Header, new NSString("header"));
            listView.DataSource = new ListViewDataSource(this);
            TKListViewLinearLayout layout = (TKListViewLinearLayout)listView.Layout;

            layout.HeaderReferenceSize = new CGSize(200, 22);

            this.View.AddSubview(listView);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // >> listview-feed-cs
            simpleArrayOfStrings = new NSMutableArray();
            simpleArrayOfStrings.Add(new NSString("Kristina Wolfe"));
            simpleArrayOfStrings.Add(new NSString("Freda Curtis"));
            simpleArrayOfStrings.Add(new NSString("Eva Lawson"));
            simpleArrayOfStrings.Add(new NSString("Emmett Santos"));
            simpleArrayOfStrings.Add(new NSString("Theresa Bryan"));
            simpleArrayOfStrings.Add(new NSString("Jenny Fuller"));
            simpleArrayOfStrings.Add(new NSString("Terrell Norris"));
            simpleArrayOfStrings.Add(new NSString("Eric Wheeler"));
            simpleArrayOfStrings.Add(new NSString("Julius Clayton"));
            simpleArrayOfStrings.Add(new NSString("Harry Douglas"));
            simpleArrayOfStrings.Add(new NSString("Eduardo Thomas"));
            simpleArrayOfStrings.Add(new NSString("Orlando Mathis"));
            simpleArrayOfStrings.Add(new NSString("Alfredo Thornton"));

            // << listview-feed-cs

            // >> listview-feed-ds-cs
            dataSource.ItemSource = simpleArrayOfStrings;
            // << listview-feed-ds-cs

            // >> listview-init-cs
            TKListView listView = new TKListView();

            listView.Frame            = new CGRect(0, 0, this.View.Bounds.Size.Width, this.View.Bounds.Size.Height - 20);
            listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            listView.WeakDataSource   = dataSource;
            this.View.AddSubview(listView);
            // << listview-init-cs

            // >> listview-init-selec-cs
            listView.AllowsMultipleSelection = true;
            // << listview-init-selec-cs

            // >> listview-init-reorder-cs
            listView.AllowsCellReorder = true;
            // << listview-init-reorder-cs
        }
Exemple #37
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.dataSource.LoadDataFromJSONResource("ListViewSampleData", "json", "teams");
            this.dataSource.GroupItemSourceKey = "items";
            this.dataSource.GroupWithKey("key");

            TKListView listView = new TKListView(this.View.Bounds);

            listView.AutoresizingMask  = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            listView.WeakDataSource    = dataSource;
            listView.SelectionBehavior = TKListViewSelectionBehavior.Press;
            this.View.AddSubview(listView);

            TKListViewColumnsLayout layout = (TKListViewColumnsLayout)listView.Layout;

            layout.CellAlignment       = TKListViewCellAlignment.Stretch;
            layout.ItemSize            = new CGSize(300, 44);
            layout.MinimumLineSpacing  = 0;
            layout.HeaderReferenceSize = new CGSize(100, 44);
            layout.FooterReferenceSize = new CGSize(100, 44);

            this.dataSource.Settings.ListView.InitCell(delegate(TKListView list, NSIndexPath indexPath, TKListViewCell cell, NSObject item) {
                TKDataSourceGroup group = this.dataSource.Items[indexPath.Section] as TKDataSourceGroup;
                cell.TextLabel.Text     = group.Items[indexPath.Row] as NSString;
            });

            this.dataSource.Settings.ListView.InitHeader(delegate(TKListView list, NSIndexPath indexPath, TKListViewHeaderCell headerCell, TKDataSourceGroup group) {
                headerCell.TextLabel.Text          = String.Format("{0}", group.Key);
                headerCell.TextLabel.TextAlignment = UITextAlignment.Center;
            });

            this.dataSource.Settings.ListView.InitFooter(delegate(TKListView list, NSIndexPath indexPath, TKListViewFooterCell footerCell, TKDataSourceGroup group) {
                footerCell.TextLabel.Text          = String.Format("Members count: {0}", group.Items.Length);
                footerCell.TextLabel.TextAlignment = UITextAlignment.Left;
                footerCell.TextLabel.Frame         = new CGRect(5, 10, 200, 22);
            });
        }
Exemple #38
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            this.dataSource.LoadDataFromJSONResource ("ListViewSampleData", "json", "teams");
            this.dataSource.GroupItemSourceKey = "items";
            this.dataSource.GroupWithKey ("key");

            TKListView listView = new TKListView (this.View.Bounds);
            listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            listView.WeakDataSource = dataSource;
            listView.SelectionBehavior = TKListViewSelectionBehavior.Press;
            this.View.AddSubview (listView);

            TKListViewLinearLayout layout = new TKListViewLinearLayout();
            layout.ItemSize = new CGSize (300, 44);
            layout.HeaderReferenceSize = new CGSize (100, 44);
            layout.FooterReferenceSize = new CGSize (100, 44);
            listView.Layout = layout;

            this.dataSource.Settings.ListView.InitCell (delegate (TKListView list, NSIndexPath indexPath, TKListViewCell cell, NSObject item) {
                TKDataSourceGroup group = this.dataSource.Items[indexPath.Section] as TKDataSourceGroup;
                cell.TextLabel.Text = group.Items[indexPath.Row] as NSString;
            });

            this.dataSource.Settings.ListView.InitHeader (delegate (TKListView list, NSIndexPath indexPath, TKListViewHeaderCell headerCell, TKDataSourceGroup group) {
                headerCell.TextLabel.Text = String.Format("{0}", group.Key);
                headerCell.TextLabel.TextAlignment = UITextAlignment.Center;
            });

            this.dataSource.Settings.ListView.InitFooter (delegate (TKListView list, NSIndexPath indexPath, TKListViewFooterCell footerCell, TKDataSourceGroup group) {
                footerCell.TextLabel.Text = String.Format("Members count: {0}", group.Items.Length);
                footerCell.TextLabel.TextAlignment = UITextAlignment.Left;
                footerCell.TextLabel.Frame = new CGRect(5, 10, 200, 22);
            });
        }
Exemple #39
0
        public void setupListView()
        {
            // >> datasource-listview-ui-cs
            CGRect rect = this.View.Bounds;

            rect.Inflate(0, -30);
            var listView = new TKListView(rect);

            listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            this.dataSource.SetDataSourceFor(listView);
            this.View.AddSubview(listView);
            // << datasource-listview-ui-cs

            // >> datasource-listview-cell-create-cs
            this.dataSource.Settings.ListView.CreateCell((TKListView list1, NSIndexPath indexPath, NSObject item) => {
                return(list1.DequeueReusableCell("myCustomCell", indexPath) as TKListViewCell);
            });

            this.dataSource.Settings.ListView.InitCell((TKListView list2, NSIndexPath indexPath, TKListViewCell cell, NSObject item) => {
                cell.TextLabel.Text = this.dataSource.TextFromItem(item, null);
                (cell.BackgroundView as TKView).Fill = new TKSolidFill(new UIColor(0.1f, 0.1f, 0.1f, 0.1f));
            });
            // << datasource-listview-cell-create-cs
        }
 public override void DidHighlightItemAtIndexPath(TKListView listView, NSIndexPath indexPath)
 {
     Console.WriteLine ("Did highlight item at row {0}", this.owner.dataSource.Items [indexPath.Row]);
     TKListViewCell cell = listView.CellForItem (indexPath);
     if (!cell.Selected && listView.SelectionBehavior == TKListViewSelectionBehavior.LongPress)
     {
         cell.SelectedBackgroundView.Hidden = true;
     }
 }
 public override void DidSelectItemAtIndexPath(TKListView listView, NSIndexPath indexPath)
 {
     this.owner.label.Text = string.Format("Selected: {0}", this.owner.dataSource.Items[indexPath.Row]);
     Console.WriteLine ("Did select item at row {0}", this.owner.dataSource.Items [indexPath.Row]);
     TKListViewCell cell = listView.CellForItem (indexPath);
     if (cell != null) {
         cell.SelectedBackgroundView.Hidden = false;
     }
 }
 public override TKListViewCell CellForItem(TKListView listView, NSIndexPath indexPath)
 {
     TKListViewCell cell = (TKListViewCell)listView.DequeueReusableCell ("cell", indexPath);
     NSString imageName = (NSString)this.owner.Photos.Items [indexPath.Row];
     cell.ImageView.Image = new UIImage (imageName);
     cell.TextLabel.Text = (NSString)this.owner.Names.Items [indexPath.Row];
     return cell;
 }
 public override void WillReorderItemAtIndexPath(TKListView listView, NSIndexPath indexPath)
 {
     TKListViewCell cell = listView.CellForItem(indexPath);
     cell.BackgroundView.BackgroundColor = UIColor.Yellow;
 }
Exemple #44
0
		public override void DidSelectItemAtIndexPath (TKListView listView, NSIndexPath indexPath)
		{
			if (listView.Tag == 0) 
			{
				owner.alert.Style.ShowAnimation = (TKAlertAnimation)indexPath.Row;
			} 
			else {
				owner.alert.Style.DismissAnimation = (TKAlertAnimation)indexPath.Row;
			}
		}
 public override int NumberOfItemsInSection(TKListView listView, int section)
 {
     return items.Count;
 }
            public override TKListViewCell CellForItem(TKListView listView, NSIndexPath indexPath)
            {
                TKListViewCell cell = listView.DequeueReusableCell ("cell", indexPath) as TKListViewCell;
                bool isUpdated = this.owner.IsUpdated (indexPath);
                cell.TextLabel.Text = this.owner.data [indexPath.Row];
                cell.BackgroundView.BackgroundColor = isUpdated ? new UIColor (1f, 1f, 0f, 0.4f) : UIColor.White;
                if (isUpdated) {
                    UIView.Animate (0.5f, () => {
                        cell.BackgroundView.Alpha = 1;
                    });
                }

                return cell;
            }
            public override bool ShouldLoadMoreDataAtIndexPath(TKListView listView, NSIndexPath indexPath)
            {
                DispatchQueue.DefaultGlobalQueue.DispatchAsync (() => {
                    this.owner.lastRetrievedDataIndex = Math.Min(this.owner.names.Items.Length, this.owner.lastRetrievedDataIndex + 10);
                    DispatchQueue.MainQueue.DispatchAfter(new DispatchTime(DispatchTime.Now, 2 * 400000000), new Action(delegate {
                        if (this.owner.names.Items.Length == this.owner.lastRetrievedDataIndex) {
                            listView.LoadOnDemandMode = TKListViewLoadOnDemandMode.None;
                        }
                        listView.DidLoadDataOnDemand();
                    }));
                });

                return true;
            }
 public override int NumberOfItemsInSection(TKListView listView, int section)
 {
     return owner.lastRetrievedDataIndex;
 }
            public override TKListViewCell CellForItem(TKListView listView, NSIndexPath indexPath)
            {
                TKListViewCell cell = listView.DequeueLoadOnDemandCell (indexPath);

                if (cell == null) {
                    cell = listView.DequeueReusableCell ("cell", indexPath) as TKListViewCell;
                    cell.ImageView.Image = new UIImage (this.owner.photos.Items [indexPath.Row] as NSString);
                    cell.TextLabel.Text = this.owner.names.Items [indexPath.Row] as NSString;
                    Random r = new Random ();
                    cell.DetailTextLabel.Text = this.owner.loremIpsum.RandomString (10 + r.Next (0, 16), indexPath);
                    cell.DetailTextLabel.TextColor = UIColor.White;
                }

                cell.BackgroundView.BackgroundColor = UIColor.FromWhiteAlpha (0.3f, 0.5f);
                ((TKView)cell.BackgroundView).Stroke = null;

                return cell;
            }
Exemple #50
0
 public override void DidSwipeCell(TKListView listView, TKListViewCell cell, NSIndexPath indexPath, CGPoint offset)
 {
     this.owner.AnimateButtonInCell (cell, offset);
 }
Exemple #51
0
 public override void DidFinishSwipeCell(TKListView listView, TKListViewCell cell, NSIndexPath indexPath, CGPoint offset)
 {
     Console.WriteLine ("Did swipe cell at index: {0}", indexPath.Row);
 }
            public override bool ListViewShouldRefreshOnPull(TKListView listView)
            {
                DispatchQueue.DefaultGlobalQueue.DispatchAsync (() => {
                    Random r = new Random();
                    this.owner.newItemsCount = this.owner.UpdateData(1 + r.Next(0, 4));
                    DispatchQueue.MainQueue.DispatchAfter(new DispatchTime(DispatchTime.Now, 2 * 500000000), () => {
                        listView.DidRefreshOnPull();
                        if (this.owner.newItemsCount < 1) {
                            UIAlertView alert = new UIAlertView("Pull to refresh", "No more data available!",null,"Close",null);
                            alert.Show();
                        }
                    });
                });

                return true;
            }
 public override TKListViewCell CellForItem(TKListView listView, NSIndexPath indexPath)
 {
     var cell = listView.DequeueReusableCell ("cell", indexPath) as ListViewVariableSizeCell;
     cell.label.Text = this.items[indexPath.Row];
     return cell;
 }
 public override void DidPull(TKListView listView, nfloat offset)
 {
     listView.PullToRefreshView.Alpha = (float)Math.Min (offset / listView.PullToRefreshTreshold, 1.0f);
 }
Exemple #55
0
		public override void ViewDidLoad ()
		{
			AddOption ("Show Alert", Show);

			base.ViewDidLoad ();

			this.listViewDelegate = new ListViewDelegate (this);

			alert = new TKAlert ();
			alert.Title = "Animations";
			alert.Style.BackgroundStyle = TKAlertBackgroundStyle.Blur;
			alert.AddActionWithTitle("Close", (TKAlert al, TKAlertAction action) => true);

			showAnimations = new NSMutableArray ();
			showAnimations.Add (new NSString ("Scale in"));
			showAnimations.Add (new NSString ("Fade in"));
			showAnimations.Add (new NSString ("Slide from left"));
			showAnimations.Add (new NSString ("Slide from top"));
			showAnimations.Add (new NSString ("Slide from right"));
			showAnimations.Add (new NSString ("Slide from bottom"));

			dismissAnimations = new NSMutableArray ();
			dismissAnimations.Add (new NSString ("Scale out"));
			dismissAnimations.Add (new NSString ("Fade out"));
			dismissAnimations.Add (new NSString ("Slide to left"));
			dismissAnimations.Add (new NSString ("Slide to top"));
			dismissAnimations.Add (new NSString ("Slide to right"));
			dismissAnimations.Add (new NSString ("Slide to bottom"));

			appearAnimations = new TKDataSource (showAnimations);
			hideAnimations = new TKDataSource (dismissAnimations);

			appearAnimationsList = new TKListView ();
			appearAnimationsList.WeakDataSource = appearAnimations;
			appearAnimationsList.Delegate = listViewDelegate;
			appearAnimationsList.Tag = 0;
			appearAnimationsList.AutoresizingMask = UIViewAutoresizing.None;
			this.View.AddSubview (appearAnimationsList);

			NSIndexPath selected = NSIndexPath.FromItemSection (3, 0);
			appearAnimationsList.SelectItem (selected, true, UICollectionViewScrollPosition.None);

			hideAnimationsList = new TKListView ();
			hideAnimationsList.WeakDataSource = hideAnimations;
			hideAnimationsList.Tag = 1;
			hideAnimationsList.Delegate = listViewDelegate;
			hideAnimationsList.AutoresizingMask = UIViewAutoresizing.None;
			this.View.AddSubview (hideAnimationsList);

			selected = NSIndexPath.FromItemSection (5, 0);
			hideAnimationsList.SelectItem (selected, true, UICollectionViewScrollPosition.None);

			appearLabel = new UILabel ();
			appearLabel.Text = "Show animation:";
			appearLabel.TextColor = new UIColor (0f, 0f, 0f, 1f);
			appearLabel.Font = UIFont.SystemFontOfSize (12);
			appearLabel.TextAlignment = UITextAlignment.Center;
			this.View.AddSubview (appearLabel);

			hideLabel = new UILabel ();
			hideLabel.Text = "Hide animation:";
			hideLabel.TextColor = new UIColor (0f, 0f, 0f, 1f);
			hideLabel.Font = UIFont.SystemFontOfSize (12);
			hideLabel.TextAlignment = UITextAlignment.Center;
			this.View.AddSubview (hideLabel);
		}
 public override int NumberOfItemsInSection(TKListView listView, int section)
 {
     return this.owner.data.Count;
 }
 public override void DidReorderItemFromIndexPath(TKListView listView, NSIndexPath originalIndexPath, NSIndexPath targetIndexPath)
 {
     TKListViewCell cell = listView.CellForItem(originalIndexPath);
     cell.BackgroundView.BackgroundColor = UIColor.White;
     this.owner.dataSource.DidReorderItemFromTo (listView, originalIndexPath, targetIndexPath);
 }
 public override void DidUnhighlightItemAtIndexPath(TKListView listView, NSIndexPath indexPath)
 {
     Console.WriteLine ("Did unhighlight item at row {0}", this.owner.dataSource.Items [indexPath.Row]);
 }
Exemple #59
0
 public override CGSize SizeForItem(TKListView listView, TKListViewLinearLayout layout, NSIndexPath indexPath)
 {
     if (layout.ScrollDirection == TKListViewScrollDirection.Vertical) {
         return new CGSize(100, sizes[indexPath.Row]);
     }
     else {
         return new CGSize(sizes[indexPath.Row], 100);
     }
 }
 public override int NumberOfItemsInSection(TKListView listView, int section)
 {
     return this.owner.Names.Items.Length;
 }