mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 08:46:18 +01:00
Refactor: extract ios core like android
This commit is contained in:
parent
b43b099f7e
commit
904b898a44
8 changed files with 101 additions and 36 deletions
36
np_ios_core/.gitignore
vendored
Normal file
36
np_ios_core/.gitignore
vendored
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# macOS
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Xcode
|
||||||
|
build/
|
||||||
|
*.pbxuser
|
||||||
|
!default.pbxuser
|
||||||
|
*.mode1v3
|
||||||
|
!default.mode1v3
|
||||||
|
*.mode2v3
|
||||||
|
!default.mode2v3
|
||||||
|
*.perspectivev3
|
||||||
|
!default.perspectivev3
|
||||||
|
xcuserdata/
|
||||||
|
*.xccheckout
|
||||||
|
*.moved-aside
|
||||||
|
DerivedData
|
||||||
|
*.hmap
|
||||||
|
*.ipa
|
||||||
|
|
||||||
|
# Bundler
|
||||||
|
.bundle
|
||||||
|
|
||||||
|
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||||
|
# Carthage/Checkouts
|
||||||
|
|
||||||
|
Carthage/Build
|
||||||
|
|
||||||
|
# We recommend against adding the Pods directory to your .gitignore. However
|
||||||
|
# you should judge for yourself, the pros and cons are mentioned at:
|
||||||
|
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
|
||||||
|
#
|
||||||
|
# Note: if you ignore the Pods directory, make sure to uncomment
|
||||||
|
# `pod install` in .travis.yml
|
||||||
|
#
|
||||||
|
# Pods/
|
26
np_ios_core/NpIosCore.podspec
Normal file
26
np_ios_core/NpIosCore.podspec
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
Pod::Spec.new do |s|
|
||||||
|
s.name = 'NpIosCore'
|
||||||
|
s.version = '0.1.0'
|
||||||
|
s.summary = 'A short description of NpIosCore.'
|
||||||
|
s.description = <<-DESC
|
||||||
|
TODO: Add long description of the pod here.
|
||||||
|
DESC
|
||||||
|
s.homepage = 'http://example.com'
|
||||||
|
s.license = { :type => 'GPLv3' }
|
||||||
|
s.author = { 'Your Company' => 'email@example.com' }
|
||||||
|
s.source = { :path => '.' }
|
||||||
|
|
||||||
|
s.ios.deployment_target = '12.0'
|
||||||
|
|
||||||
|
s.source_files = 'NpIosCore/Classes/**/*'
|
||||||
|
|
||||||
|
# s.resource_bundles = {
|
||||||
|
# 'NpIosCore' => ['NpIosCore/Assets/*.png']
|
||||||
|
# }
|
||||||
|
|
||||||
|
# s.public_header_files = 'Pod/Classes/**/*.h'
|
||||||
|
# s.frameworks = 'UIKit', 'MapKit'
|
||||||
|
# s.dependency 'AFNetworking', '~> 2.3'
|
||||||
|
s.dependency 'Flutter'
|
||||||
|
s.dependency 'Logging'
|
||||||
|
end
|
0
np_ios_core/NpIosCore/Assets/.gitkeep
Normal file
0
np_ios_core/NpIosCore/Assets/.gitkeep
Normal file
22
np_ios_core/NpIosCore/Classes/Error.swift
Normal file
22
np_ios_core/NpIosCore/Classes/Error.swift
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public class AppError: Error {
|
||||||
|
public init(_ message: String? = nil, stackTrace: [String] = Thread.callStackSymbols) {
|
||||||
|
self.message_ = message
|
||||||
|
self.stackTrace = stackTrace.joined(separator: "\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
public var description: String {
|
||||||
|
return "\(message_ ?? "") (throw: \(String(describing: self))\nStack trace:\n\(stackTrace)"
|
||||||
|
}
|
||||||
|
|
||||||
|
public var message: String {
|
||||||
|
return message_ == nil ? String(describing: self) : message_!
|
||||||
|
}
|
||||||
|
|
||||||
|
public let stackTrace: String
|
||||||
|
private let message_: String?
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NilError: AppError {
|
||||||
|
}
|
14
np_ios_core/NpIosCore/Classes/Util.swift
Normal file
14
np_ios_core/NpIosCore/Classes/Util.swift
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public extension Optional {
|
||||||
|
func unwrap(
|
||||||
|
_ errorBuilder: (() -> Error)? = nil,
|
||||||
|
file: String = #fileID,
|
||||||
|
line: Int = #line
|
||||||
|
) throws -> Wrapped {
|
||||||
|
guard let value = self else {
|
||||||
|
throw errorBuilder?() ?? NilError("\(type(of: self)) is nil in \(file):\(line)")
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
import Flutter
|
import Flutter
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import NpIosCore
|
||||||
|
|
||||||
class LockChannelHandler {
|
class LockChannelHandler {
|
||||||
func onMethodCall(call: FlutterMethodCall, result: FlutterResult) {
|
func onMethodCall(call: FlutterMethodCall, result: FlutterResult) {
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
import Foundation
|
|
||||||
|
|
||||||
class AppError: Error {
|
|
||||||
init(_ message: String? = nil, stackTrace: [String] = Thread.callStackSymbols) {
|
|
||||||
self.message_ = message
|
|
||||||
self.stackTrace = stackTrace.joined(separator: "\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
var description: String {
|
|
||||||
return "\(message_ ?? "") (throw: \(String(describing: self))\nStack trace:\n\(stackTrace)"
|
|
||||||
}
|
|
||||||
|
|
||||||
var message: String {
|
|
||||||
return message_ == nil ? String(describing: self) : message_!
|
|
||||||
}
|
|
||||||
|
|
||||||
let stackTrace: String
|
|
||||||
private let message_: String?
|
|
||||||
}
|
|
||||||
|
|
||||||
class NilError: AppError {
|
|
||||||
}
|
|
||||||
|
|
||||||
extension Optional {
|
|
||||||
func unwrap(
|
|
||||||
_ errorBuilder: (() -> Error)? = nil,
|
|
||||||
file: String = #fileID,
|
|
||||||
line: Int = #line
|
|
||||||
) throws -> Wrapped {
|
|
||||||
guard let value = self else {
|
|
||||||
throw errorBuilder?() ?? NilError("\(type(of: self)) is nil in \(file):\(line)")
|
|
||||||
}
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,11 +10,12 @@ Pod::Spec.new do |s|
|
||||||
A new Flutter plugin project.
|
A new Flutter plugin project.
|
||||||
DESC
|
DESC
|
||||||
s.homepage = 'http://example.com'
|
s.homepage = 'http://example.com'
|
||||||
s.license = { :file => '../LICENSE' }
|
s.license = { :type => 'GPLv3' }
|
||||||
s.author = { 'Your Company' => 'email@example.com' }
|
s.author = { 'Your Company' => 'email@example.com' }
|
||||||
s.source = { :path => '.' }
|
s.source = { :path => '.' }
|
||||||
s.source_files = 'Classes/**/*'
|
s.source_files = 'Classes/**/*'
|
||||||
s.dependency 'Flutter'
|
s.dependency 'Flutter'
|
||||||
|
s.dependency 'NpIosCore'
|
||||||
s.platform = :ios, '9.0'
|
s.platform = :ios, '9.0'
|
||||||
|
|
||||||
# Flutter.framework does not contain a i386 slice.
|
# Flutter.framework does not contain a i386 slice.
|
||||||
|
|
Loading…
Reference in a new issue