Improve dark mode color scheme

Signed-off-by: William Brawner <me@wbrawner.com>
This commit is contained in:
William Brawner 2020-11-06 07:41:33 -07:00
parent e82891b84b
commit b77650b2b3
24 changed files with 119 additions and 93 deletions

View file

@ -9,6 +9,7 @@
import SwiftUI
struct ActiveTimerView: View {
@Environment(\.colorScheme) var colorScheme
@EnvironmentObject var dataStore: TimerDataStore
@State var isEditing: Bool = false
@ -48,9 +49,10 @@ struct ActiveTimerView: View {
label: {
Text("Edit")
}
)
).foregroundColor(.primary)
)
.background(state.backgroundColor)
.background(state.phase.backgroundColor(forColorScheme: colorScheme))
.foregroundColor(state.phase.textColor(forColorScheme: colorScheme))
.edgesIgnoringSafeArea(.vertical)
.animation(.default)
.sheet(isPresented: $isEditing,
@ -84,7 +86,6 @@ struct TimerControlsView: View {
.scaledToFit()
.frame(width: buttonSize, height: buttonSize)
})
.foregroundColor(.primary)
.padding()
Button(action: {
self.dataStore.toggle()
@ -94,7 +95,6 @@ struct TimerControlsView: View {
.scaledToFit()
.frame(width: buttonSize, height: buttonSize)
})
.foregroundColor(.primary)
.padding()
Button(action: {
self.dataStore.goForward()
@ -104,7 +104,6 @@ struct TimerControlsView: View {
.scaledToFit()
.frame(width: buttonSize, height: buttonSize)
})
.foregroundColor(.primary)
.padding()
}
}
@ -148,5 +147,6 @@ struct ActiveTimerView_Previews: PreviewProvider {
}
static var previews: some View {
ActiveTimerView().environmentObject(dataStore)
.environment(\.colorScheme, .dark)
}
}

View file

@ -23,9 +23,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.684",
"green" : "0.498",
"red" : "0.270"
"blue" : "0.965",
"green" : "0.710",
"red" : "0.392"
}
},
"idiom" : "universal"

View file

@ -23,9 +23,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.389",
"green" : "0.582",
"red" : "0.376"
"blue" : "0.518",
"green" : "0.780",
"red" : "0.506"
}
},
"idiom" : "universal"

View file

@ -0,0 +1,33 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.463",
"green" : "0.945",
"red" : "1.000"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"platform" : "ios",
"reference" : "systemBackgroundColor"
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View file

@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.000",
"green" : "0.000",
"red" : "0.000"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.463",
"green" : "0.945",
"red" : "1.000"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View file

@ -23,9 +23,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.457",
"green" : "0.307",
"red" : "0.743"
"blue" : "0.573",
"green" : "0.384",
"red" : "0.941"
}
},
"idiom" : "universal"

View file

@ -23,9 +23,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.361",
"green" : "0.733",
"red" : "0.773"
"blue" : "0.463",
"green" : "0.945",
"red" : "1.000"
}
},
"idiom" : "universal"

View file

@ -33,7 +33,7 @@
"scale" : "2x"
},
{
"filename" : "trainterval-icon-1024x1024.png",
"filename" : "trainterval-icon-@3x.png",
"idiom" : "universal",
"scale" : "3x"
},

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View file

@ -23,9 +23,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.000",
"green" : "0.000",
"red" : "0.000"
"blue" : "1.000",
"green" : "1.000",
"red" : "1.000"
}
},
"idiom" : "universal"

View file

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17126"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="TimerIcon" translatesAutoresizingMaskIntoConstraints="NO" id="mhf-Tb-WXG">
<rect key="frame" x="143" y="389" width="128" height="128"/>
<constraints>
<constraint firstAttribute="height" constant="128" id="AjD-Bj-b8W"/>
<constraint firstAttribute="width" constant="128" id="hZt-rV-FXc"/>
</constraints>
</imageView>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" name="RestColor"/>
<constraints>
<constraint firstItem="mhf-Tb-WXG" firstAttribute="centerX" secondItem="6Tk-OE-BBY" secondAttribute="centerX" id="IFW-ag-NA6"/>
<constraint firstItem="mhf-Tb-WXG" firstAttribute="centerY" secondItem="6Tk-OE-BBY" secondAttribute="centerY" id="S7p-Tx-YmV"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<image name="TimerIcon" width="256" height="256"/>
<namedColor name="RestColor">
<color red="1" green="0.94499999284744263" blue="0.46299999952316284" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
</resources>
</document>

View file

