Skip to content

Commit

Permalink
Add settings screen. (eu-digital-green-certificates#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
yspreen authored May 5, 2021
1 parent fc9bd83 commit 913070c
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 20 deletions.
10 changes: 10 additions & 0 deletions DGCAVerifier.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
CE1F155C2639F9E700736D48 /* SwiftyJSON in Frameworks */ = {isa = PBXBuildFile; productRef = CE1F155B2639F9E700736D48 /* SwiftyJSON */; };
CE37B643263867D700DEE13D /* SecureBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE37B642263867D700DEE13D /* SecureBackground.swift */; };
CE56B5052639F48E00FB31B1 /* SwiftDGC in Frameworks */ = {isa = PBXBuildFile; productRef = CE56B5042639F48E00FB31B1 /* SwiftDGC */; };
CE59D1B426428782004EBDD6 /* Settings.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE59D1B326428782004EBDD6 /* Settings.storyboard */; };
CE59D1B626428D78004EBDD6 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE59D1B526428D78004EBDD6 /* Settings.swift */; };
CE8096D9263B07BB00A65AD6 /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE8096D8263B07BB00A65AD6 /* UIColor.swift */; };
CE81533C263FF8FE0030D777 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = CE81533B263FF8FE0030D777 /* README.md */; };
CE8912F52634C60E00CB92AF /* GatewayConnection.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE8912F42634C60E00CB92AF /* GatewayConnection.swift */; };
Expand Down Expand Up @@ -60,6 +62,8 @@
CE13CF22262DDF810070C80E /* RoundedButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundedButton.swift; sourceTree = "<group>"; };
CE1D1EF5263597A2004C8919 /* LocalData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalData.swift; sourceTree = "<group>"; };
CE37B642263867D700DEE13D /* SecureBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureBackground.swift; sourceTree = "<group>"; };
CE59D1B326428782004EBDD6 /* Settings.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Settings.storyboard; sourceTree = "<group>"; };
CE59D1B526428D78004EBDD6 /* Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = "<group>"; };
CE8096D8263B07BB00A65AD6 /* UIColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColor.swift; sourceTree = "<group>"; };
CE81533B263FF8FE0030D777 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = SOURCE_ROOT; };
CE8912F42634C60E00CB92AF /* GatewayConnection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GatewayConnection.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -122,6 +126,7 @@
CEA6D6F6261F8D2900715333 /* LaunchScreen.storyboard */,
CEA6D6F1261F8D2700715333 /* Main.storyboard */,
CE13CF04262DCDCD0070C80E /* CertificateViewer.storyboard */,
CE59D1B326428782004EBDD6 /* Settings.storyboard */,
);
path = Storyboards;
sourceTree = "<group>";
Expand Down Expand Up @@ -150,6 +155,7 @@
CE13CF09262DCDDA0070C80E /* CertificateViewer.swift */,
CEA6D6EF261F8D2700715333 /* Scan.swift */,
CE891304263581D900CB92AF /* Home.swift */,
CE59D1B526428D78004EBDD6 /* Settings.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
Expand Down Expand Up @@ -376,6 +382,9 @@
CE81533C263FF8FE0030D777 /* README.md in Resources */,
CEA6D6F5261F8D2900715333 /* Assets.xcassets in Resources */,
CEA6D6F3261F8D2700715333 /* Main.storyboard in Resources */,
CE9D1FF32641CE9E00803242 /* lets-encrypt-r3.der in Resources */,
CE59D1B426428782004EBDD6 /* Settings.storyboard in Resources */,
CE9D1FF22641CE9E00803242 /* lets-encrypt-e1.der in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -412,6 +421,7 @@
CE13CF23262DDF810070C80E /* RoundedButton.swift in Sources */,
CEA6D6EC261F8D2700715333 /* AppDelegate.swift in Sources */,
CE891305263581D900CB92AF /* Home.swift in Sources */,
CE59D1B626428D78004EBDD6 /* Settings.swift in Sources */,
CEA15563262F6DAB0024B7AC /* CertViewerDelegate.swift in Sources */,
CEA15570262F79DE0024B7AC /* InfoCell.swift in Sources */,
CEA6D6EE261F8D2700715333 /* SceneDelegate.swift in Sources */,
Expand Down
11 changes: 6 additions & 5 deletions DGCAVerifier/Services/GatewayConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,29 @@ struct GatewayConnection {
update()
}

static func update() {
static func update(completion: (() -> Void)? = nil) {
certUpdate(resume: LocalData.sharedInstance.resumeToken) { encodedCert, token in
LocalData.sharedInstance.lastFetch = Date()
guard let encodedCert = encodedCert else {
status()
status(completion: completion)
return
}
LocalData.sharedInstance.add(encodedPublicKey: encodedCert)
LocalData.sharedInstance.resumeToken = token
update()
update(completion: completion)
}
}

static func status() {
static func status(completion: (() -> Void)? = nil) {
certStatus { validKids in
let invalid = LocalData.sharedInstance.encodedPublicKeys.keys.filter {
!validKids.contains($0)
}
for key in invalid {
LocalData.sharedInstance.encodedPublicKeys.removeValue(forKey: key)
}
LocalData.sharedInstance.lastFetch = Date()
LocalData.sharedInstance.save()
completion?()
}
}
}
18 changes: 9 additions & 9 deletions DGCAVerifier/Storyboards/CertificateViewer.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="WCj-Xf-fml">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="WCj-Xf-fml">
<device id="retina5_9" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
Expand All @@ -26,7 +26,7 @@
<rect key="frame" x="0.0" y="44" width="375" height="734"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a9u-Ia-KEX" customClass="RoundedButton" customModule="DGCAVerifier" customModuleProvider="target">
<rect key="frame" x="147.66666666666666" y="627" width="80" height="51"/>
<rect key="frame" x="159.66666666666666" y="639" width="56" height="39"/>
<color key="backgroundColor" systemColor="systemBlueColor"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="22"/>
<state key="normal" title="Retry">
Expand Down Expand Up @@ -63,12 +63,12 @@
<color key="selectedSegmentTintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</segmentedControl>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" contentInsetAdjustmentBehavior="never" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="NIJ-V3-NpL">
<rect key="frame" x="0.0" y="199.66666666666666" width="375" height="423.33333333333337"/>
<rect key="frame" x="0.0" y="199.66666666666666" width="375" height="435.33333333333337"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="sectionIndexBackgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="none" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="infoCell" rowHeight="147" id="C3K-o8-BC5" customClass="InfoCell" customModule="DGCAVerifier" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="375" height="147"/>
<rect key="frame" x="0.0" y="24.333333969116211" width="375" height="147"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="C3K-o8-BC5" id="Xhy-8E-hY4">
<rect key="frame" x="0.0" y="0.0" width="375" height="147"/>
Expand Down Expand Up @@ -119,7 +119,7 @@
</constraints>
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="gradient" translatesAutoresizingMaskIntoConstraints="NO" id="Enm-XG-fIc">
<rect key="frame" x="0.0" y="591" width="375" height="32"/>
<rect key="frame" x="0.0" y="603" width="375" height="32"/>
<constraints>
<constraint firstAttribute="height" constant="32" id="1kc-qQ-0OX"/>
</constraints>
Expand Down Expand Up @@ -208,7 +208,7 @@
</scenes>
<designables>
<designable name="a9u-Ia-KEX">
<size key="intrinsicContentSize" width="80" height="51"/>
<size key="intrinsicContentSize" width="56" height="39"/>
</designable>
</designables>
<resources>
Expand All @@ -217,10 +217,10 @@
<image name="gradient" width="1" height="100"/>
<image name="main_eu_logo" width="162" height="42"/>
<namedColor name="black">
<color red="0.25098039215686274" green="0.25098039215686274" blue="0.25098039215686274" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.25099998712539673" green="0.25099998712539673" blue="0.25099998712539673" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="green">
<color red="0.27450980392156865" green="0.47843137254901957" blue="0.22352941176470587" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.27500000596046448" green="0.4779999852180481" blue="0.22400000691413879" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<systemColor name="systemBlueColor">
<color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand Down
Loading

0 comments on commit 913070c

Please sign in to comment.