From 216eb91a2234877640beef8ed62504c310faacd3 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Wed, 8 Feb 2017 13:56:19 -0500 Subject: [PATCH] welcome controller button --- .../Controller/Others/WelcomeController.swift | 46 ++++++++++++++++++- Kiwix-iOS/Info.plist | 2 +- Kiwix-iOS/Storyboard/Search.storyboard | 12 ++--- Kiwix-iOS/Storyboard/Welcome.storyboard | 44 ++++++++++-------- .../xcdebugger/Breakpoints_v2.xcbkptlist | 18 -------- Kiwix/libkiwix/ZimReader.mm | 4 +- 6 files changed, 78 insertions(+), 48 deletions(-) diff --git a/Kiwix-iOS/Controller/Others/WelcomeController.swift b/Kiwix-iOS/Controller/Others/WelcomeController.swift index efeedf33..cb13e03d 100644 --- a/Kiwix-iOS/Controller/Others/WelcomeController.swift +++ b/Kiwix-iOS/Controller/Others/WelcomeController.swift @@ -9,8 +9,50 @@ import UIKit class WelcomeController: UIViewController { + @IBOutlet weak var stackView: UIStackView! - // place holder for adding stuff like resume last read, suggestions in welcome screen - // maybe this class one day will become tabs controller + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + + let button = OpenLibraryButton() + stackView.addArrangedSubview(button) + } } + +class OpenLibraryButton: UIButton { + init() { + super.init(frame: CGRect.zero) + let style = NSMutableParagraphStyle() + style.alignment = .center + let attributedTitle = NSMutableAttributedString(string: "Open Library\n", attributes: [ + NSForegroundColorAttributeName: UIColor.white, + NSFontAttributeName: UIFont.systemFont(ofSize: 17, weight: UIFontWeightMedium), + NSParagraphStyleAttributeName: style + ] + ) + let attributedSubtitle = NSMutableAttributedString(string: "Download or import a book", attributes: [ + NSForegroundColorAttributeName: UIColor.white, + NSFontAttributeName: UIFont.systemFont(ofSize: 13, weight: UIFontWeightRegular), + NSParagraphStyleAttributeName: style + ]) + attributedTitle.append(attributedSubtitle) + + titleLabel?.numberOfLines = 0 + setAttributedTitle(attributedTitle, for: UIControlState.normal) + setTitleColor(UIColor.white, for: UIControlState.normal) + layer.cornerRadius = 10.0 + backgroundColor = UIColor.blue + } + + override var isHighlighted: Bool { + didSet { + backgroundColor = isHighlighted ? UIColor.lightGray : UIColor.orange + } + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist index 9204336d..e5b46407 100644 --- a/Kiwix-iOS/Info.plist +++ b/Kiwix-iOS/Info.plist @@ -57,7 +57,7 @@ NSAppTransportSecurity NSAllowsArbitraryLoads - + NSExceptionDomains kiwix.org diff --git a/Kiwix-iOS/Storyboard/Search.storyboard b/Kiwix-iOS/Storyboard/Search.storyboard index 9c51eed3..92ab40a4 100644 --- a/Kiwix-iOS/Storyboard/Search.storyboard +++ b/Kiwix-iOS/Storyboard/Search.storyboard @@ -1,11 +1,11 @@ - + - + @@ -31,7 +31,7 @@ - +