Skip to content

Commit 67cc27c

Browse files
committed
add rough draft with demo
1 parent d0a6c0a commit 67cc27c

29 files changed

+2193
-0
lines changed

Ark.podspec

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# Be sure to run `pod spec lint GLFeedKit.podspec' to ensure this is a
3+
# valid spec and to remove all comments including this before submitting the spec.
4+
5+
Pod::Spec.new do |spec|
6+
7+
spec.name = "Ark"
8+
spec.version = "0.0.1"
9+
spec.summary = "Combine Texture and DeepDiff with iOS-13-DiffableDataSource-like API"
10+
spec.homepage = "https://github.com/imkdir/Ark.git"
11+
spec.license = "MIT"
12+
spec.author = { "Dwight CHENG" => "dwight.cheng@glowing.com" }
13+
14+
spec.platform = :ios
15+
spec.platform = :ios, "11.0"
16+
17+
spec.source = { :git => "https://github.com/imkdir/Ark.git", :tag => s.version.to_s }
18+
19+
spec.source_files = "Ark", "Ark/**/*.swift"
20+
# spec.exclude_files = "Classes/Exclude"
21+
22+
spec.dependency "Texture", "~> 3.0"
23+
24+
end

Ark.xcodeproj/project.pbxproj

Lines changed: 703 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1160"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "B4256DC124ED1715000DF13C"
18+
BuildableName = "Ark.framework"
19+
BlueprintName = "Ark"
20+
ReferencedContainer = "container:Ark.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
</LaunchAction>
44+
<ProfileAction
45+
buildConfiguration = "Release"
46+
shouldUseLaunchSchemeArgsEnv = "YES"
47+
savedToolIdentifier = ""
48+
useCustomWorkingDirectory = "NO"
49+
debugDocumentVersioning = "YES">
50+
<MacroExpansion>
51+
<BuildableReference
52+
BuildableIdentifier = "primary"
53+
BlueprintIdentifier = "B4256DC124ED1715000DF13C"
54+
BuildableName = "Ark.framework"
55+
BlueprintName = "Ark"
56+
ReferencedContainer = "container:Ark.xcodeproj">
57+
</BuildableReference>
58+
</MacroExpansion>
59+
</ProfileAction>
60+
<AnalyzeAction
61+
buildConfiguration = "Debug">
62+
</AnalyzeAction>
63+
<ArchiveAction
64+
buildConfiguration = "Release"
65+
revealArchiveInOrganizer = "YES">
66+
</ArchiveAction>
67+
</Scheme>
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1160"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "B42875AF24EE137D00933413"
18+
BuildableName = "ArkDemo.app"
19+
BlueprintName = "ArkDemo"
20+
ReferencedContainer = "container:Ark.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
<BuildableProductRunnable
44+
runnableDebuggingMode = "0">
45+
<BuildableReference
46+
BuildableIdentifier = "primary"
47+
BlueprintIdentifier = "B42875AF24EE137D00933413"
48+
BuildableName = "ArkDemo.app"
49+
BlueprintName = "ArkDemo"
50+
ReferencedContainer = "container:Ark.xcodeproj">
51+
</BuildableReference>
52+
</BuildableProductRunnable>
53+
</LaunchAction>
54+
<ProfileAction
55+
buildConfiguration = "Release"
56+
shouldUseLaunchSchemeArgsEnv = "YES"
57+
savedToolIdentifier = ""
58+
useCustomWorkingDirectory = "NO"
59+
debugDocumentVersioning = "YES">
60+
<BuildableProductRunnable
61+
runnableDebuggingMode = "0">
62+
<BuildableReference
63+
BuildableIdentifier = "primary"
64+
BlueprintIdentifier = "B42875AF24EE137D00933413"
65+
BuildableName = "ArkDemo.app"
66+
BlueprintName = "ArkDemo"
67+
ReferencedContainer = "container:Ark.xcodeproj">
68+
</BuildableReference>
69+
</BuildableProductRunnable>
70+
</ProfileAction>
71+
<AnalyzeAction
72+
buildConfiguration = "Debug">
73+
</AnalyzeAction>
74+
<ArchiveAction
75+
buildConfiguration = "Release"
76+
revealArchiveInOrganizer = "YES">
77+
</ArchiveAction>
78+
</Scheme>

