@@ -11,6 +11,7 @@ final class AppModel {
1111 case nepaliFlag
1212 case englishShort
1313 case numeric
14+ case custom
1415
1516 var id : String { rawValue }
1617
@@ -24,15 +25,18 @@ final class AppModel {
2425 switch self {
2526 case . nepaliShort: return " \( day) \( date. nepaliMonthName) "
2627 case . nepaliLong: return " \( day) \( date. nepaliMonthName) \( year) "
27- case . nepaliFlag: return " 🇳🇵 \( day) \( date. nepaliMonthName) "
28+ case . nepaliFlag: return " 🇳🇵 \( day) \( date. nepaliMonthName) \( year ) "
2829 case . englishShort: return " \( date. day) \( date. englishMonthName) "
2930 case . numeric: return numerals. slashedDate ( date)
31+ case . custom: return " \( day) \( date. nepaliMonthName) \( year) "
3032 }
3133 }
3234 }
3335
3436 private enum DefaultsKey {
3537 static let menuBarFormat = " menuBarFormat "
38+ static let customMenuBarShowsFlag = " customMenuBarShowsFlag "
39+ static let customMenuBarShowsYear = " customMenuBarShowsYear "
3640 static let appLanguage = " appLanguage "
3741 static let numeralStyle = " numeralStyle "
3842 static let weatherEnabled = " weatherEnabled "
@@ -60,6 +64,16 @@ final class AppModel {
6064 didSet { defaults. set ( selectedMenuBarFormat. rawValue, forKey: DefaultsKey . menuBarFormat) }
6165 }
6266
67+ /// The Custom menu-bar option starts with the full Nepali date, then lets
68+ /// people keep or remove the two pieces that matter most at a glance.
69+ var customMenuBarShowsFlag : Bool {
70+ didSet { defaults. set ( customMenuBarShowsFlag, forKey: DefaultsKey . customMenuBarShowsFlag) }
71+ }
72+
73+ var customMenuBarShowsYear : Bool {
74+ didSet { defaults. set ( customMenuBarShowsYear, forKey: DefaultsKey . customMenuBarShowsYear) }
75+ }
76+
6377 var appLanguage : AppLanguage {
6478 didSet { defaults. set ( appLanguage. rawValue, forKey: DefaultsKey . appLanguage) }
6579 }
@@ -247,7 +261,21 @@ final class AppModel {
247261 }
248262
249263 var menuBarTitle : String {
250- selectedMenuBarFormat. title ( for: today, numerals: numeralStyle)
264+ menuBarTitle ( for: selectedMenuBarFormat)
265+ }
266+
267+ func menuBarTitle( for format: MenuBarFormat ) -> String {
268+ guard format == . custom else {
269+ return format. title ( for: today, numerals: numeralStyle)
270+ }
271+
272+ let day = numeralStyle. string ( from: today. day)
273+ let year = numeralStyle. string ( from: today. year)
274+ var parts : [ String ] = [ ]
275+ if customMenuBarShowsFlag { parts. append ( " 🇳🇵 " ) }
276+ parts. append ( " \( day) \( today. nepaliMonthName) " )
277+ if customMenuBarShowsYear { parts. append ( year) }
278+ return parts. joined ( separator: " " )
251279 }
252280
253281 var visibleCards : [ DashboardCard ] {
@@ -322,6 +350,8 @@ final class AppModel {
322350
323351 selectedMenuBarFormat = defaults. string ( forKey: DefaultsKey . menuBarFormat)
324352 . flatMap ( MenuBarFormat . init ( rawValue: ) ) ?? . nepaliShort
353+ customMenuBarShowsFlag = defaults. object ( forKey: DefaultsKey . customMenuBarShowsFlag) as? Bool ?? true
354+ customMenuBarShowsYear = defaults. object ( forKey: DefaultsKey . customMenuBarShowsYear) as? Bool ?? true
325355 appLanguage = defaults. string ( forKey: DefaultsKey . appLanguage)
326356 . flatMap ( AppLanguage . init ( rawValue: ) ) ?? . mixed
327357 numeralStyle = defaults. string ( forKey: DefaultsKey . numeralStyle)
0 commit comments