Skip to content

Single device definition

Adam Gr edited this page May 5, 2018 · 3 revisions

Introduction

Motivation

  1. Device definition object must allow to set device UI specific properties
  • size
  • safeAreaInsets
  • layoutMargins
  • horizontalSizeClass
  • verticalSizeClass
  • preferredContentSizeCategory
  • layoutDirection
  • directionalLayoutMargins
  • ?
  1. Single device must be accessible for Swift and Objective-C
  2. New device definition can be created at any time outside library (no needs to update library in case of new device release)

Proposed solution:

Use NSObject subclass with DeviceViewMockable protocol conformance

class Phone_4Inches: NSObject, DeviceViewMockable {
    var name = "iPhone SE"
    var size = .init(width: 320.0, height: 568.0)
    var layoutMargins = .init(top: 8.0, left: 16.0, bottom: 8.0, right: 16.0)
    ...
}

Clone this wiki locally