Ark/ASSizeRangeExtension.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// ASSizeRangeExtension.swift
3+
// Ark
4+
//
5+
// Created by Dwight CHENG on 8/27/20.
6+
// Copyright © 2020 Glow. All rights reserved.
7+
//
8+
9+
import AsyncDisplayKit
10+
11+
public extension ASSizeRange {
12+
13+
static func automaticSize(width: CGFloat) -> ASSizeRange {
14+
return ASSizeRange(
15+
min: .init(width: width, height: .leastNonzeroMagnitude),
16+
max: .init(width: width, height: .greatestFiniteMagnitude))
17+
}
18+
}

Ark/Ark.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// Ark.h
3+
// Ark
4+
//
5+
// Created by Dwight CHENG on 2020/8/19.
6+
// Copyright © 2020 Glow. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
//! Project version number for Ark.
12+
FOUNDATION_EXPORT double ArkVersionNumber;
13+
14+
//! Project version string for Ark.
15+
FOUNDATION_EXPORT const unsigned char ArkVersionString[];
16+
17+
// In this header, you should import all the public headers of your framework using statements like #import <Ark/PublicHeader.h>
18+
19+

Ark/CollectionContext.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// CollectionViewContext.swift
3+
// GLFeedKit
4+
//
5+
// Created by Dwight CHENG on 8/27/20.
6+
// Copyright © 2020 Glow. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
public struct CollectionViewContext {
12+
let section: CollectionViewModel
13+
let containerSize: CGSize
14+
let contentInset: UIEdgeInsets
15+
16+
var widthThatFit: CGFloat {
17+
max(0, containerSize.width - contentInset.left - contentInset.right)
18+
}
19+
}

Ark/CollectionNodeContext.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// CollectionNodeContext.swift
3+
// Ark
4+
//
5+
// Created by Dwight CHENG on 8/27/20.
6+
// Copyright © 2020 Glow. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
public struct CollectionNodeContext {
12+
public let section: CollectionViewModel
13+
public let containerSize: CGSize
14+
public let contentInset: UIEdgeInsets
15+
16+
public var widthThatFit: CGFloat {
17+
max(0, containerSize.width - contentInset.left - contentInset.right)
18+
}
19+
}

Ark/CollectionViewModel.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// CollectionViewModel.swift
3+
// Ark
4+
//
5+
// Created by Dwight CHENG on 8/26/20.
6+
// Copyright © 2020 Glow. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import AsyncDisplayKit
11+
12+
public protocol CollectionViewModel: Diffable {
13+
14+
var items: [CollectionViewModel] { get }
15+
16+
var viewBlock: ASCellNodeBlock { get }
17+
18+
func sizeRange(in context: CollectionNodeContext) -> ASSizeRange
19+
}
20+
21+
// MARK: - Default Implementation for Single Item Section
22+
23+
public extension CollectionViewModel {
24+
25+
var items: [CollectionViewModel] {
26+
[self]
27+
}
28+
29+
var viewBlock: ASCellNodeBlock {
30+
ASCellNode.init
31+
}
32+
33+
func sizeRange(in context: CollectionNodeContext) -> ASSizeRange {
34+
.automaticSize(width: context.widthThatFit)
35+
}
36+
}

Ark/DateFormat.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// DateFormat.swift
3+
// Ark
4+
//
5+
// Created by Dwight CHENG on 8/27/20.
6+
// Copyright © 2020 Glow. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
public func string(format: String, _ date: Date) -> String {
12+
13+
if let formatter = dateFormatters[format] {
14+
return formatter.string(from: date)
15+
} else {
16+
let formatter = DateFormatter()
17+
formatter.dateFormat = format
18+
dateFormatters[format] = formatter
19+
return formatter.string(from: date)
20+
}
21+
}
22+
23+
private var dateFormatters: [String: DateFormatter] = [:]

0 commit comments

Comments
 (0)