Skip to content

Commit

Permalink
Enhance design system and populate home data 🎨 (#103)
Browse files Browse the repository at this point in the history
* Enhance button styling

* Apply new label styling

* Ensure styling in label

* Enhance styling and appearance

* Fix application open url

* Fix seconday button style and enhance reuse identifier usages

* Fix new relic build errors

* Update launch screen image to scale aspect fill

* Fix dashboard layout not pushed to the top

* Configure view controller and layout

* Rename and move the cell

* Add new recipes view with proper configurations

* Disable blanket disable command

---------

Co-authored-by: Mohamed Atallah <100219531+mhmdatallaa@users.noreply.github.com>
  • Loading branch information
ahmdmhasn and mhmdatallaa committed Aug 4, 2023
1 parent d97a350 commit 5d7b26d
Show file tree
Hide file tree
Showing 45 changed files with 603 additions and 420 deletions.
3 changes: 3 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ disabled_rules: # rule identifiers turned on by default to exclude from running
# TODOs and FIXMEs should be resolved.
- todo

# swiftlint:disable commands should be re-enabled before the end of the file
- blanket_disable_command

# configurable rules can be customized from this configuration file
# binary rules can set their severity level
force_cast: warning
Expand Down
162 changes: 74 additions & 88 deletions Healthy.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions Healthy/Classes/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import FBSDKCoreKit
import NewRelic

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
final class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
configureGoogleSignIn()
configureFacebookSignin(application: application, launchOptions: launchOptions)
configureNewRelic()
UINavigationBar.applyDefaultAppearance()
configureAppearance()
return true
}

Expand Down Expand Up @@ -39,9 +39,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// MARK: - Authentication Handler

