public LibraryDataSource(List <Book> bookList, LibraryViewController parentVC)
        {
            this.BookList = bookList;
            this.parentVC = parentVC;

            if (BookList != null && BookList.Count > 0)
            {
                // Sort books based on current setting
                BookList = SortBooks(bookList);

                // Update dictionary
                indexDictionary = new Dictionary <NSIndexPath, LibraryBookView>();
            }
        }
Esempio n. 2
0
        public LibraryBookView(Book book, LibraryViewController parentVC) : base(new CGRect(0, 0, 280, 280))
        {
            this.LibraryBook = book;

            this.BackgroundColor     = UIColor.White;
            this.Layer.ShadowColor   = UIColor.Black.CGColor;
            this.Layer.ShadowOpacity = 0.3f;
            this.Layer.ShadowRadius  = 2f;
            this.Layer.ShadowOffset  = new CGSize(5f, 5f);

            // imageView
            imageView       = new UIImageView();
            imageView.Frame = new CGRect(0, 0, this.Frame.Width, 150);
            this.AddSubview(imageView);

            if (!String.IsNullOrEmpty(LibraryBook.LargeImageURL))
            {
                // imageSpinner
                imageSpinner        = eBriefingAppearance.GenerateBounceSpinner();
                imageSpinner.Center = imageView.Center;
                this.AddSubview(imageSpinner);

                // Download image
                bool exist = FileDownloader.Download(LibraryBook.LargeImageURL, parentVC);
                if (exist)
                {
                    bool outDated = false;
                    var  item     = BooksOnServerAccessor.GetBook(LibraryBook.ID);
                    if (item != null)
                    {
                        if (item.ImageVersion < LibraryBook.ImageVersion)
                        {
                            DownloadedFilesCache.RemoveFile(item.LargeImageURL);
                            DownloadedFilesCache.RemoveFile(item.SmallImageURL);

                            outDated = true;
                        }
                    }

                    if (outDated)
                    {
                        FileDownloader.Download(LibraryBook.LargeImageURL, parentVC, true);
                    }
                    else
                    {
                        UpdateImage(LibraryBook.LargeImageURL);
                    }
                }
            }

            // titleLabel
            UILabel titleLabel = eBriefingAppearance.GenerateLabel(16);

            titleLabel.Frame         = new CGRect(10, imageView.Frame.Bottom + 8, 260, 21);
            titleLabel.Lines         = 2;
            titleLabel.LineBreakMode = UILineBreakMode.WordWrap;
            titleLabel.Text          = book.Title;
            titleLabel.SizeToFit();
            titleLabel.Frame = new CGRect(10, titleLabel.Frame.Y, 260, titleLabel.Frame.Height);
            this.AddSubview(titleLabel);

            // bookInfoView
            BookInfoView bookInfoView = new BookInfoView("0", "0", "0", book.PageCount.ToString(), false, false, this.Frame.Width - 30);

            bookInfoView.Frame = new CGRect(10, this.Frame.Bottom - 44, bookInfoView.Frame.Width, bookInfoView.Frame.Height);
            this.AddSubview(bookInfoView);

            // downloadButton
            UIButton downloadButton = UIButton.FromType(UIButtonType.Custom);

            downloadButton.Font = eBriefingAppearance.ThemeBoldFont(14);
            downloadButton.SetTitleColor(eBriefingAppearance.Color("37b878"), UIControlState.Normal);
            downloadButton.SetTitleColor(UIColor.White, UIControlState.Highlighted);
            downloadButton.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/green_unfilled.png").CreateResizableImage(new UIEdgeInsets(15f, 14f, 15f, 14f)), UIControlState.Normal);
            downloadButton.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/green_filled.png").CreateResizableImage(new UIEdgeInsets(15f, 14f, 15f, 14f)), UIControlState.Highlighted);
            downloadButton.Frame = new CGRect(this.Center.X - 65, bookInfoView.Frame.Top - 28, 130, downloadButton.CurrentBackgroundImage.Size.Height);
            downloadButton.SetTitle("DOWNLOAD", UIControlState.Normal);
            downloadButton.TouchUpInside += HandleDownloadButtonTouchUpInside;
            this.AddSubview(downloadButton);
        }
Esempio n. 3
0
        private void InitializeTabBarController()
        {
            // My Books
            vc1                          = new MyBooksViewController();
            vc1.Title                    = StringRef.myBooks;
            vc1.RefreshEvent            += HandleRefreshEvent1;
            vc1.UpdateUpdatesBadgeEvent += HandleUpdateUpdatesBadgeEvent;
            vc1.UpdateMyBooksBadgeEvent += HandleUpdateMyBooksBadgeEvent;

            // Favorite
            vc2                          = new FavoriteViewController();
            vc2.Title                    = StringRef.favorites;
            vc2.RefreshEvent            += HandleRefreshEvent2;
            vc2.UpdateUpdatesBadgeEvent += HandleUpdateUpdatesBadgeEvent;

            // Updates
            vc3                          = new UpdateViewController();
            vc3.Title                    = StringRef.updates;
            vc3.RefreshEvent            += HandleRefreshEvent3;
            vc3.ClearUpdatesBadgeEvent  += HandleClearUpdatesBadgeEvent;
            vc3.UpdateUpdatesBadgeEvent += HandleUpdateUpdatesBadgeEvent;
            vc3.UpdateMyBooksBadgeEvent += HandleUpdateMyBooksBadgeEvent;

            // Available
            vc4                            = new LibraryViewController();
            vc4.Title                      = StringRef.available;
            vc4.RefreshEvent              += HandleRefreshEvent4;
            vc4.OpenBookshelfEvent        += HandleOpenBookshelfEvent;
            vc4.UpdateUpdatesBadgeEvent   += HandleUpdateUpdatesBadgeEvent;
            vc4.UpdateMyBooksBadgeEvent   += HandleUpdateMyBooksBadgeEvent;
            vc4.UpdateAvailableBadgeEvent += HandleUpdateAvailableBadgeEvent;
            vc4.UpdateTabLocationEvent    += HandleUpdateTabLocationEvent;

            // tabBarController
            tabBarController = new UITabBarController();
            tabBarController.TabBar.Translucent      = false;
            tabBarController.ViewControllerSelected += HandleViewControllerSelected;
            tabBarController.SetViewControllers(new UIViewController[] {
                vc1,
                vc2,
                vc3,
                vc4
            }, false);

            vc1.TabBarItem.Title = StringRef.myBooks;
            vc1.TabBarItem.Image = UIImage.FromBundle("Assets/Icons/tab0.png");
            vc1.TabBarItem.Tag   = 0;

            vc2.TabBarItem.Title = StringRef.favorites;
            vc2.TabBarItem.Image = UIImage.FromBundle("Assets/Icons/tab1.png");
            vc2.TabBarItem.Tag   = 1;

            vc3.TabBarItem.Title = StringRef.updates;
            vc3.TabBarItem.Image = UIImage.FromBundle("Assets/Icons/tab2.png");
            vc3.TabBarItem.Tag   = 2;

            vc4.TabBarItem.Title = StringRef.available;
            vc4.TabBarItem.Image = UIImage.FromBundle("Assets/Icons/tab3.png");
            vc4.TabBarItem.Tag   = 3;

            tabBarController.View.Hidden = true;
            this.View.AddSubview(tabBarController.View);

            List <Book> dBooks = BooksOnDeviceAccessor.GetBooks();

            if (dBooks != null)
            {
                tabBarController.SelectedIndex = 0;
            }
            else
            {
                tabBarController.SelectedIndex = 3;
            }
        }