@ -4,6 +4,8 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Trainterval</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
@ -37,8 +39,13 @@
</array>
</dict>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UILaunchScreen</key>
<dict>
<key>UIColorName</key>
<string>LaunchBackground</string>
<key>UIImageName</key>
<string>TimerIcon</string>
</dict>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>

View file

@ -46,7 +46,15 @@ enum Phase: String {
}
extension Phase {
var backgroundColor: Color {
func backgroundColor(forColorScheme: ColorScheme) -> Color {
return forColorScheme == .dark ? Color.black : self.color
}
func textColor(forColorScheme: ColorScheme) -> Color {
return forColorScheme == .dark ? self.color : Color.black
}
private var color: Color {
get {
switch self {
case .warmUp:
@ -123,11 +131,6 @@ struct ActiveTimerState {
let soundId: Int?
let phase: Phase
let isRunning: Bool
var backgroundColor: Color {
get {
return self.phase.backgroundColor
}
}
}
extension ActiveTimerState {

View file

@ -23,7 +23,6 @@
80F8B6FC254276380024077E /* TimerListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80F8B6FB254276380024077E /* TimerListView.swift */; };
80F8B6FE2542763A0024077E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 80F8B6FD2542763A0024077E /* Assets.xcassets */; };
80F8B7012542763A0024077E /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 80F8B7002542763A0024077E /* Preview Assets.xcassets */; };
80F8B7042542763A0024077E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 80F8B7022542763A0024077E /* LaunchScreen.storyboard */; };
80F8B70F2542763B0024077E /* IntervalTimerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80F8B70E2542763B0024077E /* IntervalTimerTests.swift */; };
80F8B71A2542763B0024077E /* IntervalTimerUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80F8B7192542763B0024077E /* IntervalTimerUITests.swift */; };
80F8B728254276E70024077E /* IntervalTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80F8B727254276E70024077E /* IntervalTimer.swift */; };
@ -65,7 +64,6 @@
80F8B6FB254276380024077E /* TimerListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimerListView.swift; sourceTree = "<group>"; };
80F8B6FD2542763A0024077E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
80F8B7002542763A0024077E /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
80F8B7032542763A0024077E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
80F8B7052542763B0024077E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
80F8B70A2542763B0024077E /* IntervalTimerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = IntervalTimerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
80F8B70E2542763B0024077E /* IntervalTimerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntervalTimerTests.swift; sourceTree = "<group>"; };
@ -142,7 +140,6 @@
80F8B6F6254276380024077E /* SceneDelegate.swift */,
80F8B6FB254276380024077E /* TimerListView.swift */,
80F8B6FD2542763A0024077E /* Assets.xcassets */,
80F8B7022542763A0024077E /* LaunchScreen.storyboard */,
80F8B7052542763B0024077E /* Info.plist */,
80F8B6F8254276380024077E /* IntervalTimer.xcdatamodeld */,
80F8B6FF2542763A0024077E /* Preview Content */,
@ -262,7 +259,7 @@
};
};
};
buildConfigurationList = 80F8B6EC254276380024077E /* Build configuration list for PBXProject "IntervalTimer" */;
buildConfigurationList = 80F8B6EC254276380024077E /* Build configuration list for PBXProject "Trainterval" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
@ -292,7 +289,6 @@
80E0FEE3254F425200A67912 /* Warm-Up.mp3 in Resources */,
80E0FEE6254F425200A67912 /* Cooldown.mp3 in Resources */,
80E0FEE4254F425200A67912 /* High Intensity.mp3 in Resources */,
80F8B7042542763A0024077E /* LaunchScreen.storyboard in Resources */,
80F8B7012542763A0024077E /* Preview Assets.xcassets in Resources */,
80F8B6FE2542763A0024077E /* Assets.xcassets in Resources */,
);
@ -364,17 +360,6 @@
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
80F8B7022542763A0024077E /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
80F8B7032542763A0024077E /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
80F8B71C2542763B0024077E /* Debug */ = {
isa = XCBuildConfiguration;
@ -619,7 +604,7 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
80F8B6EC254276380024077E /* Build configuration list for PBXProject "IntervalTimer" */ = {
80F8B6EC254276380024077E /* Build configuration list for PBXProject "Trainterval" */ = {
isa = XCConfigurationList;
buildConfigurations = (
80F8B71C2542763B0024077E /* Debug */,

View file

@ -2,6 +2,6 @@
<Workspace
version = "1.0">
<FileRef
location = "self:IntervalTimer.xcodeproj">
location = "self:/Users/wbrawner/Projects/IntervalTimer/Trainterval.xcodeproj">
</FileRef>
</Workspace>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "EA7199A8-8CE2-44F1-AA78-B346E8EEFD5B"
type = "1"
version = "2.0">
</Bucket>