notifications work—still work to do but it's progress

also updated pods
parent fa006df2
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
platform :ios, '11.0'
platform :ios, '12.0'
use_frameworks!
def important_pods
pod 'RealmSwift'
#pod 'ObjectMapper', '~> 3.2'
# TEMPORARY BECAUSE Xcode 10
pod 'ObjectMapper', :git => 'https://github.com/alecdoconnor/ObjectMapper.git', :branch => 'Swift-4.2'
pod 'ObjectMapper'
pod "ObjectMapper+Realm"
end
def ios_pods
#pod 'Segmentio', '~> 2.1'
pod 'DeckTransition', '~> 2.0'
pod 'DeckTransition'
pod 'Fabric'
pod 'Crashlytics'
......
PODS:
- Crashlytics (3.10.2):
- Fabric (~> 1.7.7)
- DeckTransition (2.0.0)
- Fabric (1.7.7)
- ObjectMapper (3.2.0)
- Crashlytics (3.12.0):
- Fabric (~> 1.9.0)
- DeckTransition (2.1.0)
- Fabric (1.9.0)
- ObjectMapper (3.4.2)
- "ObjectMapper+Realm (0.6)":
- ObjectMapper
- RealmSwift
- Realm (3.7.1):
- Realm/Headers (= 3.7.1)
- Realm/Headers (3.7.1)
- RealmSwift (3.7.1):
- Realm (= 3.7.1)
- Realm (3.13.1):
- Realm/Headers (= 3.13.1)
- Realm/Headers (3.13.1)
- RealmSwift (3.13.1):
- Realm (= 3.13.1)
DEPENDENCIES:
- Crashlytics
- DeckTransition (~> 2.0)
- DeckTransition
- Fabric
- ObjectMapper (from `https://github.com/alecdoconnor/ObjectMapper.git`, branch `Swift-4.2`)
- ObjectMapper
- "ObjectMapper+Realm"
- RealmSwift
......@@ -26,29 +26,20 @@ SPEC REPOS:
- Crashlytics
- DeckTransition
- Fabric
- ObjectMapper
- "ObjectMapper+Realm"
- Realm
- RealmSwift
EXTERNAL SOURCES:
ObjectMapper:
:branch: Swift-4.2
:git: https://github.com/alecdoconnor/ObjectMapper.git
CHECKOUT OPTIONS:
ObjectMapper:
:commit: af7966b567860596fad270bb44b27f495cd8691d
:git: https://github.com/alecdoconnor/ObjectMapper.git
SPEC CHECKSUMS:
Crashlytics: 0360624eea1c978a743feddb2fb1ef8b37fb7a0d
DeckTransition: 2300694f94fbeca2c103f365dc9dc09ffae14a4f
Fabric: bda89e242bce1b7b8ab264248cf3407774ce0095
ObjectMapper: 5cccd2de6f253eda859df8116a5a554d9769e859
Crashlytics: 07fb167b1694128c1c9a5a5cc319b0e9c3ca0933
DeckTransition: ca707456e3d83928c895fed6f458cbf68c5cac84
Fabric: f988e33c97f08930a413e08123064d2e5f68d655
ObjectMapper: 0d4402610f4e468903ae64629eec4784531e5c51
"ObjectMapper+Realm": 4cf44ed3202a73f08594e21e13eb3f8aa9b5a664
Realm: 906be37d52f17f25484ac01643a7f26a9d3bfbd5
RealmSwift: 1c2b6bae3dc55bb87e080ffa96537d71442f6dce
Realm: 50071da38fe079e0735e47c9f2eae738c68c5996
RealmSwift: 8a1e6a02b7a08cd17a31e3115143fb69fe5f3fb9
PODFILE CHECKSUM: e3da96824c5423fd0dd953a34113b2434bddd6b3
PODFILE CHECKSUM: c2fa08440be1a2902ec4a3ed351464719891fc3a
COCOAPODS: 1.5.3
COCOAPODS: 1.6.0.beta.2
......@@ -15,7 +15,7 @@ Hereʼs a GIF showing it in action.
## Requirements
- Swift 4
- Swift 4.2
- iOS 9 or later
## Installation
......@@ -100,6 +100,7 @@ It's worth noting that updating the snapshot is an expensive process and should
- [Petty](https://zachsim.one/projects/petty) by [Zach Simone](https://twitter.com/zachsimone)
- [Bitbook](https://bitbookapp.com) by [Sammy Gutierrez](https://sammygutierrez.com)
- [BookPlayer](https://github.com/GianniCarlo/Audiobook-Player) by [Gianni Carlo](https://twitter.com/GCarlo89)
- [What's Open for iOS](https://git.gmu.edu/srct/whats-open-ios) by [Mason SRCT](https://srct.gmu.edu/)
Feel free to submit a PR if you’re using this library in your apps
......
......@@ -65,7 +65,7 @@ final class DeckPresentationController: UIPresentationController, UIGestureRecog
self.dismissAnimation = dismissAnimation
self.dismissCompletion = dismissCompletion
NotificationCenter.default.addObserver(self, selector: #selector(updateForStatusBar), name: .UIApplicationDidChangeStatusBarFrame, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(updateForStatusBar), name: UIApplication.didChangeStatusBarFrameNotification, object: nil)
}
// MARK: - Public methods
......@@ -287,7 +287,7 @@ final class DeckPresentationController: UIPresentationController, UIGestureRecog
}
updateSnapshotViewAspectRatio()
containerView.bringSubview(toFront: roundedViewForPresentedView)
containerView.bringSubviewToFront(roundedViewForPresentedView)
if presentedViewController.view.isDescendant(of: containerView) {
UIView.animate(withDuration: 0.1) { [weak self] in
......@@ -586,7 +586,8 @@ final class DeckPresentationController: UIPresentationController, UIGestureRecog
animations: {
self.presentedView?.transform = .identity
})
scrollViewUpdater = nil
default: break
}
......
......@@ -55,6 +55,10 @@ final class ScrollViewDetector {
return scrollView
}
if let scrollView = viewController.view as? UIScrollView {
return scrollView
}
for subview in viewController.view.subviews {
if let scrollView = subview as? UIScrollView {
return scrollView
......
......@@ -55,9 +55,9 @@ final class ScrollViewUpdater {
/// `safeAreaInsets.top` is 0, so that is adjusted for here.
let offset: CGFloat = {
if #available(iOS 11, *) {
return scrollView.contentOffset.y + scrollView.safeAreaInsets.top
return scrollView.contentOffset.y + scrollView.contentInset.top + scrollView.safeAreaInsets.top
} else {
return scrollView.contentOffset.y
return scrollView.contentOffset.y + scrollView.contentInset.top
}
}()
......
PODS:
- Crashlytics (3.10.2):
- Fabric (~> 1.7.7)
- DeckTransition (2.0.0)
- Fabric (1.7.7)
- ObjectMapper (3.2.0)
- Crashlytics (3.12.0):
- Fabric (~> 1.9.0)
- DeckTransition (2.1.0)
- Fabric (1.9.0)
- ObjectMapper (3.4.2)
- "ObjectMapper+Realm (0.6)":
- ObjectMapper
- RealmSwift
- Realm (3.7.1):
- Realm/Headers (= 3.7.1)
- Realm/Headers (3.7.1)
- RealmSwift (3.7.1):
- Realm (= 3.7.1)
- Realm (3.13.1):
- Realm/Headers (= 3.13.1)
- Realm/Headers (3.13.1)
- RealmSwift (3.13.1):
- Realm (= 3.13.1)
DEPENDENCIES:
- Crashlytics
- DeckTransition (~> 2.0)
- DeckTransition
- Fabric
- ObjectMapper (from `https://github.com/alecdoconnor/ObjectMapper.git`, branch `Swift-4.2`)
- ObjectMapper
- "ObjectMapper+Realm"
- RealmSwift
......@@ -26,29 +26,20 @@ SPEC REPOS:
- Crashlytics
- DeckTransition
- Fabric
- ObjectMapper
- "ObjectMapper+Realm"
- Realm
- RealmSwift
EXTERNAL SOURCES:
ObjectMapper:
:branch: Swift-4.2
:git: https://github.com/alecdoconnor/ObjectMapper.git
CHECKOUT OPTIONS:
ObjectMapper:
:commit: af7966b567860596fad270bb44b27f495cd8691d
:git: https://github.com/alecdoconnor/ObjectMapper.git
SPEC CHECKSUMS:
Crashlytics: 0360624eea1c978a743feddb2fb1ef8b37fb7a0d
DeckTransition: 2300694f94fbeca2c103f365dc9dc09ffae14a4f
Fabric: bda89e242bce1b7b8ab264248cf3407774ce0095
ObjectMapper: 5cccd2de6f253eda859df8116a5a554d9769e859
Crashlytics: 07fb167b1694128c1c9a5a5cc319b0e9c3ca0933
DeckTransition: ca707456e3d83928c895fed6f458cbf68c5cac84
Fabric: f988e33c97f08930a413e08123064d2e5f68d655
ObjectMapper: 0d4402610f4e468903ae64629eec4784531e5c51
"ObjectMapper+Realm": 4cf44ed3202a73f08594e21e13eb3f8aa9b5a664
Realm: 906be37d52f17f25484ac01643a7f26a9d3bfbd5
RealmSwift: 1c2b6bae3dc55bb87e080ffa96537d71442f6dce
Realm: 50071da38fe079e0735e47c9f2eae738c68c5996
RealmSwift: 8a1e6a02b7a08cd17a31e3115143fb69fe5f3fb9
PODFILE CHECKSUM: e3da96824c5423fd0dd953a34113b2434bddd6b3
PODFILE CHECKSUM: c2fa08440be1a2902ec4a3ed351464719891fc3a
COCOAPODS: 1.5.3
COCOAPODS: 1.6.0.beta.2
......@@ -146,9 +146,7 @@ ObjectMapper 使用这个函数获取对象后进行映射。开发者需要在
如果你需要在 extension 里实现 ObjectMapper,你需要选择这个协议而不是 `Mappable`
## `ImmutableMappable` Protocol (Beta)
> ⚠️ 这个特性还处于 Beta 阶段。正式发布时 API 可能会完全不同。
## `ImmutableMappable` Protocol
使用 `ImmutableMappable` 可以映射不可变的属性。下面的表格展示了 `ImmutableMappable``Mappable` 的不同:
......
//
// CodableTransform.swift
// ObjectMapper
//
// Created by Jari Kalinainen on 10/10/2018.
//
// The MIT License (MIT)
//
// Copyright (c) 2014-2018 Tristan Himmelman
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import Foundation
/// Transforms JSON dictionary to Codable type T and back
open class CodableTransform<T: Codable>: TransformType {
public typealias Object = T
public typealias JSON = Any
public init() {}
open func transformFromJSON(_ value: Any?) -> Object? {
guard let dict = value as? [String: Any], let data = try? JSONSerialization.data(withJSONObject: dict, options: []) else {
return nil
}
do {
let decoder = JSONDecoder()
let item = try decoder.decode(T.self, from: data)
return item
} catch {
return nil
}
}
open func transformToJSON(_ value: T?) -> JSON? {
guard let item = value else {
return nil
}
do {
let encoder = JSONEncoder()
let data = try encoder.encode(item)
let dictionary = try JSONSerialization.jsonObject(with: data, options: .allowFragments)
return dictionary
} catch {
return nil
}
}
}
......@@ -6,7 +6,7 @@
//
// The MIT License (MIT)
//
// Copyright (c) 2014-2016 Hearst
// Copyright (c) 2014-2018 Tristan Himmelman
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
......
......@@ -6,7 +6,7 @@
//
// The MIT License (MIT)
//
// Copyright (c) 2014-2016 Hearst
// Copyright (c) 2014-2018 Tristan Himmelman
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
......
......@@ -6,7 +6,7 @@
//
// The MIT License (MIT)
//
// Copyright (c) 2014-2016 Hearst
// Copyright (c) 2014-2018 Tristan Himmelman
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
......
......@@ -6,7 +6,7 @@
//
// The MIT License (MIT)
//
// Copyright (c) 2014-2016 Hearst
// Copyright (c) 2014-2018 Tristan Himmelman
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
......@@ -32,23 +32,43 @@ open class DateTransform: TransformType {
public typealias Object = Date
public typealias JSON = Double
public init() {}
public enum Unit: TimeInterval {
case seconds = 1
case milliseconds = 1_000
func addScale(to interval: TimeInterval) -> TimeInterval {
return interval * rawValue
}
func removeScale(from interval: TimeInterval) -> TimeInterval {
return interval / rawValue
}
}
private let unit: Unit
public init(unit: Unit = .seconds) {
self.unit = unit
}
open func transformFromJSON(_ value: Any?) -> Date? {
var timeInterval: TimeInterval?
if let timeInt = value as? Double {
return Date(timeIntervalSince1970: TimeInterval(timeInt))
timeInterval = TimeInterval(timeInt)
}
if let timeStr = value as? String {
return Date(timeIntervalSince1970: TimeInterval(atof(timeStr)))
timeInterval = TimeInterval(atof(timeStr))
}
return nil
return timeInterval.flatMap {
return Date(timeIntervalSince1970: unit.removeScale(from: $0))
}
}
open func transformToJSON(_ value: Date?) -> Double? {
if let date = value {
return Double(date.timeIntervalSince1970)
return Double(unit.addScale(to: date.timeIntervalSince1970))
}
return nil
}
......
......@@ -3,8 +3,26 @@
// ObjectMapper
//
// Created by Milen Halachev on 7/20/16.
// Copyright © 2016 hearst. All rights reserved.
//
// Copyright (c) 2014-2018 Tristan Himmelman
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import Foundation
......
......@@ -3,8 +3,28 @@
// ObjectMapper
//
// Created by Tristan Himmelman on 2016-09-26.
// Copyright © 2016 hearst. All rights reserved.
//
// The MIT License (MIT)
//
// Copyright (c) 2014-2018 Tristan Himmelman
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import Foundation
......@@ -31,6 +51,14 @@ public func >>> <T: RawRepresentable>(left: T?, right: Map) {
}
// Code targeting the Swift 4.1 compiler and below.
#if !(swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0)))
/// Implicitly Unwrapped Optional Object of Raw Representable type
public func <- <T: RawRepresentable>(left: inout T!, right: Map) {
left <- (right, EnumTransform())
}
#endif
// MARK:- Arrays of Raw Representable type
/// Array of Raw Representable object
......@@ -53,6 +81,14 @@ public func >>> <T: RawRepresentable>(left: [T]?, right: Map) {
}
// Code targeting the Swift 4.1 compiler and below.
#if !(swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0)))
/// Array of Raw Representable object
public func <- <T: RawRepresentable>(left: inout [T]!, right: Map) {
left <- (right, EnumTransform())
}
#endif
// MARK:- Dictionaries of Raw Representable type
/// Dictionary of Raw Representable object
......@@ -73,3 +109,12 @@ public func <- <T: RawRepresentable>(left: inout [String: T]?, right: Map) {
public func >>> <T: RawRepresentable>(left: [String: T]?, right: Map) {
left >>> (right, EnumTransform())
}
// Code targeting the Swift 4.1 compiler and below.
#if !(swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0)))
/// Dictionary of Raw Representable object
public func <- <T: RawRepresentable>(left: inout [String: T]!, right: Map) {
left <- (right, EnumTransform())
}
#endif
......@@ -6,7 +6,7 @@
//
// The MIT License (MIT)
//
// Copyright (c) 2014-2016 Hearst
// Copyright (c) 2014-2018 Tristan Himmelman
//
// Permission is hereby granted, free of charge, to any person obtaining a copy