mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 11:23:48 +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.AveragePrice" = "Average Price";
|
||||||
"Gift.Value.ForSaleOnTelegram" = "for sale on Telegram";
|
"Gift.Value.ForSaleOnTelegram" = "for sale on Telegram";
|
||||||
"Gift.Value.ForSaleOnFragment" = "for sale on Fragment";
|
"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()
|
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)
|
|> map(Optional.init)
|
||||||
|> `catch` { error in
|
|> `catch` { error in
|
||||||
return .single(nil)
|
return .single(nil)
|
||||||
|
@ -933,8 +933,19 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, ASScrollViewDelega
|
|||||||
strings: presentationData.strings,
|
strings: presentationData.strings,
|
||||||
wallpaper: nil
|
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
|
continue
|
||||||
}
|
}
|
||||||
var emojiFile: TelegramMediaFile?
|
var emojiFile: TelegramMediaFile?
|
||||||
@ -945,18 +956,20 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, ASScrollViewDelega
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let themeReference: PresentationThemeReference
|
||||||
var wallpaper: TelegramWallpaper?
|
let wallpaper: TelegramWallpaper?
|
||||||
if isDarkAppearance {
|
if isDarkAppearance {
|
||||||
wallpaper = themeSettings.first(where: { $0.baseTheme == .night || $0.baseTheme == .tinted })?.wallpaper
|
wallpaper = themeSettings.first(where: { $0.baseTheme == .night || $0.baseTheme == .tinted })?.wallpaper
|
||||||
|
themeReference = .builtin(.night)
|
||||||
} else {
|
} else {
|
||||||
wallpaper = themeSettings.first(where: { $0.baseTheme == .classic || $0.baseTheme == .day })?.wallpaper
|
wallpaper = themeSettings.first(where: { $0.baseTheme == .classic || $0.baseTheme == .day })?.wallpaper
|
||||||
|
themeReference = .builtin(.dayClassic)
|
||||||
}
|
}
|
||||||
entries.append(ThemeSettingsThemeEntry(
|
entries.append(ThemeSettingsThemeEntry(
|
||||||
index: entries.count,
|
index: entries.count,
|
||||||
chatTheme: theme,
|
chatTheme: theme,
|
||||||
emojiFile: emojiFile,
|
emojiFile: emojiFile,
|
||||||
themeReference: .builtin(.dayClassic),
|
themeReference: themeReference,
|
||||||
peer: nil,
|
peer: nil,
|
||||||
nightMode: isDarkAppearance,
|
nightMode: isDarkAppearance,
|
||||||
selected: selectedTheme?.id == theme.id,
|
selected: selectedTheme?.id == theme.id,
|
||||||
@ -965,24 +978,26 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, ASScrollViewDelega
|
|||||||
wallpaper: wallpaper
|
wallpaper: wallpaper
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
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
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let action: (ChatTheme?) -> Void = { [weak self] chatTheme in
|
let action: (ChatTheme?) -> Void = { [weak self] chatTheme in
|
||||||
if let self, self.selectedTheme != chatTheme {
|
if let self, self.selectedTheme != chatTheme {
|
||||||
@ -990,8 +1005,8 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, ASScrollViewDelega
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let previousEntries = strongSelf.entries ?? []
|
let previousEntries = strongSelf.entries ?? []
|
||||||
let crossfade = previousEntries.count != entries.count
|
//let crossfade = previousEntries.count != entries.count
|
||||||
let transition = preparedTransition(context: strongSelf.context, action: action, from: previousEntries, to: entries, crossfade: crossfade)
|
let transition = preparedTransition(context: strongSelf.context, action: action, from: previousEntries, to: entries, crossfade: false)
|
||||||
strongSelf.enqueueTransition(transition)
|
strongSelf.enqueueTransition(transition)
|
||||||
|
|
||||||
strongSelf.entries = entries
|
strongSelf.entries = entries
|
||||||
|
@ -803,6 +803,42 @@ private final class GiftViewSheetContent: CombinedComponent {
|
|||||||
controller.present(shareController, in: .window(.root))
|
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() {
|
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 {
|
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
|
return
|
||||||
@ -1135,6 +1171,16 @@ private final class GiftViewSheetContent: CombinedComponent {
|
|||||||
self?.shareGift()
|
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 let _ = arguments.transferStars {
|
||||||
if case let .channel(channel) = peer, !channel.flags.contains(.isCreator) {
|
if case let .channel(channel) = peer, !channel.flags.contains(.isCreator) {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user