Skip to content

Commit 70aa25f

Browse files
authored
Label the Recent Actions filter button accurately (#66)
1 parent fe0c2a5 commit 70aa25f

10 files changed

Lines changed: 108 additions & 1 deletion

File tree

86 Bytes
Binary file not shown.

‎packages/ChannelAdminUI/Sources/ChannelAdminUI/ChannelEventLogController.swift‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ public class ChannelEventLogView : View {
157157
settings.autoSizeToFit = false
158158

159159
settings.set(font: .medium(.title), for: .Normal)
160-
settings.set(text: strings().chanelEventFilterSettings, for: .Normal)
161160

162161

163162
setFrameSize(frameRect.size)
@@ -167,6 +166,7 @@ public class ChannelEventLogView : View {
167166
public override func updateLocalizationAndTheme(theme: PresentationTheme) {
168167
super.updateLocalizationAndTheme(theme: theme)
169168
let theme = theme as! TelegramPresentationTheme
169+
settings.set(text: strings().channelEventFilterFilters, for: .Normal) //TODOLANG
170170
settings.set(color: theme.colors.text, for: .Normal)
171171
settings.set(background: .clear, for: .Highlight)
172172
settings.set(background: .clear, for: .Normal)
@@ -180,6 +180,7 @@ public class ChannelEventLogView : View {
180180
info.layer?.cornerRadius = 20
181181
info.setGlassEffect(size: NSMakeSize(40, 40))
182182
info.setAccessibilityLabel(strings().voiceOverCommonInfo)
183+
needsLayout = true
183184
}
184185

185186
func updateState(_ state: ChannelEventLogState) {

‎packages/Localization/Sources/Localization/Localizable.swift‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,6 +2173,7 @@ public final class L10n {
21732173
public static var channelEventFilterAdminsHeader: String { return L10n.tr("Localizable", "Channel.EventFilter.AdminsHeader") }
21742174
/// EVENTS
21752175
public static var channelEventFilterEventsHeader: String { return L10n.tr("Localizable", "Channel.EventFilter.EventsHeader") }
2176+
public static var channelEventFilterFilters: String { return L10n.tr("Localizable", "Channel.EventFilter.Filters") }
21762177
/// Empty
21772178
public static var channelEventLogEmpty: String { return L10n.tr("Localizable", "Channel.EventLog.Empty") }
21782179
/// **No actions found**\n\nNo recent actions that match your query were found.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Recent Actions label captures
2+
3+
Run from the repository root:
4+
5+
```sh
6+
python3 tools/tests/recent-actions-label/run.py --scratch-path /private/tmp/telegram-label-build --snapshots /private/tmp/recent-actions-label
7+
```
8+
9+
The runner reads the English strings file and extracts the actual TextButton setup/styling from ChannelEventLogView. It builds a small native executable against the real TGUIKit and ColorPalette packages, captures Settings/Filters in the same generic footer, and checks that each title fits the centered button. It also verifies the new localization key/accessor and the existing showFilter callback. The old English key is retained for a matching Before capture.
10+
11+
These are native component captures with generic content, not screenshots of an authenticated Recent Actions screen. Only the button setup/styling and string values come from production code; the surrounding title and event text are fixtures. No filter operations or account settings are changed by the executable. Screen-recording permission is needed for captures.
12+
13+
Validated on macOS 27.0.1 / Xcode 27.1. App version/build: N/A, focused component executable. Full Telegram client compilation and a live-account filter dialog test were not performed.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import AppKit
2+
import TGUIKit
3+
import ColorPalette
4+
5+
_ = NSApplication.shared
6+
NSApp.setActivationPolicy(.accessory)
7+
let images = ["Icon_SearchField", "Icon_SearchClear", "Icon_Quote", "Icon_Quote_Collapse", "Icon_Quote_Expand"].map { name in
8+
let image = NSImage(size: NSSize(width: 16, height: 16), flipped: false) { _ in true }
9+
image.setName(name)
10+
return image
11+
}
12+
let initial = PresentationTheme.current
13+
System.updateScaleFactor(2)
14+
System.liquidGlass = true
15+
let window = Window(contentRect: NSMakeRect(150, 150, 620, 220), styleMask: [.borderless], backing: .buffered, defer: false)
16+
window.level = .floating
17+
window.isReleasedWhenClosed = false
18+
window.isOpaque = true
19+
window.hasShadow = false
20+
window.makeKeyAndOrderFront(nil)
21+
for (name, palette) in [("dark", nightAccentPalette), ("light", whitePalette)] {
22+
let theme = PresentationTheme(colors: palette, search: initial.search, inputTheme: initial.inputTheme)
23+
updateTheme(theme)
24+
for (phase, title) in [("before", __BEFORE__), ("after", __AFTER__)] {
25+
let root = View(frame: NSMakeRect(0, 0, 620, 220))
26+
root.backgroundColor = palette.listBackground
27+
window.backgroundColor = palette.listBackground
28+
window.contentView = root
29+
for (text, y, size) in [("Recent Actions", CGFloat(20), CGFloat(17)), ("Alex joined the channel", CGFloat(84), CGFloat(14))] {
30+
let label = NSTextField(labelWithString: text)
31+
label.font = .systemFont(ofSize: size)
32+
label.textColor = size == 17 ? palette.text : palette.grayText
33+
label.frame = NSMakeRect(20, y, 580, 24)
34+
label.alignment = .center
35+
root.addSubview(label)
36+
}
37+
let settings = TextButton()
38+
__SETUP__
39+
__STYLE__
40+
settings.setFrameOrigin(NSMakePoint((root.frame.width - settings.frame.width) / 2, root.frame.height - settings.frame.height - 12))
41+
root.addSubview(settings)
42+
root.layoutSubtreeIfNeeded()
43+
precondition(settings.frame.width >= settings.textSize.width + 30)
44+
precondition(root.bounds.contains(settings.frame))
45+
RunLoop.main.run(until: Date(timeIntervalSinceNow: 0.25))
46+
let capture = Process()
47+
capture.executableURL = URL(fileURLWithPath: "/usr/sbin/screencapture")
48+
capture.arguments = ["-x", "-o", "-l", String(window.windowNumber), __SNAPSHOTS__ + "/\(phase)-\(name).png"]
49+
try! capture.run()
50+
capture.waitUntilExit()
51+
precondition(capture.terminationStatus == 0)
52+
}
53+
}
54+
window.orderOut(nil)
55+
print("Native Recent Actions label captures saved; button fits and stays centered in both appearances.")
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import argparse
2+
import json
3+
from pathlib import Path
4+
import subprocess
5+
import tempfile
6+
7+
root = Path(__file__).resolve().parents[3]
8+
parser = argparse.ArgumentParser()
9+
parser.add_argument('--scratch-path', type=Path, required=True)
10+
parser.add_argument('--snapshots', type=Path, required=True)
11+
args = parser.parse_args()
12+
args.snapshots.mkdir(parents=True, exist_ok=True)
13+
source = (root / 'packages/ChannelAdminUI/Sources/ChannelAdminUI/ChannelEventLogController.swift').read_text()
14+
start = source.index(' settings.autohighlight = false')
15+
end = source.index(' setFrameSize(frameRect.size)', start)
16+
setup = '\n'.join(line for line in source[start:end].splitlines() if 'settings.' in line)
17+
start = source.index(' settings.set(text: strings().channelEventFilterFilters')
18+
end = source.index(' info.set(image:', start)
19+
style = source[start:end].replace('strings().channelEventFilterFilters', 'title')
20+
strings = json.loads(subprocess.check_output(['plutil', '-convert', 'json', '-o', '-', str(root / 'Telegram-Mac/en.lproj/Localizable.strings')], text=True))
21+
new_key = 'Channel.EventFilter.Filters'
22+
assert strings[new_key] == 'Filters'
23+
assert new_key in (root / 'packages/Localization/Sources/Localization/Localizable.swift').read_text()
24+
assert 'self?.showFilter()' in source
25+
with tempfile.TemporaryDirectory(prefix='telegram-recent-actions-label-') as directory:
26+
directory = Path(directory)
27+
dependencies = ', '.join('.package(path: ' + json.dumps(str(root / 'packages' / name)) + ')' for name in ['TGUIKit', 'ColorPalette'])
28+
(directory / 'Package.swift').write_text('''// swift-tools-version:5.9
29+
import PackageDescription
30+
let package = Package(name: "RecentActionsLabel", platforms: [.macOS(.v12)], dependencies: [DEPENDENCIES], targets: [.executableTarget(name: "RecentActionsLabel", dependencies: ["TGUIKit", "ColorPalette"], path: "Sources")])
31+
'''.replace('DEPENDENCIES', dependencies))
32+
(directory / 'Sources').mkdir()
33+
text = (Path(__file__).with_name('main.swift')).read_text()
34+
for marker, value in {'__SETUP__': setup, '__STYLE__': style, '__BEFORE__': json.dumps(strings['Chanel.EventFilter.Settings']), '__AFTER__': json.dumps(strings[new_key]), '__SNAPSHOTS__': json.dumps(str(args.snapshots.resolve()))}.items():
35+
text = text.replace(marker, value)
36+
(directory / 'Sources/main.swift').write_text(text)
37+
raise SystemExit(subprocess.run(['swift', 'run', '--package-path', str(directory), '--scratch-path', str(args.scratch_path.resolve()), '--disable-sandbox', '--jobs', '4', 'RecentActionsLabel']).returncode)
31.7 KB
Loading
30.8 KB
Loading
33.3 KB
Loading
32.4 KB
Loading

0 commit comments

Comments
 (0)