Skip to content

Commit

Permalink
Font size setting as continuous
Browse files Browse the repository at this point in the history
  • Loading branch information
diegotid committed Apr 28, 2024
1 parent 3e00ca9 commit ebd85fd
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 98 deletions.
8 changes: 4 additions & 4 deletions Tildone.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 15;
CURRENT_PROJECT_VERSION = 16;
DEVELOPMENT_ASSET_PATHS = "\"Tildone/Preview Content\"";
DEVELOPMENT_TEAM = F6HFAVTS49;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -545,7 +545,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.2;
MARKETING_VERSION = 1.2.1;
PRODUCT_BUNDLE_IDENTIFIER = studio.cuatro.tildone;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -563,7 +563,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 15;
CURRENT_PROJECT_VERSION = 16;
DEVELOPMENT_ASSET_PATHS = "\"Tildone/Preview Content\"";
DEVELOPMENT_TEAM = F6HFAVTS49;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -577,7 +577,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.2;
MARKETING_VERSION = 1.2.1;
PRODUCT_BUNDLE_IDENTIFIER = studio.cuatro.tildone;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
66 changes: 22 additions & 44 deletions Tildone/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,28 @@
}
}
},
"New features:\n• Font size customizable in settings\n\nFrom the previous release:\n• Open at login\n• Focus filters\n• Arrange notes\n• Spanish, French and Chinese\n• Several other improvements" : {
"localizations" : {
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Nuevas funciones:\n• Tamaño de letra personalizable en los ajustes\n\nDe la versión anterior:\n• Abrir al iniciar sesión\n• Filtros de enfoque\n• Ordenar notas\n• Español, francés y chino\n• Otras mejoras"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Nouvelles fonctionnalités :\n• Taille de la police personnalisable dans les paramètres\n\nDepuis la version précédente :\n• Ouvrir à la connexion\n• Filtres de mise au point\n• Classer les notes\n• Espagnol, français et chinois\n• Plusieurs autres améliorations"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "新功能:\n• 可在设置中自定义字体大小\n\n上一版本:\n• 登录时打开\n• 焦点过滤器\n• 排列备注\n• 西班牙语、法语和中文\n• 其他一些改进"
}
}
}
},
"New Note" : {
"localizations" : {
"es" : {
Expand Down Expand Up @@ -1007,28 +1029,6 @@
}
}
},
"Task text sample" : {
"localizations" : {
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Ejemplo de texto de tarea"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Exemple de texte de tâche"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "任务文本示例"
}
}
}
},
"Tildone" : {
"localizations" : {
"es" : {
Expand All @@ -1051,28 +1051,6 @@
}
}
},
"Tildone has been updated featuring now:\n• Open at login\n• Focus filters\n• Arrange notes\n• Spanish, French and Chinese\n• Several other improvements" : {
"localizations" : {
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Tildone se ha actualizado e incluye ahora:\n• Abrir al iniciar sesión\n• Filtros de foco\n• Organización de notas\n• Español, francés y chino\n• Varias otras mejoras"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Tildone a été mis à jour avec désormais :\n• Ouvrir lors de la connexion\n• Filtres de focus\n• Organiser les notes\n• Espagnol, français et chinois\n• Plusieurs autres améliorations"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "Tildone 已更新,现在包含:\n• 登录时打开\n• 焦点过滤器\n• 整理笔记\n• 西班牙语、法语和中文\n• 其他多项改进"
}
}
}
},
"Top left corner" : {
"localizations" : {
"es" : {
Expand Down
5 changes: 4 additions & 1 deletion Tildone/Services/UpdateChecker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ struct UpdateChecker {
checkList.items = [checkWhatsNewTask]
checkList.systemURL = URL(string: Remote.releaseNotesUrl)
checkList.systemContent = String(localized: """
Tildone has been updated featuring now:
New features:
\u{2022} Font size customizable in settings
From the previous release:
\u{2022} Open at login
\u{2022} Focus filters
\u{2022} Arrange notes
Expand Down
20 changes: 14 additions & 6 deletions Tildone/Views/Note.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct Note: View {
listTopic()
.opacity(isTopScrolledOut || isTopicHidden ? 0 : 1)
.frame(height: isTopicHidden ? 1 : 30)
.padding(.bottom, CGFloat(FontSize(rawValue: fontSize)!.toValue() - 10))
.padding(.bottom, CGFloat(fontSize - 10))
ForEach(sortedTasks, id: \.created) { item in
listItem(task: item)
}
Expand Down Expand Up @@ -137,6 +137,7 @@ struct Note: View {
handleKeyboard()
self.isDone = list.isComplete
self.wasAlreadyDone = list.isComplete
convertLegacyFontSizeSettingIfNeeded()
}
.onReceive(NotificationCenter.default.publisher(for: .visibility)) { notification in
if let (toBlur, toNormal) = notification.object as? (Bool, Bool) {
Expand Down Expand Up @@ -352,6 +353,13 @@ private extension Note {
func handleDisappearance() {
self.list?.delete()
}

func convertLegacyFontSizeSettingIfNeeded() {
if fontSize < FontSize.xSmall.rawValue,
let newFontSize = FontSize(fromLegacySetting: fontSize) {
fontSize = newFontSize.rawValue
}
}
}

// MARK: Private methods
Expand Down Expand Up @@ -431,8 +439,8 @@ private extension Note {
@ViewBuilder
func listTopic() -> some View {
if let list = self.list {
let listTaksOffset: CGFloat = 20 / CGFloat(FontSize.small.toValue())
let size = listTaksOffset * CGFloat(FontSize(rawValue: fontSize)!.toValue())
let listTaksOffset: CGFloat = 20 / CGFloat(FontSize.small.rawValue)
let size = listTaksOffset * CGFloat(fontSize)
GeometryReader { geometry in
TextField("Topic",
text: Binding<String>(
Expand Down Expand Up @@ -502,7 +510,7 @@ private extension Note {
.padding(.vertical, 2)
if task.isDone {
Text(task.what)
.font(.system(size: CGFloat(FontSize(rawValue: fontSize)!.toValue())))
.font(.system(size: CGFloat(fontSize)))
.foregroundColor(.accentColor)
.strikethrough(color: .accentColor)
} else {
Expand All @@ -517,7 +525,7 @@ private extension Note {
view.truncationMode(.tail)
}
.textFieldStyle(PlainTextFieldStyle())
.font(.system(size: CGFloat(FontSize(rawValue: fontSize)!.toValue())))
.font(.system(size: CGFloat(fontSize)))
.foregroundColor(Color(.primaryFontColor))
.background(Color.clear)
.focused($focusedTaskCreation, equals: task.created)
Expand Down Expand Up @@ -559,7 +567,7 @@ private extension Note {
.disabled(true)
TextField("New task", text: $newTaskText)
.textFieldStyle(PlainTextFieldStyle())
.font(.system(size: CGFloat(FontSize(rawValue: fontSize)!.toValue())))
.font(.system(size: CGFloat(fontSize)))
.foregroundColor(Color(.primaryFontColor))
.background(Color.clear)
.onSubmit(handleTaskCommit)
Expand Down
62 changes: 19 additions & 43 deletions Tildone/Views/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct SettingsForm: View {
}
.padding(24)
}
.frame(width: 470, height: 635)
.frame(width: 470, height: 600)
}
}

Expand All @@ -65,29 +65,25 @@ private extension SettingsForm {

@ViewBuilder
func fontSizeSettings() -> some View {
Text("Font size")
.font(.subheadline)
.foregroundColor(.secondary)
.padding(.top, 1)
HStack {
Spacer()
Text("Task text sample")
.font(.system(size: CGFloat(FontSize(rawValue: fontSize)!.toValue())))
Text("Font size")
.font(.system(size: CGFloat(fontSize)))
Spacer()
}
.frame(minHeight: 28)
Slider(
value: $fontSize,
in: Double(FontSize.xSmall.rawValue)...Double(FontSize.xLarge.rawValue),
step: 1
)
.padding(.trailing, 10)
HStack {
ForEach(FontSize.allCases, id: \.self) { fontSize in
Text(fontSize.toString())
.font(.subheadline)
.frame(maxWidth: .infinity)
}
in: Double(FontSize.xSmall.rawValue)...Double(FontSize.xLarge.rawValue)
) {
Text("Font size")
} minimumValueLabel: {
Text("X Small")
} maximumValueLabel: {
Text("X Large")
}
.labelsHidden()
.padding(.trailing, 10)
.padding(.bottom, 14)
}

Expand Down Expand Up @@ -272,35 +268,15 @@ extension SettingsForm {

// MARK: Enum types

enum FontSize: Int, CaseIterable {
case xSmall = 0
case small
enum FontSize: Double, CaseIterable {
case xSmall = 10
case small = 13
case medium
case large
case xLarge
case xLarge = 24

init?(rawValue: Double) {
self = FontSize.allCases[Int(rawValue)]
}

func toValue() -> Int {
switch self {
case .xSmall: 10
case .small: 13
case .medium: 16
case .large: 20
case .xLarge: 24
}
}

func toString() -> String {
switch self {
case .xSmall: String(localized: "X Small")
case .small: String(localized: "Small")
case .medium: String(localized: "Medium")
case .large: String(localized: "Large")
case .xLarge: String(localized: "X Large")
}
init?(fromLegacySetting legacyValue: Double) {
self = FontSize.allCases[Int(legacyValue)]
}
}

Expand Down

0 comments on commit ebd85fd

Please sign in to comment.