Commit 5e4758be by Daniel Dahan

Merge branch 'Button-example-polish' into development

parents ca1719c3 1028e7f0
...@@ -41,29 +41,5 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -41,29 +41,5 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
window!.rootViewController = ViewController() window!.rootViewController = ViewController()
window!.makeKeyAndVisible() window!.makeKeyAndVisible()
} }
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
} }
...@@ -31,21 +31,51 @@ ...@@ -31,21 +31,51 @@
import UIKit import UIKit
import Material import Material
struct ButtonLayout {
struct Flat {
static let width: CGFloat = 120
static let height: CGFloat = 36
static let offsetY: CGFloat = -150
}
struct Raised {
static let width: CGFloat = 150
static let height: CGFloat = 36
static let offsetY: CGFloat = -75
}
struct Fab {
static let diameter: CGFloat = 48
}
struct Icon {
static let width: CGFloat = 120
static let height: CGFloat = 48
static let offsetY: CGFloat = 75
}
}
class ViewController: UIViewController { class ViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.white prepareView()
prepareFlatButton() prepareFlatButton()
prepareRaisedButton() prepareRaisedButton()
prepareFabButton() prepareFabButton()
prepareIconButton() prepareIconButton()
} }
private func prepareView() {
view.backgroundColor = Color.white
}
private func prepareFlatButton() { private func prepareFlatButton() {
let button = FlatButton(title: "Flat Button", titleColor: Color.blue.base) let button = FlatButton(title: "Flat Button", titleColor: Color.blue.base)
view.layout(button).width(120).height(36).center(offsetY: -150) view.layout(button)
.width(ButtonLayout.Flat.width)
.height(ButtonLayout.Flat.height)
.center(offsetY: ButtonLayout.Flat.offsetY)
} }
private func prepareRaisedButton() { private func prepareRaisedButton() {
...@@ -53,19 +83,28 @@ class ViewController: UIViewController { ...@@ -53,19 +83,28 @@ class ViewController: UIViewController {
button.pulseColor = Color.white button.pulseColor = Color.white
button.backgroundColor = Color.blue.base button.backgroundColor = Color.blue.base
view.layout(button).width(150).height(36).center(offsetY: -75) view.layout(button)
.width(ButtonLayout.Raised.width)
.height(ButtonLayout.Raised.height)
.center(offsetY: ButtonLayout.Raised.offsetY)
} }
private func prepareFabButton() { private func prepareFabButton() {
let button = FabButton(image: Icon.cm.add, tintColor: Color.white) let button = FabButton(image: Icon.cm.add, tintColor: Color.white)
view.layout(button).width(48).height(48).center() view.layout(button)
.width(ButtonLayout.Fab.diameter)
.height(ButtonLayout.Fab.diameter)
.center()
} }
private func prepareIconButton() { private func prepareIconButton() {
let button = IconButton(image: Icon.cm.search, tintColor: Color.blue.base) let button = IconButton(image: Icon.cm.search, tintColor: Color.blue.base)
view.layout(button).width(120).height(48).center(offsetY: 75) view.layout(button)
.width(ButtonLayout.Icon.width)
.height(ButtonLayout.Icon.height)
.center(offsetY: ButtonLayout.Icon.offsetY)
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment