Add swipe action on download Lightshow

This commit is contained in:
Quentin Millardet
2024-06-04 00:03:28 +02:00
parent 53d5be6a02
commit 60cb3d37c8
6 changed files with 94 additions and 31 deletions

View File

@@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
663BEC572BEE2DA0000585D9 /* LightshowDownloadOrAddView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 663BEC562BEE2DA0000585D9 /* LightshowDownloadOrAddView.swift */; };
66A9B7DE2C0E642200CA1A0A /* LightshowDownloadCellSecond.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66A9B7DD2C0E642200CA1A0A /* LightshowDownloadCellSecond.swift */; };
66BE20232BD5AA790051989C /* LightshowDownloadCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66BE20222BD5AA790051989C /* LightshowDownloadCell.swift */; };
66E3889B2BD3371A0004C1F2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66E3889A2BD3371A0004C1F2 /* AppDelegate.swift */; };
66E3889D2BD3371A0004C1F2 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66E3889C2BD3371A0004C1F2 /* SceneDelegate.swift */; };
@@ -42,6 +43,7 @@
/* Begin PBXFileReference section */
663BEC562BEE2DA0000585D9 /* LightshowDownloadOrAddView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LightshowDownloadOrAddView.swift; sourceTree = "<group>"; };
668F709C2BE82632004A9EDD /* LightshowManager.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = LightshowManager.entitlements; sourceTree = "<group>"; };
66A9B7DD2C0E642200CA1A0A /* LightshowDownloadCellSecond.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LightshowDownloadCellSecond.swift; sourceTree = "<group>"; };
66BE20222BD5AA790051989C /* LightshowDownloadCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LightshowDownloadCell.swift; sourceTree = "<group>"; };
66D401E92BE7EFD1004814D0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Main.strings; sourceTree = "<group>"; };
66E388972BD3371A0004C1F2 /* LightshowManager.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LightshowManager.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -109,6 +111,7 @@
66E388992BD3371A0004C1F2 /* LightshowManager */ = {
isa = PBXGroup;
children = (
66A9B7DD2C0E642200CA1A0A /* LightshowDownloadCellSecond.swift */,
668F709C2BE82632004A9EDD /* LightshowManager.entitlements */,
66E3889A2BD3371A0004C1F2 /* AppDelegate.swift */,
66E388A32BD3371C0004C1F2 /* Assets.xcassets */,
@@ -279,6 +282,7 @@
66E3889F2BD3371A0004C1F2 /* ViewController.swift in Sources */,
663BEC572BEE2DA0000585D9 /* LightshowDownloadOrAddView.swift in Sources */,
66BE20232BD5AA790051989C /* LightshowDownloadCell.swift in Sources */,
66A9B7DE2C0E642200CA1A0A /* LightshowDownloadCellSecond.swift in Sources */,
66E388CB2BD548990004C1F2 /* LightshowModel.swift in Sources */,
66E388CD2BD549B90004C1F2 /* LightshowDownloadView.swift in Sources */,
66E3889B2BD3371A0004C1F2 /* AppDelegate.swift in Sources */,

View File

@@ -7,17 +7,17 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "D0E79D3F-B868-4417-B9C9-D1D626356F3D"
uuid = "1BEFFFD0-B8D9-4839-A8E9-37CF4443CF62"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "LightshowManager/LightshowDownloadCell.swift"
filePath = "LightshowManager/LightshowDownloadView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "13"
endingLineNumber = "13"
landmarkName = "LightshowDownloadCell"
landmarkType = "3">
startingLineNumber = "30"
endingLineNumber = "30"
landmarkName = "tableView(_:cellForRowAt:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>

View File

@@ -139,13 +139,14 @@
<!--Lightshow Download View-->
<scene sceneID="dI5-cz-aov">
<objects>
<placeholder placeholderIdentifier="IBFirstResponder" id="OGa-Bj-Kz7" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
<tableViewController id="EaI-Xt-tQP" customClass="LightshowDownloadView" customModule="LightshowManager" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" id="17d-ar-rgx">
<rect key="frame" x="0.0" y="0.0" width="430" height="932"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" restorationIdentifier="lightshowDownloadCell" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="lightshowDownloadCell" rowHeight="74" id="NEU-PL-acG" customClass="LightshowDownloadCell" customModule="LightshowManager" customModuleProvider="target">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" restorationIdentifier="lightshowDownloadCell" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="lightshowDownloadCell" rowHeight="74" id="NEU-PL-acG" customClass="LightshowDownloadCellSecond" customModule="LightshowManager" customModuleProvider="target">
<rect key="frame" x="0.0" y="50" width="430" height="74"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="NEU-PL-acG" id="9k8-K2-vHz">
@@ -153,14 +154,31 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="66a-IA-YSR">
<rect key="frame" x="20" y="11" width="42" height="21"/>
<rect key="frame" x="20" y="11" width="347" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="p51-aq-pBZ">
<rect key="frame" x="172" y="42" width="42" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="exclamationmark.triangle.fill" catalog="system" translatesAutoresizingMaskIntoConstraints="NO" id="taK-s6-GOZ">
<rect key="frame" x="356" y="15" width="48" height="48"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="tintColor" systemColor="systemYellowColor"/>
</imageView>
</subviews>
</tableViewCellContentView>
<connections>
<outlet property="LightshowName" destination="66a-IA-YSR" id="q46-yf-bHM"/>
<outlet property="alertMessage" destination="p51-aq-pBZ" id="9bq-jx-4go"/>
<outlet property="warningIcon" destination="taK-s6-GOZ" id="ROG-X7-p97"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
@@ -170,7 +188,6 @@
</tableView>
<navigationItem key="navigationItem" id="D7b-Rf-ffZ"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="OGa-Bj-Kz7" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2458.6046511627906" y="-328.32618025751077"/>
</scene>
@@ -213,6 +230,7 @@
<resources>
<image name="camera.metering.unknown" catalog="system" width="128" height="93"/>
<image name="door.left.hand.open" catalog="system" width="108" height="128"/>
<image name="exclamationmark.triangle.fill" catalog="system" width="128" height="109"/>
<image name="warninglight" catalog="system" width="128" height="115"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -220,5 +238,8 @@
<systemColor name="systemRedColor">
<color red="1" green="0.23137254901960785" blue="0.18823529411764706" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemYellowColor">
<color red="1" green="0.80000000000000004" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>

View File

@@ -1,16 +1 @@
//
// LightshowDownloadCell.swift
// LightshowManager
//
// Created by Quentin Millardet on 21/04/2024.
//
import UIKit
class LightshowDownloadCell : UITableViewCell{
@IBOutlet weak var warningMessage: UIImageView!
@IBOutlet weak var LightshowName: UILabel!
@IBOutlet weak var alertLabel: UILabel!
}

View File

@@ -0,0 +1,16 @@
//
// LightshowDownloadCell.swift
// LightshowManager
//
// Created by Quentin Millardet on 21/04/2024.
//
import UIKit
class LightshowDownloadCellSecond : UITableViewCell{
@IBOutlet weak var LightshowName: UILabel!
@IBOutlet weak var warningIcon: UIImageView!
@IBOutlet weak var alertMessage: UILabel!
}

View File

@@ -29,16 +29,53 @@ class LightshowDownloadView: UITableViewController{
let isOk : Bool = model?.isOkFiles() ?? false;
//(cell as! LightshowDownloadCell).LightshowName.text = model?.name
//(cell as! LightshowDownloadCell).warningMessage.isHidden = isOk;
//var alertText = ""
//if (!isOk){
// alertText = "(Le fichcier mp3 ou fseq n'a pas été reconnu)"
//}
//(cell as! LightshowDownloadCell).alertLabel.text = alertText
(cell as! LightshowDownloadCellSecond).LightshowName.text = model?.name
(cell as! LightshowDownloadCellSecond).warningIcon.isHidden = isOk;
var alertText = ""
if (!isOk){
alertText = "(Le fichcier mp3 ou fseq n'a pas été reconnu)"
}
(cell as! LightshowDownloadCellSecond).alertMessage.text = alertText
return cell!
}
override func tableView(_ tableView: UITableView,
leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
// Trash action
let trash = UIContextualAction(style: .destructive,
title: "Edit") { [weak self] (action, view, completionHandler) in
self?.handleMarkAsUnread()
completionHandler(true)
}
trash.backgroundColor = .systemGray
let configuration = UISwipeActionsConfiguration(actions: [trash])
return configuration
}
override func tableView(_ tableView: UITableView,
trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
// Trash action
let trash = UIContextualAction(style: .destructive,
title: "Trash") { [weak self] (action, view, completionHandler) in
self?.handleMoveToTrash()
completionHandler(true)
}
trash.backgroundColor = .systemRed
let configuration = UISwipeActionsConfiguration(actions: [trash])
return configuration
}
private func handleMarkAsUnread() {
print("Marked as unread")
}
private func handleMoveToTrash() {
print("Moved to trash")
}
// Permet de passer des informations à une vue avant que celle-ci ne soit créee
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {