Browse Source

Rename dark mode to high contrast

Deniz Cengiz 1 năm trước cách đây
mục cha
commit
99c4e60e8a

+ 4 - 4
FreeAPS/Sources/APS/Storage/ContactTrickStorage.swift

@@ -30,7 +30,7 @@ final class BaseContactTrickStorage: ContactTrickStorage, Injectable {
             ofType: ContactTrickEntryStored.self,
             onContext: backgroundContext,
             predicate: NSPredicate.all,
-            key: "isDarkMode",
+            key: "hasHighContrast",
             ascending: false
         )
 
@@ -46,7 +46,7 @@ final class BaseContactTrickStorage: ContactTrickStorage, Injectable {
                     top: ContactTrickValue(rawValue: entry.top ?? "None") ?? .none,
                     bottom: ContactTrickValue(rawValue: entry.bottom ?? "None") ?? .none,
                     contactId: entry.contactId?.string,
-                    darkMode: entry.isDarkMode,
+                    hasHighContrast: entry.hasHighContrast,
                     ringWidth: ContactTrickEntry.RingWidth(rawValue: Int(entry.ringWidth)) ?? .regular,
                     ringGap: ContactTrickEntry.RingGap(rawValue: Int(entry.ringGap)) ?? .small,
                     fontSize: ContactTrickEntry.FontSize(rawValue: Int(entry.fontSize)) ?? .regular,
@@ -78,7 +78,7 @@ final class BaseContactTrickStorage: ContactTrickStorage, Injectable {
             newContactTrickEntry.primary = contactTrickEntry.primary.rawValue
             newContactTrickEntry.top = contactTrickEntry.top.rawValue
             newContactTrickEntry.bottom = contactTrickEntry.bottom.rawValue
-            newContactTrickEntry.isDarkMode = contactTrickEntry.darkMode
+            newContactTrickEntry.hasHighContrast = contactTrickEntry.hasHighContrast
             newContactTrickEntry.ringWidth = Int16(contactTrickEntry.ringWidth.rawValue)
             newContactTrickEntry.ringGap = Int16(contactTrickEntry.ringGap.rawValue)
             newContactTrickEntry.fontSize = Int16(contactTrickEntry.fontSize.rawValue)
@@ -118,7 +118,7 @@ final class BaseContactTrickStorage: ContactTrickStorage, Injectable {
                     existingEntry.primary = contactTrickEntry.primary.rawValue
                     existingEntry.top = contactTrickEntry.top.rawValue
                     existingEntry.bottom = contactTrickEntry.bottom.rawValue
-                    existingEntry.isDarkMode = contactTrickEntry.darkMode
+                    existingEntry.hasHighContrast = contactTrickEntry.hasHighContrast
                     existingEntry.ringWidth = Int16(contactTrickEntry.ringWidth.rawValue)
                     existingEntry.ringGap = Int16(contactTrickEntry.ringGap.rawValue)
                     existingEntry.fontSize = Int16(contactTrickEntry.fontSize.rawValue)

+ 2 - 2
FreeAPS/Sources/Models/ContactTrickEntry.swift

@@ -10,7 +10,7 @@ struct ContactTrickEntry: Hashable, Equatable, Sendable {
     var top: ContactTrickValue = .none
     var bottom: ContactTrickValue = .none
     var contactId: String? = nil
-    var darkMode: Bool = false
+    var hasHighContrast: Bool = true
     var ringWidth: RingWidth = .regular
     var ringGap: RingGap = .small
     var fontSize: FontSize = .regular
@@ -28,7 +28,7 @@ struct ContactTrickEntry: Hashable, Equatable, Sendable {
             lhs.top == rhs.top &&
             lhs.bottom == rhs.bottom &&
             lhs.contactId == rhs.contactId &&
-            lhs.darkMode == rhs.darkMode &&
+            lhs.hasHighContrast == rhs.hasHighContrast &&
             lhs.ringWidth == rhs.ringWidth &&
             lhs.ringGap == rhs.ringGap &&
             lhs.fontSize == rhs.fontSize &&

+ 4 - 4
FreeAPS/Sources/Modules/ContactTrick/View/AddContactTrickSheet.swift

@@ -7,7 +7,7 @@ struct AddContactTrickSheet: View {
 
     @ObservedObject var state: ContactTrick.StateModel
 
-    @State private var isDarkMode: Bool = false
+    @State private var hasHighContrast: Bool = true
     @State private var ringWidth: ContactTrickEntry.RingWidth = .regular
     @State private var ringGap: ContactTrickEntry.RingGap = .small
     @State private var layout: ContactTrickLayout = .single
@@ -30,7 +30,7 @@ struct AddContactTrickSheet: View {
             top: top,
             bottom: bottom,
             contactId: nil, // not needed for preview, gets set later in ContactTrickStateModel via ContactTrickManager
-            darkMode: isDarkMode,
+            hasHighContrast: hasHighContrast,
             ringWidth: ringWidth,
             ringGap: ringGap,
             fontSize: fontSize,
@@ -48,7 +48,7 @@ struct AddContactTrickSheet: View {
                     Spacer()
                     ZStack {
                         Circle()
-                            .fill(previewEntry.darkMode ? .black : .white)
+                            .fill(previewEntry.hasHighContrast ? .black : .white)
                             .foregroundColor(.white)
                             .frame(width: 100, height: 100)
                         Image(uiImage: ContactPicture.getImage(contact: previewEntry, state: state.state))
@@ -73,7 +73,7 @@ struct AddContactTrickSheet: View {
                                 Text(layout.displayName).tag(layout)
                             }
                         }
-                        Toggle("Dark Mode", isOn: $isDarkMode)
+                        Toggle("High Contrast Mode", isOn: $hasHighContrast)
                     }.listRowBackground(Color.chart)
 
                     // Primary Value Section

+ 2 - 2
FreeAPS/Sources/Modules/ContactTrick/View/ContactTrickDetailView.swift

@@ -23,7 +23,7 @@ struct ContactTrickDetailView: View {
                 Spacer()
                 ZStack {
                     Circle()
-                        .fill(contactTrickEntry.darkMode ? .black : .white)
+                        .fill(contactTrickEntry.hasHighContrast ? .black : .white)
                         .foregroundColor(.white)
                         .frame(width: 100, height: 100)
                     Image(uiImage: ContactPicture.getImage(contact: contactTrickEntry, state: state.state))
@@ -47,7 +47,7 @@ struct ContactTrickDetailView: View {
                             Text(layout.displayName).tag(layout)
                         }
                     }
-                    Toggle("Dark Mode", isOn: $contactTrickEntry.darkMode)
+                    Toggle("High Contrast Mode", isOn: $contactTrickEntry.hasHighContrast)
                 }.listRowBackground(Color.chart)
 
                 Section(header: Text("Display Values")) {

+ 1 - 1
FreeAPS/Sources/Modules/ContactTrick/View/ContactTrickRootView.swift

@@ -53,7 +53,7 @@ extension ContactTrick {
                             HStack {
                                 ZStack {
                                     Circle()
-                                        .fill(entry.darkMode ? .black : .white)
+                                        .fill(entry.hasHighContrast ? .black : .white)
                                         .foregroundColor(.white)
                                         .frame(width: 40, height: 40)
 

+ 8 - 8
FreeAPS/Sources/Services/ContactTrick/ContactTrickPicture.swift

@@ -22,10 +22,10 @@ struct ContactPicture: View {
         let width = 1024.0
         let height = 1024.0
         var rect = CGRect(x: 0, y: 0, width: width, height: height)
-        let textColor: Color = contact.darkMode ?
+        let textColor: Color = contact.hasHighContrast ?
             Color(red: 250 / 256, green: 250 / 256, blue: 250 / 256) :
             Color(red: 20 / 256, green: 20 / 256, blue: 20 / 256)
-        let secondaryTextColor: Color = contact.darkMode ?
+        let secondaryTextColor: Color = contact.hasHighContrast ?
             Color(red: 220 / 256, green: 220 / 256, blue: 220 / 256) :
             Color(red: 40 / 256, green: 40 / 256, blue: 40 / 256)
         let fontWeight = contact.fontWeight
@@ -98,9 +98,9 @@ struct ContactPicture: View {
 
             if contact.bottom != .none, contact.top == .none {
                 // move things around a little bit to give more space to the bottom area
-                
+
                 // TODO: revisit rings for iob, cob and combined iob+cob with more user feedback
-                if contact.bottom == .trend && contact.ring == .loop {
+                if contact.bottom == .trend, contact.ring == .loop {
 //                if contact.ring == .iob || contact.ring == .cob || contact.ring == .iobcob ||
 //                    (contact.bottom == .trend && contact.ring == .loop)
 //                {
@@ -365,7 +365,7 @@ struct ContactPicture: View {
 //                drawProgressBar(
 //                    rect: rect,
 //                    progress: Double(iob) / Double(state.maxIOB),
-//                    colors: [contact.darkMode ? .blue : .blue, contact.darkMode ? .pink : .red],
+//                    colors: [contact.hasHighContrast ? .blue : .blue, contact.hasHighContrast ? .pink : .red],
 //                    strokeWidth: strokeWidth
 //                )
 //            }
@@ -384,7 +384,7 @@ struct ContactPicture: View {
 //                    rect: rect,
 //                    progress1: state.iob.map { Double($0) / Double(state.maxIOB) },
 //                    progress2: state.cob.map { Double($0) / Double(state.maxCOB) },
-//                    colors1: [contact.darkMode ? .blue : .blue, contact.darkMode ? .pink : .red],
+//                    colors1: [contact.hasHighContrast ? .blue : .blue, contact.hasHighContrast ? .pink : .red],
 //                    colors2: [.loopYellow, .red],
 //                    strokeWidth: strokeWidth
 //                )
@@ -628,14 +628,14 @@ struct ContactPicturePreview: View {
         }
         .frame(width: 256, height: 256)
         .clipShape(Circle())
-        .preferredColorScheme($contact.wrappedValue.darkMode ? .dark : .light)
+        .preferredColorScheme($contact.wrappedValue.hasHighContrast ? .dark : .light)
     }
 }
 
 struct ContactPicture_Previews: PreviewProvider {
     struct Preview: View {
         @State var rangeIndicator: Bool = true
-        @State var darkMode: Bool = true
+        @State var hasHighContrast: Bool = true
         @State var fontSize: ContactTrickEntry.FontSize = .small
         @State var fontWeight: UIFont.Weight = .bold
         @State var fontName: String? = "AmericanTypewriter"

+ 1 - 1
Model/Classes+Properties/ContactTrickEntryStored+CoreDataProperties.swift

@@ -13,7 +13,7 @@ public extension ContactTrickEntryStored {
     @NSManaged var top: String?
     @NSManaged var bottom: String?
     @NSManaged var contactId: String?
-    @NSManaged var isDarkMode: Bool
+    @NSManaged var hasHighContrast: Bool
     @NSManaged var ringWidth: Int16
     @NSManaged var ringGap: Int16
     @NSManaged var id: UUID?

+ 2 - 2
Model/TrioCoreDataPersistentContainer.xcdatamodeld/TrioCoreDataPersistentContainer.xcdatamodel/contents

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="23605" systemVersion="24C101" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithSwiftData="YES" userDefinedModelVersionIdentifier="">
+<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="23231" systemVersion="24C101" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithSwiftData="YES" userDefinedModelVersionIdentifier="">
     <entity name="BolusStored" representedClassName="BolusStored" syncable="YES">
         <attribute name="amount" optional="YES" attributeType="Decimal" defaultValueString="0"/>
         <attribute name="isExternal" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
@@ -32,8 +32,8 @@
         <attribute name="fontSizeSecondary" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
         <attribute name="fontWeight" optional="YES" attributeType="String"/>
         <attribute name="fontWidth" optional="YES" attributeType="String"/>
+        <attribute name="hasHighContrast" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
         <attribute name="id" optional="YES" attributeType="UUID" usesScalarValueType="NO"/>
-        <attribute name="isDarkMode" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
         <attribute name="layout" optional="YES" attributeType="String"/>
         <attribute name="name" optional="YES" attributeType="String"/>
         <attribute name="primary" optional="YES" attributeType="String"/>