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

@@ -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?) {