Skip to content

Commit

Permalink
Merge pull request #179 from CovidTrackerFr/develop
Browse files Browse the repository at this point in the history
Release 1.5.0 - Merge develop into main
  • Loading branch information
victor-sarda authored Jan 16, 2022
2 parents ae11e45 + 62b8498 commit 130c1dd
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 95 deletions.
10 changes: 5 additions & 5 deletions ViteMaDose.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
shellScript = "# Adds support for Apple Silicon brew directory\nexport PATH=\"$PATH:/opt/homebrew/bin\"\n\nif which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
};
DA68646626276624005B2AC2 /* Crashlytics */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -1443,7 +1443,7 @@
repositoryURL = "https://github.com/mxcl/PromiseKit";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 6.13.3;
minimumVersion = 6.16.2;
};
};
575CC20F262AD8F6008D1869 /* XCRemoteSwiftPackageReference "PhoneNumberKit" */ = {
Expand Down Expand Up @@ -1483,7 +1483,7 @@
repositoryURL = "https://github.com/firebase/firebase-ios-sdk.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 8.9.1;
minimumVersion = 8.10.0;
};
};
57954761263E1A1600AD5DFD /* XCRemoteSwiftPackageReference "Moya" */ = {
Expand All @@ -1499,15 +1499,15 @@
repositoryURL = "https://github.com/efremidze/Haptica.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 3.0.2;
minimumVersion = 3.0.3;
};
};
6AD0CC16262EC128001F8807 /* XCRemoteSwiftPackageReference "Kingfisher" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/onevcat/Kingfisher.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 6.2.1;
minimumVersion = 7.1.2;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"repositoryURL": "https://github.com/firebase/firebase-ios-sdk.git",
"state": {
"branch": null,
"revision": "839cc6b0cd80b0b8bf81fe9bd82b743b25dc6446",
"version": "8.9.1"
"revision": "08686f04881483d2bc098b2696e674c0ba135e47",
"version": "8.10.0"
}
},
{
Expand Down Expand Up @@ -105,8 +105,8 @@
"repositoryURL": "https://github.com/onevcat/Kingfisher.git",
"state": {
"branch": null,
"revision": "15d199e84677303a7004ed2c5ecaa1a90f3863f8",
"version": "6.2.1"
"revision": "0c02c46cfdc0656ce74fd0963a75e5000a0b7f23",
"version": "7.1.2"
}
},
{
Expand Down
7 changes: 7 additions & 0 deletions ViteMaDose/Helpers/Extensions/UIDevice+common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@ extension UIDevice {
}
return version < 15.0
}

var isUnderiOS14: Bool {
guard let version = Float(self.systemVersion) else {
return false
}
return version < 14.0
}
}
5 changes: 2 additions & 3 deletions ViteMaDose/Models/Credit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Foundation
// MARK: - Credit

struct Credit: Codable {
let id: String?
let nom: String?
let pseudo: String?
let photo: String?
Expand All @@ -22,11 +21,11 @@ struct Credit: Codable {
let links: [CreditLink]?

var shownName: String {
nom ?? pseudo ?? id ?? Localization.Credits.noName
nom ?? pseudo ?? Localization.Credits.noName
}

var shownRole: String {
teams?.joined(separator: ", ") ?? Localization.Credits.noRole
teams?.joined(separator: .commaWithSpace) ?? Localization.Credits.noRole
}
}

Expand Down
38 changes: 14 additions & 24 deletions ViteMaDose/ViewModels/Credit/CreditViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,19 @@ class CreditViewModel: CreditViewModelProvider {
return nil
}

let creditLink: URL? = {
if let url = URL(string: credit.site_web.emptyIfNil) {
return url
} else if let url = URL(string: (credit.links?.first?.url).emptyIfNil) {
return url
}
return nil
}()

return CreditCellViewData(
creditName: credit.shownName,
creditRole: AccessibilityString(rawValue: pretty(toDiplay: credit.shownRole), vocalizedValue: pretty(toVocalize: credit.shownRole)),
creditLink: URL(string: credit.site_web ?? credit.links?.first?.url ?? ""),
creditLink: creditLink,
creditImage: credit.photo
)
}
Expand Down Expand Up @@ -93,26 +102,6 @@ class CreditViewModel: CreditViewModelProvider {
.replacingOccurrences(of: "web", with: "application web")
}

/// Keep unique `Credit` by filtering the givene `values` by `nom` properties
/// - Parameter values: The data set to filter
/// - Returns: The filtered credits
private func keepUnique(within values: [Credit]) -> [Credit] {
var unique = [Credit]()
values.forEach { item in
let isAlradyStored = unique.contains { element in
if let itemName = item.nom?.uppercased(), let elementName = element.nom?.uppercased(), itemName == elementName {
return true
} else {
return false
}
}
if !isAlradyStored {
unique.append(item)
}
}
return unique
}

// MARK: Load of data

func load() {
Expand All @@ -133,9 +122,10 @@ class CreditViewModel: CreditViewModelProvider {
}

private func handleLoad(with credits: [Credit]) {
let uniqueCredits = keepUnique(within: credits)
self.allCredits = uniqueCredits.sorted(by: { $0.shownName < $1.shownName })
delegate?.reloadTableView(with: uniqueCredits)
self.allCredits = credits
.unique(by: \.pseudo)
.sorted(by: { $0.shownName < $1.shownName })
delegate?.reloadTableView(with: self.allCredits)
}

private func handleError(_ error: Error) {
Expand Down
5 changes: 2 additions & 3 deletions ViteMaDose/Views/CentresList/Cells/CentreActionCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ class CentreActionCell: UITableViewCell {
)
actionButton.accessibilityLabel = Localization.A11y.VoiceOver.Actions.filter_button_label
actionButton.accessibilityHint = Localization.A11y.VoiceOver.Actions.filter_button_hint
if UIDevice.current.isUnderiOS15 {
actionButton.setImage(UIImage(systemName: "list.dash"), for: .normal)
}
let actionButtonIconName = UIDevice.current.isUnderiOS15 ? "list.dash" : "line.3.horizontal.decrease.circle.fill"
actionButton.setImage(UIImage(systemName: actionButtonIconName), for: .normal)
}

@objc private func didTapActionButton() {
Expand Down
8 changes: 4 additions & 4 deletions ViteMaDose/Views/CentresList/Cells/CentreActionCell.xib
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3ej-ox-E3h" userLabel="Filter Button">
<rect key="frame" x="309" y="0.0" width="45" height="78"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" image="line.3.horizontal.decrease.circle.fill" catalog="system" title=""/>
<rect key="frame" x="334.5" y="0.0" width="19.5" height="78"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="" image="ellipsis" catalog="system"/>
</button>
</subviews>
</stackView>
Expand All @@ -58,7 +58,7 @@
</tableViewCell>
</objects>
<resources>
<image name="line.3.horizontal.decrease.circle.fill" catalog="system" width="128" height="121"/>
<image name="ellipsis" catalog="system" width="128" height="37"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
Expand Down
6 changes: 4 additions & 2 deletions ViteMaDose/Views/Credits/Cells/CreditCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ class CreditCell: UITableViewCell {
creditImageView.setCornerRadius(Constant.viewsCornerRadius)
creditContainerView.setCornerRadius(Constant.viewsCornerRadius)

creditImageView.kf.setImage(with: URL(string: viewData.creditImage ?? ""))
if let imageURL = URL(string: viewData.creditImage.emptyIfNil) {
creditImageView.kf.setImage(with: imageURL)
}
creditNameLabel.text = viewData.creditName

// Need to be refactored: if too big a11y sizes, diplay is dirty (sometimes role or name)
Expand All @@ -76,7 +78,7 @@ class CreditCell: UITableViewCell {
creditRoleLabel.accessibilityLabel = viewData.creditRole.vocalizedValue
}

if let url = buttonURL, UIApplication.shared.canOpenURL(url) {
if let url = buttonURL, url.isValid {
creditLinkButton.isHidden = false
creditLinkButton.accessibilityLabel = Localization.A11y.VoiceOver.Credits.credit_button_label
creditLinkButton.accessibilityHint = Localization.A11y.VoiceOver.Credits.credit_button_hint
Expand Down
39 changes: 19 additions & 20 deletions ViteMaDose/Views/Credits/Cells/CreditCell.xib
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" rowHeight="370" id="6oK-Dz-Q8T" customClass="CreditCell" customModule="ViteMaDose" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="407" height="126"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" rowHeight="325" id="6oK-Dz-Q8T" customClass="CreditCell" customModule="ViteMaDose" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="407" height="81"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="6oK-Dz-Q8T" id="j5w-8X-A2y">
<rect key="frame" x="0.0" y="0.0" width="407" height="126"/>
<rect key="frame" x="0.0" y="0.0" width="407" height="81"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="CFm-F6-pGf">
<rect key="frame" x="24" y="5" width="359" height="96.5"/>
<rect key="frame" x="24" y="5" width="359" height="66"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" spacing="15" translatesAutoresizingMaskIntoConstraints="NO" id="yn7-42-KlF">
<rect key="frame" x="8" y="8" width="343" height="80.5"/>
<rect key="frame" x="8" y="8" width="335" height="50"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ZZP-zD-Fe1">
<rect key="frame" x="0.0" y="0.0" width="40" height="80.5"/>
<rect key="frame" x="0.0" y="0.0" width="40" height="50"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="JOF-Zo-WjW">
<rect key="frame" x="0.0" y="20.5" width="40" height="40"/>
<rect key="frame" x="0.0" y="5" width="40" height="40"/>
<constraints>
<constraint firstAttribute="width" constant="40" id="J7H-2P-pRd"/>
<constraint firstAttribute="height" constant="40" id="TN2-VE-hHq"/>
Expand All @@ -43,30 +43,29 @@
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="ZXs-sh-754">
<rect key="frame" x="55" y="0.0" width="288" height="80.5"/>
<rect key="frame" x="55" y="0.0" width="240" height="50"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="Name" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" minimumFontSize="12" translatesAutoresizingMaskIntoConstraints="NO" id="Arf-tf-NyD">
<rect key="frame" x="0.0" y="0.0" width="288" height="60"/>
<rect key="frame" x="0.0" y="0.0" width="240" height="29.5"/>
<fontDescription key="fontDescription" type="system" pointSize="24"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Role" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3zb-J9-cLa">
<rect key="frame" x="0.0" y="60" width="288" height="20.5"/>
<rect key="frame" x="0.0" y="29.5" width="240" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="SpD-fC-YN7">
<rect key="frame" x="343" y="0.0" width="25" height="80.5"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="SpD-fC-YN7">
<rect key="frame" x="310" y="0.0" width="25" height="50"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="25" id="8fD-T2-b4K"/>
<constraint firstAttribute="width" relation="lessThanOrEqual" constant="50" id="FcV-4K-0xg"/>
<constraint firstAttribute="width" constant="25" id="2wa-H1-L0x"/>
</constraints>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="person.text.rectangle" catalog="system"/>
<state key="normal" image="arrow.up.right.circle" catalog="system"/>
<connections>
<action selector="creditLinkButtonClicked:" destination="6oK-Dz-Q8T" eventType="touchUpInside" id="V6C-rI-0TD"/>
</connections>
Expand All @@ -79,15 +78,15 @@
<constraint firstItem="yn7-42-KlF" firstAttribute="leading" secondItem="CFm-F6-pGf" secondAttribute="leading" constant="8" id="byf-V1-2vJ"/>
<constraint firstAttribute="bottom" secondItem="yn7-42-KlF" secondAttribute="bottom" constant="8" id="fXf-6R-Fio"/>
<constraint firstItem="yn7-42-KlF" firstAttribute="top" secondItem="CFm-F6-pGf" secondAttribute="top" constant="8" id="gsq-pU-TY5"/>
<constraint firstAttribute="trailing" secondItem="yn7-42-KlF" secondAttribute="trailing" constant="8" id="wLB-gl-z6x"/>
<constraint firstAttribute="trailing" secondItem="yn7-42-KlF" secondAttribute="trailing" constant="16" id="wLB-gl-z6x"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="CFm-F6-pGf" firstAttribute="top" secondItem="j5w-8X-A2y" secondAttribute="top" constant="5" id="O6V-mY-fnN"/>
<constraint firstAttribute="bottom" secondItem="CFm-F6-pGf" secondAttribute="bottom" constant="5" id="ZHI-99-zCC"/>
<constraint firstAttribute="bottom" secondItem="CFm-F6-pGf" secondAttribute="bottom" constant="5" id="Vm1-zo-Inf"/>
<constraint firstAttribute="trailing" secondItem="CFm-F6-pGf" secondAttribute="trailing" constant="24" id="amF-1t-Tve"/>
<constraint firstItem="CFm-F6-pGf" firstAttribute="top" secondItem="j5w-8X-A2y" secondAttribute="top" constant="5" id="qNM-rb-leC"/>
<constraint firstItem="CFm-F6-pGf" firstAttribute="leading" secondItem="j5w-8X-A2y" secondAttribute="leading" constant="24" id="uzp-XR-XFb"/>
</constraints>
</tableViewCellContentView>
Expand All @@ -98,11 +97,11 @@
<outlet property="creditNameLabel" destination="Arf-tf-NyD" id="Q4W-Oc-Szi"/>
<outlet property="creditRoleLabel" destination="3zb-J9-cLa" id="pzu-hp-UaZ"/>
</connections>
<point key="canvasLocation" x="96.376811594202906" y="-6.0267857142857144"/>
<point key="canvasLocation" x="103.62318840579711" y="-40.513392857142854"/>
</tableViewCell>
</objects>
<resources>
<image name="person.text.rectangle" catalog="system" width="128" height="93"/>
<image name="arrow.up.right.circle" catalog="system" width="128" height="121"/>
<systemColor name="secondarySystemBackgroundColor">
<color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
Expand Down
Loading

0 comments on commit 130c1dd

Please sign in to comment.