Skip to content

Commit

Permalink
adds menu vc, changes color theme, adds geobackground image, credits …
Browse files Browse the repository at this point in the history
…added to README
  • Loading branch information
spacedrabbit committed Aug 22, 2016
1 parent 6fa432e commit 01d9ab0
Show file tree
Hide file tree
Showing 11 changed files with 169 additions and 31 deletions.
4 changes: 4 additions & 0 deletions CatPColoralettes.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
1441546C1D6B99AE00BA03D0 /* MenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1441546B1D6B99AE00BA03D0 /* MenuViewController.swift */; };
144334C01D690ABC00E2F511 /* SimpleHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 144334BF1D690ABC00E2F511 /* SimpleHeaderView.swift */; };
144334C51D690B6700E2F511 /* FloatingAddButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 144334C41D690B6700E2F511 /* FloatingAddButton.swift */; };
1466AE0F1D661EA2006D072E /* ExpandingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1466AE0E1D661EA2006D072E /* ExpandingView.swift */; };
Expand All @@ -26,6 +27,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
1441546B1D6B99AE00BA03D0 /* MenuViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuViewController.swift; sourceTree = "<group>"; };
144334BF1D690ABC00E2F511 /* SimpleHeaderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SimpleHeaderView.swift; sourceTree = "<group>"; };
144334C41D690B6700E2F511 /* FloatingAddButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FloatingAddButton.swift; sourceTree = "<group>"; };
1466AE0E1D661EA2006D072E /* ExpandingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExpandingView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -72,6 +74,7 @@
isa = PBXGroup;
children = (
14C491261D6610CC00390756 /* PaletteViewController.swift */,
1441546B1D6B99AE00BA03D0 /* MenuViewController.swift */,
);
name = "View Controllers";
sourceTree = "<group>";
Expand Down Expand Up @@ -279,6 +282,7 @@
1466AE151D67FD4C006D072E /* ColorPalette.swift in Sources */,
14C491271D6610CC00390756 /* PaletteViewController.swift in Sources */,
144334C01D690ABC00E2F511 /* SimpleHeaderView.swift in Sources */,
1441546C1D6B99AE00BA03D0 /* MenuViewController.swift in Sources */,
14C491161D660F1A00390756 /* ViewController.swift in Sources */,
14D3BE241D6A2EAD0024A9D8 /* SimpleTableTitleView.swift in Sources */,
1466AE0F1D661EA2006D072E /* ExpandingView.swift in Sources */,
Expand Down
5 changes: 3 additions & 2 deletions CatPColoralettes/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let rootVC = PaletteViewController()
let navigationController: UINavigationController = UINavigationController(rootViewController: rootVC)
navigationController.navigationBar.barTintColor = AppColors.DefaultBackground
navigationController.navigationBar.barTintColor = AppColors.LightGeoBackgroundTheme
navigationController.navigationBar.titleTextAttributes = [
NSForegroundColorAttributeName : AppColors.DefaultTitleText,
NSFontAttributeName : AppFonts.Header
Expand All @@ -29,10 +29,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// TODO: update background on menu
// TODO: test with background image and adjust parallax settings
let slidingNavigationMenu: RESideMenu = RESideMenu(contentViewController: navigationController,
leftMenuViewController: ViewController(),
leftMenuViewController: MenuViewController(),
rightMenuViewController: ViewController())
slidingNavigationMenu.bouncesHorizontally = false
slidingNavigationMenu.animationDuration = 0.25
slidingNavigationMenu.backgroundImage = UIImage(named: "geo_background")
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window?.rootViewController = slidingNavigationMenu //navigationController
self.window?.makeKeyAndVisible()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "geo_background@2x.jpeg",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "geo_background@3x.jpg",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions CatPColoralettes/Common/Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,22 @@ import UIKit
internal struct AppColors {
internal static let DefaultBackground: UIColor = hexStringToUIColor("3A233E")
internal static let DefaultTitleText: UIColor = hexStringToUIColor("F6F6F7")
internal static let DarkGeoBackgroundTheme: UIColor = hexStringToUIColor("95756F")
internal static let LightGeoBackgroundTheme: UIColor = UIColor(red: (122.0/255.0), green: (93.0/255.0), blue: (125.0/255.0), alpha: 1.0)
internal static let Clear: UIColor = UIColor.clearColor()
}

internal struct AppFonts {
internal static let Header: UIFont = UIFont.systemFontOfSize(24.0)
internal static let SectionTitle: UIFont = UIFont.systemFontOfSize(20.0, weight: UIFontWeightMedium)
internal static let MenuButtonText: UIFont = UIFont.systemFontOfSize(24.0, weight: UIFontWeightMedium)
}

internal struct AppStrings {
internal static let PaletteVCTile: String = "Palettes"
internal static let GradientsTitle: String = "Gradients"
internal static let ProfileTitle: String = "Profile"
internal static let SettingsTitle: String = "Settings"
}


Expand Down
111 changes: 111 additions & 0 deletions CatPColoralettes/MenuViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
//
// MenuViewController.swift
// CatPColoralettes
//
// Created by Louis Tur on 8/22/16.
// Copyright © 2016 catthoughts. All rights reserved.
//

import UIKit
import RESideMenu
import SnapKit

class MenuViewController: UIViewController {
private static let LeftMargin: CGFloat = 24.0
private static let VerticalMargin: CGFloat = 16.0
private static let TopOffsetMultiplier: CGFloat = 0.25

// ---------------------------------------------------------------- //
// MARK: - View Lifecycle
override func viewDidLoad() {
super.viewDidLoad()

self.setupViewHierarchy()
self.configureConstraints()
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}


// ---------------------------------------------------------------- //
// MARK: - Setup
private func configureConstraints() {
self.containerView.snp_makeConstraints { (make) in
make.left.right.equalTo(self.view)
make.top.equalTo(self.view.snp_top).offset(self.view.frame.height * MenuViewController.TopOffsetMultiplier)
}

self.palettesButton.snp_makeConstraints { (make) in
make.top.equalTo(containerView)
make.left.equalTo(containerView).offset(MenuViewController.LeftMargin)
}

self.gradientsButton.snp_makeConstraints { (make) in
make.left.equalTo(containerView).offset(MenuViewController.LeftMargin)
make.top.equalTo(self.palettesButton.snp_bottom).offset(MenuViewController.VerticalMargin)
}

self.settingsButton.snp_makeConstraints { (make) in
make.left.equalTo(containerView).offset(MenuViewController.LeftMargin)
make.top.equalTo(self.gradientsButton.snp_bottom).offset(MenuViewController.VerticalMargin)
}

self.profileButton.snp_makeConstraints { (make) in
make.left.equalTo(containerView).offset(MenuViewController.LeftMargin)
make.top.equalTo(self.settingsButton.snp_bottom).offset(MenuViewController.VerticalMargin)
make.bottom.equalTo(containerView)
}
}

private func setupViewHierarchy() {
self.view.addSubview(containerView)
self.view.backgroundColor = AppColors.Clear

self.containerView.addSubview(palettesButton)
self.containerView.addSubview(gradientsButton)
self.containerView.addSubview(settingsButton)
self.containerView.addSubview(profileButton)
}

override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent
}

// ---------------------------------------------------------------- //
// MARK: - Lazy Instances
internal lazy var containerView: UIView = UIView()

internal lazy var palettesButton: UIButton = {
let button: UIButton = UIButton()
button.setTitle(AppStrings.PaletteVCTile, forState: .Normal)
button.titleLabel?.font = AppFonts.MenuButtonText
button.titleLabel?.textColor = AppColors.DefaultTitleText
return button
}()

internal lazy var gradientsButton: UIButton = {
let button: UIButton = UIButton()
button.setTitle(AppStrings.GradientsTitle, forState: .Normal)
button.titleLabel?.font = AppFonts.MenuButtonText
button.titleLabel?.textColor = AppColors.DefaultTitleText
return button
}()

internal lazy var settingsButton: UIButton = {
let button: UIButton = UIButton()
button.setTitle(AppStrings.SettingsTitle, forState: .Normal)
button.titleLabel?.font = AppFonts.MenuButtonText
button.titleLabel?.textColor = AppColors.DefaultTitleText
return button
}()

internal lazy var profileButton: UIButton = {
let button: UIButton = UIButton()
button.setTitle(AppStrings.ProfileTitle, forState: .Normal)
button.titleLabel?.font = AppFonts.MenuButtonText
button.titleLabel?.textColor = AppColors.DefaultTitleText
return button
}()
}
30 changes: 4 additions & 26 deletions CatPColoralettes/PaletteViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,13 @@ internal class PaletteViewController: UIViewController, UITableViewDelegate, UIT
}

