mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
disableDeleteChatSwipeOption + refactor restart alert
This commit is contained in:
parent
58f020eeef
commit
44fe90b317
@ -35,6 +35,7 @@ swift_library(
|
||||
"//submodules/AccountContext:AccountContext",
|
||||
"//submodules/AppBundle:AppBundle",
|
||||
"//submodules/TelegramUI/Components/Settings/PeerNameColorScreen",
|
||||
"//submodules/UndoUI:UndoUI",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -22,6 +22,7 @@ import AccountContext
|
||||
import AppBundle
|
||||
import WebKit
|
||||
import PeerNameColorScreen
|
||||
import UndoUI
|
||||
|
||||
|
||||
private enum SGControllerSection: Int32, SGItemListSection {
|
||||
@ -56,6 +57,7 @@ private enum SGBoolSetting: String {
|
||||
case sendLargePhotos
|
||||
case storyStealthMode
|
||||
case disableSwipeToRecordStory
|
||||
case disableDeleteChatSwipeOption
|
||||
case quickTranslateButton
|
||||
case hideReactions
|
||||
case showRepostToStory
|
||||
@ -151,6 +153,7 @@ private func SGControllerEntries(presentationData: PresentationData, callListSet
|
||||
entries.append(.header(id: id.count, section: .chatList, text: i18n("Settings.ChatList.Header", lang), badge: nil))
|
||||
entries.append(.toggle(id: id.count, section: .chatList, settingName: .compactChatList, value: SGSimpleSettings.shared.compactChatList, text: i18n("Settings.CompactChatList", lang), enabled: true))
|
||||
entries.append(.toggle(id: id.count, section: .chatList, settingName: .disableChatSwipeOptions, value: !SGSimpleSettings.shared.disableChatSwipeOptions, text: i18n("Settings.ChatSwipeOptions", lang), enabled: true))
|
||||
entries.append(.toggle(id: id.count, section: .chatList, settingName: .disableDeleteChatSwipeOption, value: !SGSimpleSettings.shared.disableDeleteChatSwipeOption, text: i18n("Settings.DeleteChatSwipeOption", lang), enabled: !SGSimpleSettings.shared.disableChatSwipeOptions))
|
||||
|
||||
entries.append(.header(id: id.count, section: .profiles, text: i18n("Settings.Profiles.Header", lang), badge: nil))
|
||||
entries.append(.toggle(id: id.count, section: .profiles, settingName: .showProfileId, value: SGSettings.showProfileId, text: i18n("Settings.ShowProfileID", lang), enabled: true))
|
||||
@ -386,6 +389,10 @@ public func sgSettingsController(context: AccountContext/*, focusOnItemTag: Int?
|
||||
SGSimpleSettings.shared.disableScrollToNextTopic = !value
|
||||
case .disableChatSwipeOptions:
|
||||
SGSimpleSettings.shared.disableChatSwipeOptions = !value
|
||||
simplePromise.set(true) // Trigger update for 'enabled' field of other toggles
|
||||
askForRestart?()
|
||||
case .disableDeleteChatSwipeOption:
|
||||
SGSimpleSettings.shared.disableDeleteChatSwipeOption = !value
|
||||
askForRestart?()
|
||||
case .disableGalleryCamera:
|
||||
SGSimpleSettings.shared.disableGalleryCamera = !value
|
||||
@ -622,18 +629,19 @@ public func sgSettingsController(context: AccountContext/*, focusOnItemTag: Int?
|
||||
return
|
||||
}
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let actionSheet = ActionSheetController(presentationData: presentationData)
|
||||
actionSheet.setItemGroups([ActionSheetItemGroup(items: [
|
||||
ActionSheetTextItem(title: i18n("Common.RestartRequired", presentationData.strings.baseLanguageCode)),
|
||||
ActionSheetButtonItem(title: i18n("Common.RestartNow", presentationData.strings.baseLanguageCode), color: .destructive, font: .default, action: {
|
||||
exit(0)
|
||||
})
|
||||
]), ActionSheetItemGroup(items: [
|
||||
ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
})
|
||||
])])
|
||||
presentControllerImpl?(actionSheet, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||
presentControllerImpl?(
|
||||
UndoOverlayController(
|
||||
presentationData: presentationData,
|
||||
content: .info(title: nil, // i18n("Common.RestartRequired", presentationData.strings.baseLanguageCode),
|
||||
text: i18n("Common.RestartRequired", presentationData.strings.baseLanguageCode),
|
||||
timeout: nil,
|
||||
customUndoText: i18n("Common.RestartNow", presentationData.strings.baseLanguageCode) //presentationData.strings.Common_Yes
|
||||
),
|
||||
elevatedLayout: false,
|
||||
action: { action in if action == .undo { exit(0) }; return true }
|
||||
),
|
||||
nil
|
||||
)
|
||||
}
|
||||
return controller
|
||||
|
||||
|
@ -80,6 +80,7 @@ public class SGSimpleSettings {
|
||||
case disableScrollToNextChannel
|
||||
case disableScrollToNextTopic
|
||||
case disableChatSwipeOptions
|
||||
case disableDeleteChatSwipeOption
|
||||
case disableGalleryCamera
|
||||
case disableSendAsButton
|
||||
case disableSnapDeletionEffect
|
||||
@ -168,6 +169,7 @@ public class SGSimpleSettings {
|
||||
Keys.disableScrollToNextChannel.rawValue: false,
|
||||
Keys.disableScrollToNextTopic.rawValue: false,
|
||||
Keys.disableChatSwipeOptions.rawValue: false,
|
||||
Keys.disableDeleteChatSwipeOption.rawValue: false,
|
||||
Keys.disableGalleryCamera.rawValue: false,
|
||||
Keys.disableSendAsButton.rawValue: false,
|
||||
Keys.disableSnapDeletionEffect.rawValue: false,
|
||||
@ -289,6 +291,9 @@ public class SGSimpleSettings {
|
||||
@UserDefault(key: Keys.disableChatSwipeOptions.rawValue)
|
||||
public var disableChatSwipeOptions: Bool
|
||||
|
||||
@UserDefault(key: Keys.disableDeleteChatSwipeOption.rawValue)
|
||||
public var disableDeleteChatSwipeOption: Bool
|
||||
|
||||
@UserDefault(key: Keys.disableGalleryCamera.rawValue)
|
||||
public var disableGalleryCamera: Bool
|
||||
|
||||
|
@ -100,6 +100,7 @@
|
||||
|
||||
|
||||
"Settings.ChatSwipeOptions" = "Chat List Swipe Options";
|
||||
"Settings.DeleteChatSwipeOption" = "Swipe to Delete Chat";
|
||||
/* Re-word like this string on offical app https://translations.telegram.org/en/ios/groups_and_channels/Chat.NextChannelSameLocationSwipeProgress */
|
||||
"Settings.PullToNextChannel" = "Pull to Next Unread Channel";
|
||||
/* Re-word like this string on offical app https://translations.telegram.org/en/ios/groups_and_channels/Chat.NextUnreadTopicSwipeProgress */
|
||||
|
@ -619,7 +619,7 @@ private func revealOptions(strings: PresentationStrings, theme: PresentationThem
|
||||
}
|
||||
}
|
||||
}
|
||||
if canDelete {
|
||||
if canDelete && !SGSimpleSettings.shared.disableDeleteChatSwipeOption {
|
||||
options.append(ItemListRevealOption(key: RevealOptionKey.delete.rawValue, title: strings.Common_Delete, icon: deleteIcon, color: theme.list.itemDisclosureActions.destructive.fillColor, textColor: theme.list.itemDisclosureActions.destructive.foregroundColor))
|
||||
}
|
||||
if case .savedMessagesChats = location {
|
||||
@ -707,7 +707,7 @@ private func forumThreadRevealOptions(strings: PresentationStrings, theme: Prese
|
||||
}
|
||||
}
|
||||
}
|
||||
if canDelete {
|
||||
if canDelete && !SGSimpleSettings.shared.disableDeleteChatSwipeOption {
|
||||
options.append(ItemListRevealOption(key: RevealOptionKey.delete.rawValue, title: strings.Common_Delete, icon: deleteIcon, color: theme.list.itemDisclosureActions.destructive.fillColor, textColor: theme.list.itemDisclosureActions.destructive.foregroundColor))
|
||||
}
|
||||
if canOpenClose {
|
||||
@ -3282,6 +3282,7 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
|
||||
ItemListRevealOption(key: RevealOptionKey.edit.rawValue, title: item.presentationData.strings.ChatList_ItemMenuEdit, icon: .none, color: item.presentationData.theme.list.itemDisclosureActions.neutral2.fillColor, textColor: item.presentationData.theme.list.itemDisclosureActions.neutral2.foregroundColor),
|
||||
ItemListRevealOption(key: RevealOptionKey.delete.rawValue, title: item.presentationData.strings.ChatList_ItemMenuDelete, icon: .none, color: item.presentationData.theme.list.itemDisclosureActions.destructive.fillColor, textColor: item.presentationData.theme.list.itemDisclosureActions.destructive.foregroundColor)
|
||||
]
|
||||
if SGSimpleSettings.shared.disableDeleteChatSwipeOption { peerRevealOptions.removeLast() }
|
||||
} else {
|
||||
peerRevealOptions = []
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user