extension AppDelegate {
func applicatxion(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
func application(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
let facebookResult: () -> Bool = {
ApplicationDelegate.shared.application(
app,
Expand Down Expand Up @@ -78,4 +78,7 @@ private extension AppDelegate {
NewRelic.start(withApplicationToken: Constants.newRelicAPIKey)
}

func configureAppearance() {
UINavigationBar.applyDefaultAppearance()
}
}
25 changes: 25 additions & 0 deletions Healthy/Classes/Extensions/NSLayoutConstraint+Helpers.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import UIKit

extension NSLayoutDimension {
/// Creates a constraint that sets the dimension's constant value to the provided CGFloat.
/// - Parameter value: The constant value to set for the dimension.
/// - Returns: The created constraint, which is activated automatically.
@discardableResult
func equalTo(_ value: CGFloat) -> NSLayoutConstraint {
let constraint = self.constraint(equalToConstant: value)
constraint.isActive = true
return constraint
}
}

extension NSLayoutConstraint {
/// Sets the priority of the constraint.
/// - Parameter priority: The UILayoutPriority to set for the constraint.
/// - Returns: The modified constraint, allowing for chaining with other methods.
@discardableResult
func priority(_ priority: UILayoutPriority) -> NSLayoutConstraint {
self.priority = priority
isActive = true
return self
}
}
85 changes: 38 additions & 47 deletions Healthy/Classes/Extensions/UIButton+Style.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,60 @@ import UIKit
extension UIButton {
enum ButtonStyle {
case primary
case plainGold

// TODO: [HL-4] Add global Color
fileprivate var buttonBackgroundColor: UIColor? {
switch self {
case .primary:
return ButtonColors.lightGreen
default:
return nil
}
}

// TODO: [HL-4] Add global Color
fileprivate var buttonTextColor: UIColor? {
switch self {
case .primary:
return .white
case .plainGold:
return ButtonColors.gold
}
}

// TODO: [HL-16] Add global fonts
fileprivate var buttonFont: UIFont? {
switch self {
case .primary:
return UIFont.preferredFont(forTextStyle: .callout, compatibleWith: .none)
case .plainGold:
return UIFont.preferredFont(forTextStyle: .subheadline, compatibleWith: .none)
}
}
case secondary
}
}

// MARK: - Apply button style
//
extension UIButton {
func applyButtonStyle(_ style: ButtonStyle) {
backgroundColor = style.buttonBackgroundColor
backgroundColor = style.backgroundColor
titleLabel?.font = style.buttonFont
tintColor = style.buttonTextColor
layer.cornerRadius = Constants.defaultCornerRadius
tintColor = style.textColor
layer.cornerRadius = style.cornerRadius
layer.masksToBounds = true
let heightConstraint = heightAnchor.constraint(equalToConstant: Constants.defaultHeight)
let heightConstraint = heightAnchor.constraint(equalToConstant: style.defaultHeight)
heightConstraint.priority = .defaultHigh
heightConstraint.isActive = true
}
}

// MARK: - Constants
// MARK: Button Style Configurations
//
private extension UIButton {
enum Constants {
static let defaultCornerRadius: CGFloat = 10.0
static let defaultHeight: CGFloat = 40.0
private extension UIButton.ButtonStyle {
var backgroundColor: UIColor? {
switch self {
case .primary: return .primary100
case .secondary: return .white
}
}
}

// MARK: - Button Colors
//
private extension UIButton {
enum ButtonColors {
static let lightGreen = UIColor(red: 0.071, green: 0.584, blue: 0.459, alpha: 1)
static let gold = UIColor(red: 1.000, green: 0.612, blue: 0.000, alpha: 1)
var textColor: UIColor? {
switch self {
case .primary: return .white
case .secondary: return .secondary100
}
}

var buttonFont: UIFont? {
switch self {
case .primary: return .mediumBold
case .secondary: return .mediumBold
}
}

var defaultHeight: CGFloat {
switch self {
case .primary, .secondary:
return 40.0
}
}

var cornerRadius: CGFloat {
switch self {
case .primary, .secondary:
return 12.0
}
}
}
6 changes: 0 additions & 6 deletions Healthy/Classes/Extensions/UICollectionView+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,3 @@ extension UICollectionView {
return cell
}
}

extension UIView {
static var reuseIdentifier: String {
return String(describing: self)
}
}
32 changes: 14 additions & 18 deletions Healthy/Classes/Extensions/UIFont+Style.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,31 @@ import UIKit
extension UIFont {

static var titleRegular: UIFont {
poppins(ofSize: 50, weight: .regular)
}

static var headerRegular: UIFont {
poppins(ofSize: 30, weight: .regular)
}

static var largeRegular: UIFont {
static var headerRegular: UIFont {
poppins(ofSize: 20, weight: .regular)
}

static var mediumRegular: UIFont {
static var largeRegular: UIFont {
poppins(ofSize: 18, weight: .regular)
}

static var normalRegular: UIFont {
static var mediumRegular: UIFont {
poppins(ofSize: 16, weight: .regular)
}

static var smallRegular: UIFont {
static var normalRegular: UIFont {
poppins(ofSize: 14, weight: .regular)
}

static var smallerRegular: UIFont {
static var smallRegular: UIFont {
poppins(ofSize: 11, weight: .regular)
}

static var smallLabelRegular: UIFont {
poppins(ofSize: 8, weight: .regular)
static var smallerRegular: UIFont {
poppins(ofSize: 9, weight: .regular)
}
}

Expand All @@ -42,31 +38,31 @@ extension UIFont {
extension UIFont {

static var titleBold: UIFont {
poppins(ofSize: 50, weight: .bold)
poppins(ofSize: 30, weight: .bold)
}

static var headerBold: UIFont {
poppins(ofSize: 30, weight: .bold)
poppins(ofSize: 20, weight: .bold)
}

static var largeBold: UIFont {
poppins(ofSize: 20, weight: .bold)
poppins(ofSize: 18, weight: .bold)
}

static var mediumBold: UIFont {
poppins(ofSize: 18, weight: .bold)
poppins(ofSize: 16, weight: .bold)
}

static var normalBold: UIFont {
poppins(ofSize: 16, weight: .bold)
poppins(ofSize: 14, weight: .bold)
}

static var smallBold: UIFont {
poppins(ofSize: 14, weight: .bold)
poppins(ofSize: 11, weight: .bold)
}

static var smallerBold: UIFont {
poppins(ofSize: 11, weight: .bold)
poppins(ofSize: 9, weight: .bold)
}
}

Expand Down
Loading

0 comments on commit 5d7b26d

Please sign in to comment.