fix swift
This commit is contained in:
@@ -26,6 +26,8 @@ jobs:
|
|||||||
run: yarn lint
|
run: yarn lint
|
||||||
- name: Prettier check
|
- name: Prettier check
|
||||||
run: yarn prettier --check .
|
run: yarn prettier --check .
|
||||||
|
- name: Lint native check
|
||||||
|
run: yarn lint-native
|
||||||
- name: Check & compile i18n
|
- name: Check & compile i18n
|
||||||
run: yarn intl:build
|
run: yarn intl:build
|
||||||
- name: Type check
|
- name: Type check
|
||||||
|
|||||||
@@ -30,12 +30,11 @@ class ShareViewController: UIViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func handleText(item: NSItemProvider) async -> Void {
|
private func handleText(item: NSItemProvider) async {
|
||||||
do {
|
do {
|
||||||
if let data = try await item.loadItem(forTypeIdentifier: "public.text") as? String {
|
if let data = try await item.loadItem(forTypeIdentifier: "public.text") as? String {
|
||||||
if let encoded = data.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed),
|
if let encoded = data.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed),
|
||||||
let url = URL(string: "\(self.appScheme)://intent/compose?text=\(encoded)")
|
let url = URL(string: "\(self.appScheme)://intent/compose?text=\(encoded)") {
|
||||||
{
|
|
||||||
_ = self.openURL(url)
|
_ = self.openURL(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,12 +44,11 @@ class ShareViewController: UIViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func handleUrl(item: NSItemProvider) async -> Void {
|
private func handleUrl(item: NSItemProvider) async {
|
||||||
do {
|
do {
|
||||||
if let data = try await item.loadItem(forTypeIdentifier: "public.url") as? URL {
|
if let data = try await item.loadItem(forTypeIdentifier: "public.url") as? URL {
|
||||||
if let encoded = data.absoluteString.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed),
|
if let encoded = data.absoluteString.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed),
|
||||||
let url = URL(string: "\(self.appScheme)://intent/compose?text=\(encoded)")
|
let url = URL(string: "\(self.appScheme)://intent/compose?text=\(encoded)") {
|
||||||
{
|
|
||||||
_ = self.openURL(url)
|
_ = self.openURL(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,7 +58,7 @@ class ShareViewController: UIViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func handleImages(items: [NSItemProvider]) async -> Void {
|
private func handleImages(items: [NSItemProvider]) async {
|
||||||
let firstFourItems: [NSItemProvider]
|
let firstFourItems: [NSItemProvider]
|
||||||
if items.count < 4 {
|
if items.count < 4 {
|
||||||
firstFourItems = items
|
firstFourItems = items
|
||||||
@@ -72,7 +70,7 @@ class ShareViewController: UIViewController {
|
|||||||
var imageUris = ""
|
var imageUris = ""
|
||||||
|
|
||||||
for (index, item) in firstFourItems.enumerated() {
|
for (index, item) in firstFourItems.enumerated() {
|
||||||
var imageUriInfo: String? = nil
|
var imageUriInfo: String?
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if let dataUri = try await item.loadItem(forTypeIdentifier: "public.image") as? URL {
|
if let dataUri = try await item.loadItem(forTypeIdentifier: "public.image") as? URL {
|
||||||
@@ -100,8 +98,7 @@ class ShareViewController: UIViewController {
|
|||||||
|
|
||||||
if valid,
|
if valid,
|
||||||
let encoded = imageUris.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed),
|
let encoded = imageUris.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed),
|
||||||
let url = URL(string: "\(self.appScheme)://intent/compose?imageUris=\(encoded)")
|
let url = URL(string: "\(self.appScheme)://intent/compose?imageUris=\(encoded)") {
|
||||||
{
|
|
||||||
_ = self.openURL(url)
|
_ = self.openURL(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,13 +116,11 @@ class ShareViewController: UIViewController {
|
|||||||
// extension does.
|
// extension does.
|
||||||
if let dir = FileManager()
|
if let dir = FileManager()
|
||||||
.containerURL(
|
.containerURL(
|
||||||
forSecurityApplicationGroupIdentifier: "group.app.bsky")
|
forSecurityApplicationGroupIdentifier: "group.app.bsky") {
|
||||||
{
|
|
||||||
let filePath = "\(dir.absoluteString)\(ProcessInfo.processInfo.globallyUniqueString).jpeg"
|
let filePath = "\(dir.absoluteString)\(ProcessInfo.processInfo.globallyUniqueString).jpeg"
|
||||||
|
|
||||||
if let newUri = URL(string: filePath),
|
if let newUri = URL(string: filePath),
|
||||||
let jpegData = image.jpegData(compressionQuality: 1)
|
let jpegData = image.jpegData(compressionQuality: 1)
|
||||||
{
|
|
||||||
try jpegData.write(to: newUri)
|
try jpegData.write(to: newUri)
|
||||||
return "\(newUri.absoluteString)|\(image.size.width)|\(image.size.height)"
|
return "\(newUri.absoluteString)|\(image.size.width)|\(image.size.height)"
|
||||||
}
|
}
|
||||||
@@ -136,7 +131,7 @@ class ShareViewController: UIViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func completeRequest() -> Void {
|
private func completeRequest() {
|
||||||
self.extensionContext?.completeRequest(returningItems: nil)
|
self.extensionContext?.completeRequest(returningItems: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-6
@@ -11,7 +11,7 @@ let DEFAULTS: [String:Any] = [
|
|||||||
"playSoundReply": false,
|
"playSoundReply": false,
|
||||||
"playSoundRepost": false,
|
"playSoundRepost": false,
|
||||||
"mutedThreads": [:] as! [String: [String]],
|
"mutedThreads": [:] as! [String: [String]],
|
||||||
"badgeCount": 0,
|
"badgeCount": 0
|
||||||
]
|
]
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -64,22 +64,21 @@ public class ExpoBackgroundNotificationHandlerModule: Module {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncFunction("setBoolAsync") { (forKey: String, value: Bool) -> Void in
|
AsyncFunction("setBoolAsync") { (forKey: String, value: Bool) in
|
||||||
userDefaults?.setValue(value, forKey: forKey)
|
userDefaults?.setValue(value, forKey: forKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncFunction("setStringAsync") { (forKey: String, value: String) -> Void in
|
AsyncFunction("setStringAsync") { (forKey: String, value: String) in
|
||||||
userDefaults?.setValue(value, forKey: forKey)
|
userDefaults?.setValue(value, forKey: forKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncFunction("setStringArrayAsync") { (forKey: String, value: [String]) -> Void in
|
AsyncFunction("setStringArrayAsync") { (forKey: String, value: [String]) in
|
||||||
userDefaults?.setValue(value, forKey: forKey)
|
userDefaults?.setValue(value, forKey: forKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncFunction("addToStringArrayAsync") { (forKey: String, string: String) in
|
AsyncFunction("addToStringArrayAsync") { (forKey: String, string: String) in
|
||||||
if var curr = userDefaults?.stringArray(forKey: forKey),
|
if var curr = userDefaults?.stringArray(forKey: forKey),
|
||||||
!curr.contains(string)
|
!curr.contains(string) {
|
||||||
{
|
|
||||||
curr.append(string)
|
curr.append(string)
|
||||||
userDefaults?.setValue(curr, forKey: forKey)
|
userDefaults?.setValue(curr, forKey: forKey)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ public class GifView: ExpoView, AVPlayerViewControllerDelegate {
|
|||||||
private var placeholderOperation: SDWebImageCombinedOperation?
|
private var placeholderOperation: SDWebImageCombinedOperation?
|
||||||
|
|
||||||
// Props
|
// Props
|
||||||
var source: String? = nil
|
var source: String?
|
||||||
var placeholderSource: String? = nil
|
var placeholderSource: String?
|
||||||
var autoplay = true {
|
var autoplay = true {
|
||||||
didSet {
|
didSet {
|
||||||
if !autoplay {
|
if !autoplay {
|
||||||
@@ -78,8 +78,7 @@ public class GifView: ExpoView, AVPlayerViewControllerDelegate {
|
|||||||
// See:
|
// See:
|
||||||
// https://github.com/SDWebImage/SDWebImage/blob/master/Docs/HowToUse.md#using-asynchronous-image-caching-independently
|
// https://github.com/SDWebImage/SDWebImage/blob/master/Docs/HowToUse.md#using-asynchronous-image-caching-independently
|
||||||
if !SDImageCache.shared.diskImageDataExists(withKey: source),
|
if !SDImageCache.shared.diskImageDataExists(withKey: source),
|
||||||
let url = URL(string: placeholderSource)
|
let url = URL(string: placeholderSource) {
|
||||||
{
|
|
||||||
self.placeholderOperation = imageManager.loadImage(
|
self.placeholderOperation = imageManager.loadImage(
|
||||||
with: url,
|
with: url,
|
||||||
options: [.retryFailed],
|
options: [.retryFailed],
|
||||||
@@ -132,8 +131,7 @@ public class GifView: ExpoView, AVPlayerViewControllerDelegate {
|
|||||||
if let placeholderSource = self.placeholderSource,
|
if let placeholderSource = self.placeholderSource,
|
||||||
imageUrl?.absoluteString == placeholderSource,
|
imageUrl?.absoluteString == placeholderSource,
|
||||||
self.imageView.image == nil,
|
self.imageView.image == nil,
|
||||||
let image = image
|
let image = image {
|
||||||
{
|
|
||||||
self.setImage(image)
|
self.setImage(image)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -142,8 +140,7 @@ public class GifView: ExpoView, AVPlayerViewControllerDelegate {
|
|||||||
imageUrl?.absoluteString == source,
|
imageUrl?.absoluteString == source,
|
||||||
// UIImage perf suckssss if the image is animated
|
// UIImage perf suckssss if the image is animated
|
||||||
let data = data,
|
let data = data,
|
||||||
let animatedImage = SDAnimatedImage(data: data)
|
let animatedImage = SDAnimatedImage(data: data) {
|
||||||
{
|
|
||||||
self.placeholderOperation?.cancel()
|
self.placeholderOperation?.cancel()
|
||||||
self.isPlaying = self.autoplay
|
self.isPlaying = self.autoplay
|
||||||
self.isLoaded = true
|
self.isLoaded = true
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ class ExpoScrollForwarderView: ExpoView, UIGestureRecognizerDelegate {
|
|||||||
self.cancelGestureRecognizers = [lpg, tg]
|
self.cancelGestureRecognizers = [lpg, tg]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// We don't want to recognize the scroll pan gesture and the swipe back gesture together
|
// We don't want to recognize the scroll pan gesture and the swipe back gesture together
|
||||||
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||||
if gestureRecognizer is UIPanGestureRecognizer, otherGestureRecognizer is UIPanGestureRecognizer {
|
if gestureRecognizer is UIPanGestureRecognizer, otherGestureRecognizer is UIPanGestureRecognizer {
|
||||||
@@ -64,11 +63,11 @@ class ExpoScrollForwarderView: ExpoView, UIGestureRecognizerDelegate {
|
|||||||
|
|
||||||
// This will be used to cancel the animation whenever we press inside of the scroll view. We don't want to change
|
// This will be used to cancel the animation whenever we press inside of the scroll view. We don't want to change
|
||||||
// the scroll view gesture's delegate, so we add an additional recognizer to detect this.
|
// the scroll view gesture's delegate, so we add an additional recognizer to detect this.
|
||||||
@IBAction func callOnPress(_ sender: UITapGestureRecognizer) -> Void {
|
@IBAction func callOnPress(_ sender: UITapGestureRecognizer) {
|
||||||
self.stopTimer()
|
self.stopTimer()
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func callOnPan(_ sender: UIPanGestureRecognizer) -> Void {
|
@IBAction func callOnPan(_ sender: UIPanGestureRecognizer) {
|
||||||
guard let rctsv = self.rctScrollView, let sv = rctsv.scrollView else {
|
guard let rctsv = self.rctScrollView, let sv = rctsv.scrollView else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -129,7 +128,7 @@ class ExpoScrollForwarderView: ExpoView, UIGestureRecognizerDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var animTranslation = -translation
|
var animTranslation = -translation
|
||||||
self.animTimer = Timer.scheduledTimer(withTimeInterval: 1.0 / 120, repeats: true) { timer in
|
self.animTimer = Timer.scheduledTimer(withTimeInterval: 1.0 / 120, repeats: true) { _ in
|
||||||
velocity *= 0.9875
|
velocity *= 0.9875
|
||||||
animTranslation = (-velocity / 120) + animTranslation
|
animTranslation = (-velocity / 120) + animTranslation
|
||||||
|
|
||||||
@@ -190,7 +189,6 @@ class ExpoScrollForwarderView: ExpoView, UIGestureRecognizerDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func enableCancelGestureRecognizers() {
|
func enableCancelGestureRecognizers() {
|
||||||
self.cancelGestureRecognizers?.forEach { r in
|
self.cancelGestureRecognizers?.forEach { r in
|
||||||
r.isEnabled = true
|
r.isEnabled = true
|
||||||
@@ -203,11 +201,11 @@ class ExpoScrollForwarderView: ExpoView, UIGestureRecognizerDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func scrollToOffset(_ offset: Int, animated: Bool = true) -> Void {
|
func scrollToOffset(_ offset: Int, animated: Bool = true) {
|
||||||
self.rctScrollView?.scroll(toOffset: CGPoint(x: 0, y: offset), animated: animated)
|
self.rctScrollView?.scroll(toOffset: CGPoint(x: 0, y: offset), animated: animated)
|
||||||
}
|
}
|
||||||
|
|
||||||
func stopTimer() -> Void {
|
func stopTimer() {
|
||||||
self.disableCancelGestureRecognizers()
|
self.disableCancelGestureRecognizers()
|
||||||
self.animTimer?.invalidate()
|
self.animTimer?.invalidate()
|
||||||
self.animTimer = nil
|
self.animTimer = nil
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
"test-ci": "NODE_ENV=test jest --ci --forceExit --reporters=default --reporters=jest-junit",
|
"test-ci": "NODE_ENV=test jest --ci --forceExit --reporters=default --reporters=jest-junit",
|
||||||
"test-coverage": "NODE_ENV=test jest --coverage",
|
"test-coverage": "NODE_ENV=test jest --coverage",
|
||||||
"lint": "eslint --cache --ext .js,.jsx,.ts,.tsx src",
|
"lint": "eslint --cache --ext .js,.jsx,.ts,.tsx src",
|
||||||
|
"lint-native": "swiftlint ./modules && ktlint ./modules",
|
||||||
|
"lint-native:fix": "swiftlint --fix ./modules && ktlint --format ./modules",
|
||||||
"typecheck": "tsc --project ./tsconfig.check.json",
|
"typecheck": "tsc --project ./tsconfig.check.json",
|
||||||
"e2e:mock-server": "./jest/dev-infra/with-test-redis-and-db.sh ts-node --project tsconfig.e2e.json __e2e__/mock-server.ts",
|
"e2e:mock-server": "./jest/dev-infra/with-test-redis-and-db.sh ts-node --project tsconfig.e2e.json __e2e__/mock-server.ts",
|
||||||
"e2e:metro": "EXPO_PUBLIC_ENV=e2e NODE_ENV=test RN_SRC_EXT=e2e.ts,e2e.tsx expo run:ios",
|
"e2e:metro": "EXPO_PUBLIC_ENV=e2e NODE_ENV=test RN_SRC_EXT=e2e.ts,e2e.tsx expo run:ios",
|
||||||
|
|||||||
Reference in New Issue
Block a user