private func adjustSubclass() {
self.view.backgroundColor = AppColors.DefaultBackground
// self.title = AppStrings.PaletteVCTile

self.view.backgroundColor = AppColors.LightGeoBackgroundTheme
self.tableView.dataSource = self
self.tableView.delegate = self
self.tableView.estimatedRowHeight = 80.0
self.tableView.rowHeight = UITableViewAutomaticDimension
self.tableView.backgroundColor = AppColors.DefaultBackground
self.tableView.separatorColor = UIColor.clearColor()
self.tableView.backgroundColor = AppColors.LightGeoBackgroundTheme
self.tableView.separatorColor = AppColors.Clear
// TODO: adjust separator insets
}

Expand Down Expand Up @@ -161,8 +159,6 @@ internal class PaletteViewController: UIViewController, UITableViewDelegate, UIT
// ---------------------------------------------------------------- //
// MARK: - UITableViewDelegate
internal func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
//TODO: - needs reimplementation for smooth animations, i think..

let selectedCell: SimpleExpandingCell = tableView.cellForRowAtIndexPath(indexPath) as! SimpleExpandingCell
selectedCell.simulateTap()
self.tableView.reloadData()
Expand All @@ -174,7 +170,7 @@ internal class PaletteViewController: UIViewController, UITableViewDelegate, UIT
internal func scrollViewDidScroll(scrollView: UIScrollView) {

if self.timeSinceLastDrawUpdate >= 0.1 {
self.updateFloatingButtonPosition(scrollView.contentOffset.y)

}
else {
// note: tried adding in a time limit to see if that was what was causing the flashing, but it seems as though its
Expand All @@ -201,24 +197,6 @@ internal class PaletteViewController: UIViewController, UITableViewDelegate, UIT
print("Velocity ending: \(velocity)") // pts/sec I think... negative indicates scrolling from bottom -> top
}

private func updateFloatingButtonPosition(deltaY: CGFloat) {

let currentFloatingBottomConstraintOffset: CGFloat = self.view.frame.height - (self.floatingPlusButton.frame.origin.y + self.floatingPlusButton.frame.height)
if self.tableView.contentOffset.y >= -44.0 { // scrolling down
UIView.animateWithDuration(0.0, delay: 0.0, options: .BeginFromCurrentState, animations: {
self.floatingPlusButtonBottomConstraint?.updateOffset(self.visibleButtonOffset)
}, completion: nil)
let newYOrigin = self.view.frame.height - (self.floatingPlusButton.frame.height + 40.0)
self.floatingPlusButton.frame = CGRectMake(self.floatingPlusButton.frame.origin.x, newYOrigin, self.floatingPlusButton.frame.width, self.floatingPlusButton.frame.height)
}
else if self.tableView.contentOffset.y < -44.0 { // scrolling up
let originalRect = self.floatingPlusButton.frame
UIView.animateWithDuration(0.0, delay: 0.0, options: .BeginFromCurrentState, animations: {
self.floatingPlusButton.frame = CGRectMake(originalRect.origin.x, originalRect.origin.y - (currentFloatingBottomConstraintOffset + deltaY), originalRect.size.width, originalRect.size.height)
}, completion: nil)
}

}

// ---------------------------------------------------------------- //
// MARK: - Actions
Expand Down
2 changes: 1 addition & 1 deletion CatPColoralettes/SimpleExpandingCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal class SimpleExpandingCell: UITableViewCell {
private func adjustSubclass() {
// make any changes to subclass properties
self.selectionStyle = .None
self.backgroundColor = AppColors.DefaultBackground
self.backgroundColor = AppColors.LightGeoBackgroundTheme
}

internal func simulateTap() {
Expand Down
2 changes: 1 addition & 1 deletion CatPColoralettes/SimpleTableTitleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ internal class SimpleTableTitleView: UIView {

private func setupViewHierarchy() {
self.addSubview(titleLabel)
self.backgroundColor = AppColors.DefaultBackground
self.backgroundColor = AppColors.LightGeoBackgroundTheme
}

internal lazy var titleLabel: UILabel = {
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,19 @@

8/21 - Notes on 734d45f 'going back to the "jumpy"'

...animation. it looks less broken than the attempt at reloading following the animation block. Further, the table refresh should be obvious following the cell animation since both are executing on the main queue and thus in serial. But now that I think about it, the examples in my mind of apps that have this feature (the tap to expand) all do so in an instataneous manner.
...animation. it looks less broken than the attempt at reloading following the animation block. Further, the table refresh should be obvious following the cell animation since both are executing on the main queue and thus in serial. But now that I think about it, the examples in my mind of apps that have this feature (the tap to expand) all do so in an instataneous manner.


-------------------------
### Credits:

- Image Assets
- Geometric Background Image
- https://dribbble.com/shots/1414523-Free-Polygon-Backgrounds-V1 by Ahmed Abbas (https://dribbble.com/Ahmedeabbas)
- Icons
- Palette:
- Plus Icon: https://thenounproject.com/term/add/25957/ by Mr. Yunis (https://thenounproject.com/mr.yunis/)

- Pods
- RESideMenu: https://github.com/romaonthego/RESideMenu by Roman Efimov (https://twitter.com/romaonthego)
- SnapKit: https://github.com/SnapKit/SnapKit

0 comments on commit 01d9ab0

Please sign in to comment.