Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Public share quota, advanced settings chip #1430

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion kDrive/UI/Controller/Files/FileDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class FileDetailViewController: UIViewController, SceneStateRestorable {
@IBOutlet var commentButton: UIButton!

@LazyInjectService var accountManager: AccountManageable
@LazyInjectService var router: AppNavigable

var file: File!
var driveFileManager: DriveFileManager!
Expand Down Expand Up @@ -552,7 +553,7 @@ extension FileDetailViewController: UITableViewDelegate, UITableViewDataSource {
case .share:
let cell = tableView.dequeueReusableCell(type: ShareLinkTableViewCell.self, for: indexPath)
cell.delegate = self
cell.configureWith(file: file, currentPackId: packId, insets: false)
cell.configureWith(file: file, currentPackId: packId, driveFileManager: driveFileManager, insets: false)
return cell
case .categories:
let cell = tableView.dequeueReusableCell(type: ManageCategoriesTableViewCell.self, for: indexPath)
Expand Down Expand Up @@ -921,6 +922,11 @@ extension FileDetailViewController: ShareLinkTableViewCellDelegate {
}

func shareLinkSettingsButtonPressed() {
if packId == .myKSuite, driveFileManager.drive.sharedLinkQuotaExceeded {
router.presentUpSaleSheet()
return
}

performSegue(withIdentifier: "toShareLinkSettingsSegue", sender: nil)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Infomaniak kDrive - iOS App
Copyright (C) 2025 Infomaniak Network SA

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import Foundation
import kDriveCore

public enum MykSuiteRestrictions {
public static func sharedLinkRestricted(packId: DrivePackId?,
driveFileManager: DriveFileManager,
fileHasShareLink: Bool) -> Bool {
guard let packId else { return false }
return packId == .myKSuite
&& driveFileManager.drive.sharedLinkQuotaExceeded
&& !fileHasShareLink
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ extension ShareAndRightsViewController: UITableViewDelegate, UITableViewDataSour
let cell = tableView.dequeueReusableCell(type: ShareLinkTableViewCell.self, for: indexPath)
cell.initWithPositionAndShadow(isFirst: true, isLast: true, radius: 6)
cell.delegate = self
cell.configureWith(file: file, currentPackId: packId)
cell.configureWith(file: file, currentPackId: packId, driveFileManager: driveFileManager)
return cell
case .access:
let cell = tableView.dequeueReusableCell(type: UsersAccessTableViewCell.self, for: indexPath)
Expand All @@ -212,7 +212,7 @@ extension ShareAndRightsViewController: UITableViewDelegate, UITableViewDataSour
case .invite:
break
case .link:
guard packId != .myKSuite else {
guard !showMykSuiteRestriction(fileHasShareLink: file.hasSharelink) else {
router.presentUpSaleSheet()
return
}
Expand Down Expand Up @@ -242,6 +242,12 @@ extension ShareAndRightsViewController: UITableViewDelegate, UITableViewDataSour
.instantiate(title: KDriveResourcesStrings.Localizable.fileShareDetailsUsersAccesTitle)
}
}

private func showMykSuiteRestriction(fileHasShareLink: Bool) -> Bool {
return MykSuiteRestrictions.sharedLinkRestricted(packId: packId,
driveFileManager: driveFileManager,
fileHasShareLink: fileHasShareLink)
}
}

// MARK: - Rights selection delegate
Expand Down Expand Up @@ -319,6 +325,11 @@ extension ShareAndRightsViewController: ShareLinkTableViewCellDelegate {
}

func shareLinkSettingsButtonPressed() {
if packId == .myKSuite, driveFileManager.drive.sharedLinkQuotaExceeded {
router.presentUpSaleSheet()
return
}

let shareLinkSettingsViewController = ShareLinkSettingsViewController.instantiate()
shareLinkSettingsViewController.driveFileManager = driveFileManager
shareLinkSettingsViewController.file = file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,7 @@ extension ShareLinkSettingsViewController: UITableViewDelegate, UITableViewDataS

if !option.isEnabled(drive: driveFileManager.drive) {
cell.actionHandler = { [weak self] _ in
guard let self else { return }
let driveFloatingPanelController = SecureLinkFloatingPanelViewController.instantiatePanel()
let floatingPanelViewController = driveFloatingPanelController
.contentViewController as? SecureLinkFloatingPanelViewController
floatingPanelViewController?.rightButton.isEnabled = driveFileManager.drive.accountAdmin
floatingPanelViewController?.actionHandler = { _ in
driveFloatingPanelController.dismiss(animated: true) {
self.router.presentUpSaleSheet()
}
}
present(driveFloatingPanelController, animated: true)
self?.router.presentUpSaleSheet()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class ShareLinkSettingTableViewCell: InsetTableViewCell {
@IBOutlet var passwordTextField: MaterialOutlinedTextField!
@IBOutlet var newPasswordButton: IKButton!
@IBOutlet var compactDatePicker: UIDatePicker!
@IBOutlet var updateView: UIView!
@IBOutlet var updateButton: UIButton!
@IBOutlet var chipContainerView: UIView!

var option: ShareLinkSettingsViewController.OptionsRow?
weak var delegate: ShareLinkSettingsDelegate?
Expand All @@ -48,7 +50,7 @@ class ShareLinkSettingTableViewCell: InsetTableViewCell {
super.awakeFromNib()
passwordTextField.isHidden = true
compactDatePicker.isHidden = true
updateButton.isHidden = true
updateView.isHidden = true
newPasswordButton.isHidden = true

compactDatePicker.minimumDate = Date()
Expand Down Expand Up @@ -79,6 +81,22 @@ class ShareLinkSettingTableViewCell: InsetTableViewCell {
rightView.addSubview(overlayButton)
passwordTextField.rightView = rightView
passwordTextField.rightViewMode = .always

prepareChip()
}

private func prepareChip() {
let chipView = MyKSuiteChip.instantiateGrayChip()

chipView.translatesAutoresizingMaskIntoConstraints = false
chipContainerView.addSubview(chipView)

NSLayoutConstraint.activate([
chipView.leadingAnchor.constraint(greaterThanOrEqualTo: chipContainerView.leadingAnchor),
chipView.trailingAnchor.constraint(greaterThanOrEqualTo: chipContainerView.trailingAnchor),
chipView.topAnchor.constraint(equalTo: chipContainerView.topAnchor),
chipView.bottomAnchor.constraint(equalTo: chipContainerView.bottomAnchor)
])
}

override func setSelected(_ selected: Bool, animated: Bool) {
Expand Down Expand Up @@ -109,7 +127,7 @@ class ShareLinkSettingTableViewCell: InsetTableViewCell {
settingDetail.text = isFolder ? option.folderDescription : option.fileDescription
settingSwitch.isOn = switchValue
settingSwitch.isEnabled = option.isEnabled(drive: drive)
updateButton.isHidden = option.isEnabled(drive: drive)
updateView.isHidden = option.isEnabled(drive: drive)
passwordTextField.isHidden = true
newPasswordButton.isHidden = true
compactDatePicker.isHidden = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23094" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23084"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
<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"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -77,27 +78,48 @@
<action selector="compactDatePickerChanged:" destination="KGk-i7-Jjw" eventType="valueChanged" id="WEy-d9-ajH"/>
</connections>
</datePicker>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="2ju-Mt-PMJ">
<rect key="frame" x="0.0" y="268" width="147" height="36"/>
<color key="backgroundColor" name="backgroundColor"/>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="OhU-uH-GaZ" userLabel="UpdateView">
<rect key="frame" x="0.0" y="268" width="240" height="36"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="2ju-Mt-PMJ">
<rect key="frame" x="0.0" y="0.0" width="149" height="36"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="36" id="eHu-JC-Am2"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<state key="normal" title="Faire évoluer mon offre">
<color key="titleColor" name="infomaniakColor"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<real key="value" value="18"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="string" keyPath="xibLocKey" value="buttonUpgradeOffer"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="updateButtonPressed:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="w2G-aU-fKm"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3bI-0o-fhJ">
<rect key="frame" x="161" y="8" width="20" height="20"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="width" constant="20" placeholder="YES" id="2Sr-ip-kwP"/>
<constraint firstAttribute="height" constant="20" placeholder="YES" id="JHu-V9-VWG"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="36" id="eHu-JC-Am2"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="3bI-0o-fhJ" secondAttribute="trailing" constant="20" id="5dP-UA-2eL"/>
<constraint firstItem="3bI-0o-fhJ" firstAttribute="centerY" secondItem="2ju-Mt-PMJ" secondAttribute="centerY" id="GkM-oB-uic"/>
<constraint firstItem="2ju-Mt-PMJ" firstAttribute="leading" secondItem="OhU-uH-GaZ" secondAttribute="leading" id="VLG-DN-JN5"/>
<constraint firstAttribute="bottom" secondItem="2ju-Mt-PMJ" secondAttribute="bottom" id="frg-wq-gGP"/>
<constraint firstItem="3bI-0o-fhJ" firstAttribute="leading" secondItem="2ju-Mt-PMJ" secondAttribute="trailing" constant="12" id="hHD-up-AfZ"/>
<constraint firstItem="2ju-Mt-PMJ" firstAttribute="top" secondItem="OhU-uH-GaZ" secondAttribute="top" id="jlv-uk-2qh"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<inset key="contentEdgeInsets" minX="8" minY="0.0" maxX="8" maxY="0.0"/>
<state key="normal" title="Faire évoluer mon offre">
<color key="titleColor" name="infomaniakColor"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<real key="value" value="18"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="string" keyPath="xibLocKey" value="buttonUpgradeOffer"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="updateButtonPressed:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="w2G-aU-fKm"/>
</connections>
</button>
</view>
</subviews>
<constraints>
<constraint firstItem="TIN-sh-74m" firstAttribute="leading" secondItem="1Xm-Dy-4ti" secondAttribute="leading" id="1uf-vI-Lak"/>
Expand Down Expand Up @@ -134,6 +156,7 @@
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="bottomConstraint" destination="b3L-GJ-LSF" id="Y7h-fG-fCo"/>
<outlet property="chipContainerView" destination="3bI-0o-fhJ" id="7bR-Qw-nEu"/>
<outlet property="compactDatePicker" destination="Em4-Ij-GbM" id="op2-IE-Hyt"/>
<outlet property="contentInsetView" destination="aqX-hy-10J" id="elq-4h-42h"/>
<outlet property="newPasswordButton" destination="mNc-Na-0mD" id="FQM-G6-POG"/>
Expand All @@ -143,6 +166,7 @@
<outlet property="titleLabel" destination="rtI-Wc-46s" id="1mr-2E-JMe"/>
<outlet property="topConstraint" destination="eo3-Nh-xzM" id="zKn-C5-K50"/>
<outlet property="updateButton" destination="2ju-Mt-PMJ" id="GR1-2E-f95"/>
<outlet property="updateView" destination="OhU-uH-GaZ" id="RVy-CA-OYk"/>
</connections>
<point key="canvasLocation" x="148.55072463768118" y="253.45982142857142"/>
</tableViewCell>
Expand All @@ -151,17 +175,17 @@
<namedColor name="backgroundCardViewColor">
<color red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="backgroundColor">
<color red="0.95686274509803926" green="0.96470588235294119" blue="0.99215686274509807" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="infomaniakColor">
<color red="0.0" green="0.59600001573562622" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.0" green="0.59607843137254901" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="primaryTextColor">
<color red="0.40000000596046448" green="0.40000000596046448" blue="0.40000000596046448" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="titleColor">
<color red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.20000000298023224" green="0.20000000298023224" blue="0.20000000298023224" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
Loading
Loading