mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-08 19:10:53 +00:00
Various improvements
This commit is contained in:
parent
6405f365a9
commit
2713bcee1d
@ -14994,3 +14994,5 @@ Sorry for the inconvenience.";
|
||||
"Gift.Value.AveragePrice" = "Average Price";
|
||||
"Gift.Value.ForSaleOnTelegram" = "for sale on Telegram";
|
||||
"Gift.Value.ForSaleOnFragment" = "for sale on Fragment";
|
||||
|
||||
"Gift.View.Context.SetAsTheme" = "Set as Theme in...";
|
||||
|
@ -552,7 +552,7 @@ public final class UniqueGiftChatThemesContext {
|
||||
self.pushState()
|
||||
}
|
||||
|
||||
let signal = network.request(Api.functions.account.getUniqueGiftChatThemes(offset: offset, limit: 32, hash: 0))
|
||||
let signal = network.request(Api.functions.account.getUniqueGiftChatThemes(offset: offset, limit: 50, hash: 0))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { error in
|
||||
return .single(nil)
|
||||
|
@ -933,8 +933,19 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, ASScrollViewDelega
|
||||
strings: presentationData.strings,
|
||||
wallpaper: nil
|
||||
))
|
||||
for theme in uniqueGiftChatThemesState.themes {
|
||||
guard case let .gift(gift, themeSettings) = theme else {
|
||||
|
||||
var giftThemes = uniqueGiftChatThemesState.themes
|
||||
var existingIds = Set<String>()
|
||||
if let initiallySelectedTheme, case .gift = initiallySelectedTheme {
|
||||
let initialThemeIndex = giftThemes.firstIndex(where: { $0.id == initiallySelectedTheme.id })
|
||||
if initialThemeIndex == nil || initialThemeIndex! > 50 {
|
||||
giftThemes.insert(initiallySelectedTheme, at: 0)
|
||||
existingIds.insert(initiallySelectedTheme.id)
|
||||
}
|
||||
}
|
||||
|
||||
for theme in giftThemes {
|
||||
guard case let .gift(gift, themeSettings) = theme, !existingIds.contains(theme.id) else {
|
||||
continue
|
||||
}
|
||||
var emojiFile: TelegramMediaFile?
|
||||
@ -945,18 +956,20 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, ASScrollViewDelega
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var wallpaper: TelegramWallpaper?
|
||||
let themeReference: PresentationThemeReference
|
||||
let wallpaper: TelegramWallpaper?
|
||||
if isDarkAppearance {
|
||||
wallpaper = themeSettings.first(where: { $0.baseTheme == .night || $0.baseTheme == .tinted })?.wallpaper
|
||||
themeReference = .builtin(.night)
|
||||
} else {
|
||||
wallpaper = themeSettings.first(where: { $0.baseTheme == .classic || $0.baseTheme == .day })?.wallpaper
|
||||
themeReference = .builtin(.dayClassic)
|
||||
}
|
||||
entries.append(ThemeSettingsThemeEntry(
|
||||
index: entries.count,
|
||||
chatTheme: theme,
|
||||
emojiFile: emojiFile,
|
||||
themeReference: .builtin(.dayClassic),
|
||||
themeReference: themeReference,
|
||||
peer: nil,
|
||||
nightMode: isDarkAppearance,
|
||||
selected: selectedTheme?.id == theme.id,
|
||||
@ -965,33 +978,35 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, ASScrollViewDelega
|
||||
wallpaper: wallpaper
|
||||
))
|
||||
}
|
||||
for theme in themes {
|
||||
guard let emoticon = theme.emoticon else {
|
||||
continue
|
||||
|
||||
if uniqueGiftChatThemesState.themes.count == 0 || uniqueGiftChatThemesState.dataState == .ready(canLoadMore: false) {
|
||||
for theme in themes {
|
||||
guard let emoticon = theme.emoticon else {
|
||||
continue
|
||||
}
|
||||
entries.append(ThemeSettingsThemeEntry(
|
||||
index: entries.count,
|
||||
chatTheme: .emoticon(emoticon),
|
||||
emojiFile: animatedEmojiStickers[emoticon]?.first?.file._parse(),
|
||||
themeReference: .cloud(PresentationCloudTheme(theme: theme, resolvedWallpaper: nil, creatorAccountId: nil)),
|
||||
peer: nil,
|
||||
nightMode: isDarkAppearance,
|
||||
selected: selectedTheme?.id == ChatTheme.emoticon(emoticon).id,
|
||||
theme: presentationData.theme,
|
||||
strings: presentationData.strings,
|
||||
wallpaper: nil
|
||||
))
|
||||
}
|
||||
entries.append(ThemeSettingsThemeEntry(
|
||||
index: entries.count,
|
||||
chatTheme: .emoticon(emoticon),
|
||||
emojiFile: animatedEmojiStickers[emoticon]?.first?.file._parse(),
|
||||
themeReference: .cloud(PresentationCloudTheme(theme: theme, resolvedWallpaper: nil, creatorAccountId: nil)),
|
||||
peer: nil,
|
||||
nightMode: isDarkAppearance,
|
||||
selected: selectedTheme?.id == ChatTheme.emoticon(emoticon).id,
|
||||
theme: presentationData.theme,
|
||||
strings: presentationData.strings,
|
||||
wallpaper: nil
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
let action: (ChatTheme?) -> Void = { [weak self] chatTheme in
|
||||
if let self, self.selectedTheme != chatTheme {
|
||||
self.setChatTheme(chatTheme)
|
||||
}
|
||||
}
|
||||
let previousEntries = strongSelf.entries ?? []
|
||||
let crossfade = previousEntries.count != entries.count
|
||||
let transition = preparedTransition(context: strongSelf.context, action: action, from: previousEntries, to: entries, crossfade: crossfade)
|
||||
//let crossfade = previousEntries.count != entries.count
|
||||
let transition = preparedTransition(context: strongSelf.context, action: action, from: previousEntries, to: entries, crossfade: false)
|
||||
strongSelf.enqueueTransition(transition)
|
||||
|
||||
strongSelf.entries = entries
|
||||
|
@ -803,6 +803,42 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
controller.present(shareController, in: .window(.root))
|
||||
}
|
||||
|
||||
func setAsGiftTheme() {
|
||||
guard let arguments = self.subject.arguments, let controller = self.getController() as? GiftViewScreen, let navigationController = controller.navigationController as? NavigationController, case let .unique(gift) = arguments.gift else {
|
||||
return
|
||||
}
|
||||
|
||||
let context = self.context
|
||||
let peerController = self.context.sharedContext.makePeerSelectionController(PeerSelectionControllerParams(context: self.context, filter: [.excludeRecent, .doNotSearchMessages], requestPeerType: [.user(.init(isBot: false, isPremium: false))], hasContactSelector: false, hasCreation: false))
|
||||
peerController.peerSelected = { [weak peerController, weak navigationController] peer, _ in
|
||||
let _ = context.engine.themes.setChatTheme(peerId: peer.id, chatTheme: .gift(.unique(gift), [])).start()
|
||||
peerController?.dismiss()
|
||||
|
||||
if let navigationController {
|
||||
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(
|
||||
navigationController: navigationController,
|
||||
chatController: nil,
|
||||
context: context,
|
||||
chatLocation: .peer(peer),
|
||||
subject: nil,
|
||||
botStart: nil,
|
||||
updateTextInputState: nil,
|
||||
keepStack: .always,
|
||||
useExisting: true,
|
||||
purposefulAction: nil,
|
||||
scrollToEndIfExists: false,
|
||||
activateMessageSearch: nil,
|
||||
animated: true
|
||||
))
|
||||
}
|
||||
}
|
||||
self.dismiss(animated: true)
|
||||
|
||||
Queue.mainQueue().after(0.4) {
|
||||
navigationController.pushViewController(peerController)
|
||||
}
|
||||
}
|
||||
|
||||
func transferGift() {
|
||||
guard let arguments = self.subject.arguments, let controller = self.getController() as? GiftViewScreen, case let .unique(gift) = arguments.gift, let reference = arguments.reference, let transferStars = arguments.transferStars else {
|
||||
return
|
||||
@ -1135,6 +1171,16 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
self?.shareGift()
|
||||
})))
|
||||
|
||||
if gift.flags.contains(.isThemeAvailable) {
|
||||
items.append(.action(ContextMenuActionItem(text: presentationData.strings.Gift_View_Context_SetAsTheme, icon: { theme in
|
||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/ApplyTheme"), color: theme.contextMenu.primaryColor)
|
||||
}, action: { [weak self] c, _ in
|
||||
c?.dismiss(completion: nil)
|
||||
|
||||
self?.setAsGiftTheme()
|
||||
})))
|
||||
}
|
||||
|
||||
if let _ = arguments.transferStars {
|
||||
if case let .channel(channel) = peer, !channel.flags.contains(.isCreator) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user