Implement developer feature to avoid distractions
This commit implements an optional developer feature to scramble text and blur images to prevent distractions during development and testing. It is not perfect (It breaks some mentions and rich text objects, and does not scramble non-alphanumeric languages such as Japanese), but good enough to avoid distractions while working on most features. No changelog entry is needed because this is not meant for the final user. Changelog-None Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
30
damus/Util/Undistractor.swift
Normal file
30
damus/Util/Undistractor.swift
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// Undistractor.swift
|
||||
// damus
|
||||
//
|
||||
// Created by Daniel D’Aquino on 2025-02-19.
|
||||
//
|
||||
|
||||
/// Keeping the minds of developers safe from the occupational hazard of social media distractions when testing Damus since 2025
|
||||
struct Undistractor {
|
||||
static func makeGibberish(text: String) -> String {
|
||||
let lowercaseLetters = "abcdefghijklmnopqrstuvwxyz"
|
||||
let uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
var transformedText = ""
|
||||
|
||||
for char in text {
|
||||
if lowercaseLetters.contains(char) {
|
||||
if let randomLetter = lowercaseLetters.randomElement() {
|
||||
transformedText.append(randomLetter)
|
||||
}
|
||||
} else if uppercaseLetters.contains(char) {
|
||||
if let randomLetter = uppercaseLetters.randomElement() {
|
||||
transformedText.append(randomLetter)
|
||||
}
|
||||
} else {
|
||||
transformedText.append(char)
|
||||
}
|
||||
}
|
||||
return transformedText
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user