Skip to content

Commit

Permalink
Sync Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Lakr233 committed Aug 5, 2023
1 parent 428f92e commit 54d0019
Show file tree
Hide file tree
Showing 16 changed files with 599 additions and 274 deletions.
16 changes: 16 additions & 0 deletions Foundation/Source/Sources/ModuleBridge/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@ public extension User {
}

public extension UserProfile {
static func converting(_ user: User?) -> UserProfile? {
guard let user else { return nil }
return UserProfile(
userId: user.userId,
name: user.name,
username: user.username,
host: user.host,
avatarUrl: user.avatarUrl,
avatarBlurhash: user.avatarBlurHash,
isAdmin: user.isAdmin,
isModerator: user.isModerator,
isBot: user.isBot,
isCat: user.isCat
)
}

static func converting(_ userDetails: NMUserDetails?, defaultHost: String) -> UserProfile? {
guard let userDetails else { return nil }
guard let date = userDetails.createdAt.toISODate(nil, region: nil)?.date else {
Expand Down
62 changes: 57 additions & 5 deletions Kimis.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@
50BED2262927802700C9D7E2 /* SPIndicator in Frameworks */ = {isa = PBXBuildFile; productRef = 50BED2252927802700C9D7E2 /* SPIndicator */; };
50BED238292789FE00C9D7E2 /* NoteAttachmentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50BED22D292789FE00C9D7E2 /* NoteAttachmentView.swift */; };
50BED23A292789FE00C9D7E2 /* NoteAttachmentView+Elemet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50BED22F292789FE00C9D7E2 /* NoteAttachmentView+Elemet.swift */; };
50CEBEBB2A6A455900484FD8 /* UserSimpleBannerListTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50CEBEB42A6A455900484FD8 /* UserSimpleBannerListTableView.swift */; };
50CEBEBC2A6A455900484FD8 /* UserSimpleBannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50CEBEB62A6A455900484FD8 /* UserSimpleBannerView.swift */; };
50CEBEBD2A6A455900484FD8 /* UserSimpleBannerCell+Render.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50CEBEB82A6A455900484FD8 /* UserSimpleBannerCell+Render.swift */; };
50CEBEBE2A6A455900484FD8 /* UserSimpleBannerCell+Context.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50CEBEB92A6A455900484FD8 /* UserSimpleBannerCell+Context.swift */; };
50CEBEBF2A6A455900484FD8 /* UserSimpleBannerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50CEBEBA2A6A455900484FD8 /* UserSimpleBannerCell.swift */; };
50D3CC8B295D831500D5CE6A /* TableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50D3CC8A295D831500D5CE6A /* TableView.swift */; };
50D7B1722970FF3000E12904 /* PostEditorPollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50D7B1712970FF3000E12904 /* PostEditorPollView.swift */; };
50D7B17429710B5500E12904 /* PostEditorPollView+Delegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50D7B17329710B5500E12904 /* PostEditorPollView+Delegate.swift */; };
Expand Down Expand Up @@ -485,6 +490,11 @@
50BED1B529277D0E00C9D7E2 /* TextParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextParser.swift; sourceTree = "<group>"; };
50BED22D292789FE00C9D7E2 /* NoteAttachmentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoteAttachmentView.swift; sourceTree = "<group>"; };
50BED22F292789FE00C9D7E2 /* NoteAttachmentView+Elemet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NoteAttachmentView+Elemet.swift"; sourceTree = "<group>"; };
50CEBEB42A6A455900484FD8 /* UserSimpleBannerListTableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserSimpleBannerListTableView.swift; sourceTree = "<group>"; };
50CEBEB62A6A455900484FD8 /* UserSimpleBannerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserSimpleBannerView.swift; sourceTree = "<group>"; };
50CEBEB82A6A455900484FD8 /* UserSimpleBannerCell+Render.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UserSimpleBannerCell+Render.swift"; sourceTree = "<group>"; };
50CEBEB92A6A455900484FD8 /* UserSimpleBannerCell+Context.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UserSimpleBannerCell+Context.swift"; sourceTree = "<group>"; };
50CEBEBA2A6A455900484FD8 /* UserSimpleBannerCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserSimpleBannerCell.swift; sourceTree = "<group>"; };
50D3CC8A295D831500D5CE6A /* TableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableView.swift; sourceTree = "<group>"; };
50D7B1712970FF3000E12904 /* PostEditorPollView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostEditorPollView.swift; sourceTree = "<group>"; };
50D7B17329710B5500E12904 /* PostEditorPollView+Delegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PostEditorPollView+Delegate.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1133,6 +1143,7 @@
50BED16C29277D0E00C9D7E2 /* NoteTableView */,
504E87C42937594500BDE03C /* NotificationTableView */,
5069EBB5295EE2AC00677A3F /* UsersListTableView */,
50CEBEB22A6A455900484FD8 /* UserSimpleBannerListTableView */,
50FE1B132933A3E7000CE139 /* TrendingTableView */,
50BED18029277D0E00C9D7E2 /* EmojiPicker */,
);
Expand Down Expand Up @@ -1363,6 +1374,43 @@
name = Frameworks;
sourceTree = "<group>";
};
50CEBEB22A6A455900484FD8 /* UserSimpleBannerListTableView */ = {
isa = PBXGroup;
children = (
50CEBEB32A6A455900484FD8 /* UserSimpleBannerListTableView */,
50CEBEB52A6A455900484FD8 /* UserSimpleBannerView */,
50CEBEB72A6A455900484FD8 /* UserCell */,
);
name = UserSimpleBannerListTableView;
path = Kimis/Interface/Component/UserSimpleBannerListTableView;
sourceTree = SOURCE_ROOT;
};
50CEBEB32A6A455900484FD8 /* UserSimpleBannerListTableView */ = {
isa = PBXGroup;
children = (
50CEBEB42A6A455900484FD8 /* UserSimpleBannerListTableView.swift */,
);
path = UserSimpleBannerListTableView;
sourceTree = "<group>";
};
50CEBEB52A6A455900484FD8 /* UserSimpleBannerView */ = {
isa = PBXGroup;
children = (
50CEBEB62A6A455900484FD8 /* UserSimpleBannerView.swift */,
);
path = UserSimpleBannerView;
sourceTree = "<group>";
};
50CEBEB72A6A455900484FD8 /* UserCell */ = {
isa = PBXGroup;
children = (
50CEBEB82A6A455900484FD8 /* UserSimpleBannerCell+Render.swift */,
50CEBEB92A6A455900484FD8 /* UserSimpleBannerCell+Context.swift */,
50CEBEBA2A6A455900484FD8 /* UserSimpleBannerCell.swift */,
);
path = UserCell;
sourceTree = "<group>";
};
50D3CC84295D4D1500D5CE6A /* LoadingController */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1528,13 +1576,15 @@
5020160329704EC600C57E39 /* PostEditorAttachmentView+Cell.swift in Sources */,
508FE99A292B54E9005D1933 /* NSAttributeString.swift in Sources */,
504519A3296D55EC009D613D /* Toolbar+File.swift in Sources */,
50CEBEBE2A6A455900484FD8 /* UserSimpleBannerCell+Context.swift in Sources */,
50BED1D529277D0E00C9D7E2 /* TimelineTableView.swift in Sources */,
502F6E582968738F003691BE /* ToolbarView.swift in Sources */,
50AFDFE929305E9B00BEC741 /* NoteOperationStrip+More.swift in Sources */,
508FC83029632AB200B032D8 /* AnySnapshot.swift in Sources */,
50FAC1F32A651B4000125B2A /* ReactionStrip+BaseView.swift in Sources */,
504E87CE293779C200BDE03C /* NotificationTableView+Publisher.swift in Sources */,
504519A6296D55EC009D613D /* Toolbar+User.swift in Sources */,
50CEBEBD2A6A455900484FD8 /* UserSimpleBannerCell+Render.swift in Sources */,
50BED20129277D0E00C9D7E2 /* TextParser+TinyEmoji.swift in Sources */,
504E87D229377A3000BDE03C /* NotificationTableView+Delegate.swift in Sources */,
50BED20929277D0E00C9D7E2 /* Enumerator.swift in Sources */,
Expand Down Expand Up @@ -1567,6 +1617,7 @@
50A2F3792934B4B400DE9464 /* NoteCell+Pinned.swift in Sources */,
508FE98F292B3C40005D1933 /* NoteCell+ContextBuilder.swift in Sources */,
50BED1E729277D0E00C9D7E2 /* LargeTimelineController.swift in Sources */,
50CEBEBB2A6A455900484FD8 /* UserSimpleBannerListTableView.swift in Sources */,
50BED1FE29277D0E00C9D7E2 /* TextParser+Visibility.swift in Sources */,
50BED1BA29277D0E00C9D7E2 /* EncryptedCodableDefault.swift in Sources */,
5057A942296180C90088A6D4 /* PollView.swift in Sources */,
Expand Down Expand Up @@ -1680,6 +1731,7 @@
50FE1B192933AFF9000CE139 /* TrendingTableView+Cell.swift in Sources */,
505E10C9292E110D001F9141 /* NoteCell+Reply.swift in Sources */,
50AFDFE529305E9200BEC741 /* NoteOperationStrip+Reaction.swift in Sources */,
50CEBEBF2A6A455900484FD8 /* UserSimpleBannerCell.swift in Sources */,
5069EBC2295EEAB000677A3F /* UserCell+Context.swift in Sources */,
50D7B1722970FF3000E12904 /* PostEditorPollView.swift in Sources */,
50BED1D329277D0E00C9D7E2 /* NoteTableView.swift in Sources */,
Expand Down Expand Up @@ -1718,6 +1770,7 @@
50BED1C229277D0E00C9D7E2 /* TextView.swift in Sources */,
5065E4E429352B22001C540C /* TextParser+Email.swift in Sources */,
50BED20329277D0E00C9D7E2 /* TextParser+Body.swift in Sources */,
50CEBEBC2A6A455900484FD8 /* UserSimpleBannerView.swift in Sources */,
50126253292F7752002E1636 /* ReactionStrip+EmojiView.swift in Sources */,
50126247292F3945002E1636 /* NoteCell+Progress.swift in Sources */,
50BED1C629277D0E00C9D7E2 /* UIFont.swift in Sources */,
Expand Down Expand Up @@ -1871,7 +1924,7 @@
CODE_SIGN_ENTITLEMENTS = Kimis/KimisDebug.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 151;
CURRENT_PROJECT_VERSION = 152;
DEVELOPMENT_TEAM = 6CMYQQFFT8;
"ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -1910,7 +1963,7 @@
CODE_SIGN_ENTITLEMENTS = Kimis/Kimis.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 151;
CURRENT_PROJECT_VERSION = 152;
DEVELOPMENT_TEAM = 6CMYQQFFT8;
"ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -2040,9 +2093,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/hackiftekhar/IQKeyboardManager";
requirement = {
kind = versionRange;
maximumVersion = 999.999.999;
minimumVersion = 0.0.0;
kind = exactVersion;
version = 6.5.11;
};
};
50BED2242927802700C9D7E2 /* XCRemoteSwiftPackageReference "SPIndicator" */ = {
Expand Down
8 changes: 4 additions & 4 deletions Kimis.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/bugsnag/bugsnag-cocoa",
"state" : {
"revision" : "c730af7a4676617d82394782300df997d9a356cd",
"version" : "6.26.2"
"revision" : "2f373f21b965f1b13d7070662e2d35f46c17d975",
"version" : "6.27.2"
}
},
{
Expand Down Expand Up @@ -59,8 +59,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/SDWebImage/SDWebImage",
"state" : {
"revision" : "3289629ef6cbf1ad8c3d1dccf0cf09ac97547cd6",
"version" : "5.15.7"
"revision" : "633996a807442ec28df9d33b0f88ce57a0e2fdbf",
"version" : "5.17.0"
}
},
{
Expand Down
11 changes: 8 additions & 3 deletions Kimis/Backend/TextParser/Helper/TextParser+Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ extension TextParser {

class RemoteImageAttachment: SubviewTextAttachment {
let provider: TextAttachedViewProvider
init(url: URL, size: CGSize) {
provider = RemoteImageAttachmentProvider(url: url, size: size)
init(url: URL, size: CGSize, cornerRadius: CGFloat = 0) {
provider = RemoteImageAttachmentProvider(url: url, size: size, cornerRadius: cornerRadius)
super.init(viewProvider: provider)
}

Expand All @@ -74,9 +74,12 @@ extension TextParser {
private class RemoteImageAttachmentProvider: TextAttachedViewProvider {
let url: URL
let size: CGSize
init(url: URL, size: CGSize) {
let cornerRadius: CGFloat

init(url: URL, size: CGSize, cornerRadius: CGFloat = 0) {
self.url = url
self.size = size
self.cornerRadius = cornerRadius
}

@available(*, unavailable)
Expand All @@ -89,6 +92,8 @@ extension TextParser {
view.contentMode = .scaleAspectFit
view.layer.minificationFilter = .trilinear
view.sd_setImage(with: url, placeholderImage: placeholder, options: [], completed: nil)
view.clipsToBounds = true
view.layer.cornerRadius = cornerRadius
return view
}

Expand Down
23 changes: 23 additions & 0 deletions Kimis/Backend/TextParser/Render/TextParser+User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,27 @@ extension TextParser {
decodingIDNAIfNeeded(modifyingStringInPlace: ans)
return finalize(ans, defaultHost: user.host)
}

func compileUserBanner(withUser user: User) -> NSMutableAttributedString {
var strings: [NSMutableAttributedString] = []
if let url = URL(string: user.avatarUrl) {
strings.append(
NSMutableAttributedString(
attachment: RemoteImageAttachment(url: url, size: CGSize(width: size.base, height: size.base), cornerRadius: 8)
)
)
}
strings.append(
NSMutableAttributedString(
string: user.name,
attributes: [
.font: getFont(size: size.base, weight: weight.base),
.link: "username://\(user.absoluteUsername.base64Encoded ?? "")",
]
)
)
let ans = connect(strings: strings, separator: " ")
decodingIDNAIfNeeded(modifyingStringInPlace: ans)
return finalize(ans, defaultHost: user.host)
}
}
18 changes: 13 additions & 5 deletions Kimis/Extension/UIKit/UIViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ extension UIViewController {
}

func present(next: UIViewController) {
guard let presenter = topMostController else {
print("[E] failed to find top most controller for present")
return
}
guard let presenter = topMostController else { return }
if let navigator = presenter.navigationController,
!(next is UINavigationController),
!(next is UIAlertController),
Expand All @@ -81,7 +78,8 @@ extension UIViewController {
var result: UIViewController? = self
while true {
if let next = result?.presentedViewController,
!next.isBeingDismissed
!next.isBeingDismissed,
next as? UISearchController == nil
{
result = next
continue
Expand Down Expand Up @@ -112,6 +110,16 @@ extension UIViewController {
result = target.associatedNavigationController
continue
}
if let target = result as? RootController,
let newTarget = target.controller
{
result = newTarget
continue
}
if let target = result as? SideBarController {
result = target.contentController
continue
}
break
}
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ extension ReactionStrip {
}
}

@objc func longPress(_ guesture: UILongPressGestureRecognizer) {
@objc func longPress(_: UILongPressGestureRecognizer) {
// eat this event, let context menu to handle
// if guesture.state == .began { postLongPress() }
}
Expand Down
Loading

0 comments on commit 54d0019

Please sign in to comment.