Skip to content

Commit 4f59cff

Browse files
Merge pull request #3734 from nextcloud/gui-26
Gui 26 - Media
2 parents b43be16 + ab5a15d commit 4f59cff

12 files changed

+392
-322
lines changed

Nextcloud.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@
754754
F793E5A128B76541005E4B02 /* NotificationCenter+MainThread.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70460512499061800BB98A7 /* NotificationCenter+MainThread.swift */; };
755755
F794E13D2BBBFF2E003693D7 /* NCMainTabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F794E13C2BBBFF2E003693D7 /* NCMainTabBarController.swift */; };
756756
F794E13F2BBC0F70003693D7 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F794E13E2BBC0F70003693D7 /* SceneDelegate.swift */; };
757+
F79699E72E689F68000EC82A /* NCMediaNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F79699E62E689F68000EC82A /* NCMediaNavigationController.swift */; };
757758
F798F0E225880608000DAFFD /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70CEF5523E9C7E50007035B /* UIColor+Extension.swift */; };
758759
F798F0E725880609000DAFFD /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70CEF5523E9C7E50007035B /* UIColor+Extension.swift */; };
759760
F798F0EC2588060A000DAFFD /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70CEF5523E9C7E50007035B /* UIColor+Extension.swift */; };
@@ -1665,6 +1666,7 @@
16651666
F79131C728AFB86E00577277 /* eu */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = eu; path = eu.lproj/InfoPlist.strings; sourceTree = "<group>"; };
16661667
F794E13C2BBBFF2E003693D7 /* NCMainTabBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCMainTabBarController.swift; sourceTree = "<group>"; };
16671668
F794E13E2BBC0F70003693D7 /* SceneDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
1669+
F79699E62E689F68000EC82A /* NCMediaNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCMediaNavigationController.swift; sourceTree = "<group>"; };
16681670
F799DF812C4B7DCC003410B5 /* NCSectionFooter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCSectionFooter.swift; sourceTree = "<group>"; };
16691671
F799DF842C4B7E56003410B5 /* NCSectionHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCSectionHeader.swift; sourceTree = "<group>"; };
16701672
F799DF872C4B83CC003410B5 /* NCCollectionViewCommon+EasyTipView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCCollectionViewCommon+EasyTipView.swift"; sourceTree = "<group>"; };
@@ -3243,6 +3245,7 @@
32433245
F7BD0A032C4689E9003A4A6D /* NCMedia+MediaLayout.swift */,
32443246
F7E2B64E2DDCC5C30075B4D0 /* NCMedia+TransferDelegate.swift */,
32453247
F78B87E62B62527100C65ADC /* NCMediaDataSource.swift */,
3248+
F79699E62E689F68000EC82A /* NCMediaNavigationController.swift */,
32463249
F7D60CAE2C941ACB008FBFDD /* NCMediaPinchGesture.swift */,
32473250
F78B87E82B62550800C65ADC /* NCMediaDownloadThumbnail.swift */,
32483251
F755CB3F2B8CB13C00CE27E9 /* NCMediaLayout.swift */,
@@ -4872,6 +4875,7 @@
48724875
F749B651297B0F2400087535 /* NCManageDatabase+Avatar.swift in Sources */,
48734876
F7FAFD3A28BFA948000777FE /* NCNotification+Menu.swift in Sources */,
48744877
F74C0436253F1CDC009762AB /* NCShares.swift in Sources */,
4878+
F79699E72E689F68000EC82A /* NCMediaNavigationController.swift in Sources */,
48754879
F7AC1CB028AB94490032D99F /* Array+Extension.swift in Sources */,
48764880
F7AE00F5230D5F9E007ACF8A /* NCLoginProvider.swift in Sources */,
48774881
F707C26521A2DC5200F6181E /* NCStoreReview.swift in Sources */,

iOSClient/Extensions/UINavigationController+Extension.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ extension UINavigationController {
3838
appearance.configureWithDefaultBackground()
3939
} else {
4040
appearance.configureWithTransparentBackground()
41-
appearance.backgroundColor = backgroundColor
42-
41+
if topViewController is NCMedia {
42+
// transparent
43+
} else {
44+
appearance.backgroundColor = backgroundColor
45+
}
4346
appearance.shadowColor = .clear
4447
appearance.shadowImage = UIImage()
4548
}

iOSClient/Extensions/UIView+Extension.swift

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,6 @@ extension UIView {
4646
hiddenView.addSubview(view)
4747
}
4848

49-
func addBlur(style: UIBlurEffect.Style) {
50-
let blur = UIBlurEffect(style: style)
51-
let blurredEffectView = UIVisualEffectView(effect: blur)
52-
blurredEffectView.frame = self.bounds
53-
blurredEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
54-
blurredEffectView.isUserInteractionEnabled = false
55-
self.addSubview(blurredEffectView)
56-
}
57-
5849
func insertBlur(style: UIBlurEffect.Style) {
5950
let blur = UIBlurEffect(style: style)
6051
let blurredEffectView = UIVisualEffectView(effect: blur)
@@ -80,4 +71,31 @@ extension UIView {
8071
}
8172
return nil
8273
}
74+
75+
func addBlur(style: UIBlurEffect.Style, alpha: CGFloat = 1.0) {
76+
let blurEffect = UIBlurEffect(style: style)
77+
let blurView = UIVisualEffectView(effect: blurEffect)
78+
blurView.frame = bounds
79+
blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
80+
blurView.alpha = alpha
81+
blurView.layer.masksToBounds = true
82+
insertSubview(blurView, at: 0)
83+
}
84+
85+
func addBlurBackground(style: UIBlurEffect.Style, alpha: CGFloat = 1) {
86+
let blur = UIBlurEffect(style: style)
87+
let blurView = UIVisualEffectView(effect: blur)
88+
blurView.isUserInteractionEnabled = false
89+
blurView.alpha = alpha
90+
blurView.layer.masksToBounds = true
91+
blurView.translatesAutoresizingMaskIntoConstraints = false
92+
insertSubview(blurView, at: 0)
93+
94+
NSLayoutConstraint.activate([
95+
blurView.topAnchor.constraint(equalTo: topAnchor),
96+
blurView.leadingAnchor.constraint(equalTo: leadingAnchor),
97+
blurView.trailingAnchor.constraint(equalTo: trailingAnchor),
98+
blurView.bottomAnchor.constraint(equalTo: bottomAnchor)
99+
])
100+
}
83101
}

iOSClient/Main/Main.storyboard

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23727" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="FkP-Lh-8zt">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="24123.1" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="FkP-Lh-8zt">
33
<device id="retina6_1" orientation="portrait" appearance="light"/>
44
<dependencies>
5-
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23721"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24062"/>
76
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
87
</dependencies>
98
<scenes>
@@ -39,7 +38,7 @@
3938
<tabBarItem key="tabBarItem" title="File" id="Zxv-aS-HGF"/>
4039
<toolbarItems/>
4140
<navigationBar key="navigationBar" contentMode="scaleToFill" largeTitles="YES" id="cj6-rT-wnB">
42-
<rect key="frame" x="0.0" y="96" width="414" height="96"/>
41+
<rect key="frame" x="0.0" y="96" width="414" height="106"/>
4342
<autoresizingMask key="autoresizingMask"/>
4443
</navigationBar>
4544
<nil name="viewControllers"/>
@@ -68,7 +67,7 @@
6867
<tabBarItem key="tabBarItem" title="Favorites" id="o09-67-hwf"/>
6968
<toolbarItems/>
7069
<navigationBar key="navigationBar" contentMode="scaleToFill" largeTitles="YES" id="MJw-Bn-5le">
71-
<rect key="frame" x="0.0" y="96" width="414" height="96"/>
70+
<rect key="frame" x="0.0" y="96" width="414" height="106"/>
7271
<autoresizingMask key="autoresizingMask"/>
7372
</navigationBar>
7473
<nil name="viewControllers"/>
@@ -93,11 +92,11 @@
9392
<!--Media-->
9493
<scene sceneID="IuY-Iu-oAm">
9594
<objects>
96-
<navigationController extendedLayoutIncludesOpaqueBars="YES" automaticallyAdjustsScrollViewInsets="NO" id="Npr-vu-PSD" sceneMemberID="viewController">
95+
<navigationController extendedLayoutIncludesOpaqueBars="YES" automaticallyAdjustsScrollViewInsets="NO" id="Npr-vu-PSD" customClass="NCMediaNavigationController" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
9796
<tabBarItem key="tabBarItem" title="Media" id="5cw-bP-7It"/>
9897
<toolbarItems/>
9998
<navigationBar key="navigationBar" contentMode="scaleToFill" largeTitles="YES" id="ixg-Pw-TNO">
100-
<rect key="frame" x="0.0" y="96" width="414" height="96"/>
99+
<rect key="frame" x="0.0" y="96" width="414" height="106"/>
101100
<autoresizingMask key="autoresizingMask"/>
102101
</navigationBar>
103102
<nil name="viewControllers"/>
@@ -125,7 +124,7 @@
125124
<navigationController extendedLayoutIncludesOpaqueBars="YES" automaticallyAdjustsScrollViewInsets="NO" id="cJk-3t-NeM" customClass="NCActivityNavigationController" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
126125
<tabBarItem key="tabBarItem" title="Activity" id="tc3-kx-Dca" userLabel="Activity"/>
127126
<navigationBar key="navigationBar" contentMode="scaleToFill" largeTitles="YES" id="Qkh-XJ-mse">
128-
<rect key="frame" x="0.0" y="96" width="414" height="96"/>
127+
<rect key="frame" x="0.0" y="96" width="414" height="106"/>
129128
<autoresizingMask key="autoresizingMask"/>
130129
</navigationBar>
131130
<connections>
@@ -153,7 +152,7 @@
153152
<tabBarItem key="tabBarItem" title="More" id="U4f-qS-cgh"/>
154153
<toolbarItems/>
155154
<navigationBar key="navigationBar" contentMode="scaleToFill" largeTitles="YES" id="yVo-p8-ApS">
156-
<rect key="frame" x="0.0" y="96" width="414" height="96"/>
155+
<rect key="frame" x="0.0" y="96" width="414" height="106"/>
157156
<autoresizingMask key="autoresizingMask"/>
158157
</navigationBar>
159158
<nil name="viewControllers"/>

iOSClient/Main/NCMainNavigationController.swift

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ class NCMainNavigationController: UINavigationController, UINavigationController
2525
topViewController as? NCTrash
2626
}
2727

28+
var mediaViewController: NCMedia? {
29+
topViewController as? NCMedia
30+
}
31+
2832
@MainActor
2933
var session: NCSession.Session {
3034
NCSession.shared.getSession(controller: controller)
@@ -210,6 +214,7 @@ class NCMainNavigationController: UINavigationController, UINavigationController
210214
func updateRightBarButtonItems(_ fileItem: UITabBarItem? = nil) async -> Int {
211215
guard !(collectionViewCommon?.isEditMode ?? false),
212216
!(trashViewController?.isEditMode ?? false),
217+
!(mediaViewController?.isEditMode ?? false),
213218
!(topViewController is NCViewerMediaPage),
214219
!(topViewController is NCViewerPDF),
215220
!(topViewController is NCViewerRichDocument),
@@ -524,7 +529,118 @@ class NCMainNavigationController: UINavigationController, UINavigationController
524529
return false
525530
}
526531

532+
/// Changes the tint color of a specific right bar button item identified by tag.
533+
/// - Parameters:
534+
/// - tag: The tag used to identify the UIBarButtonItem.
535+
/// - color: The UIColor to be applied.
536+
@MainActor
537+
func setRightItemColor(tag: Int, to color: UIColor) {
538+
guard
539+
let items = topViewController?.navigationItem.rightBarButtonItems,
540+
let item = items.first(where: { $0.tag == tag }),
541+
let button = item.customView as? UIButton
542+
else { return }
543+
544+
applyTint(button, color: color)
545+
}
546+
547+
/// Changes the tint color of all right bar button items currently visible
548+
/// in the topViewController's navigation item.
549+
/// - Parameter color: The UIColor to be applied.
550+
@MainActor
551+
func setAllRightItemsColor(_ color: UIColor) {
552+
guard let items = topViewController?.navigationItem.rightBarButtonItems else { return }
553+
554+
for item in items {
555+
if let button = item.customView as? UIButton {
556+
applyTint(button, color: color)
557+
}
558+
}
559+
}
560+
527561
// MARK: - Left
528562

529563
func setNavigationLeftItems() async { }
564+
565+
/// Changes the tint color of a specific left bar button item identified by tag.
566+
/// - Parameters:
567+
/// - tag: The tag used to identify the UIBarButtonItem.
568+
/// - color: The UIColor to be applied.
569+
@MainActor
570+
func setLeftItemColor(tag: Int, to color: UIColor) {
571+
guard
572+
let items = topViewController?.navigationItem.leftBarButtonItems,
573+
let item = items.first(where: { $0.tag == tag }),
574+
let button = item.customView as? UIButton
575+
else { return }
576+
577+
applyTint(button, color: color)
578+
}
579+
580+
/// Changes the tint color of all left bar button items currently visible
581+
/// in the topViewController's navigation item.
582+
/// - Parameter color: The UIColor to be applied.
583+
@MainActor
584+
func setAllLeftItemsColor(_ color: UIColor) {
585+
guard let items = topViewController?.navigationItem.leftBarButtonItems else { return }
586+
587+
for item in items {
588+
if let button = item.customView as? UIButton {
589+
applyTint(button, color: color)
590+
}
591+
}
592+
}
593+
594+
// MARK: - Tint helpers
595+
596+
/// Applies a tint color to a given UIButton, handling both UIButton.Configuration
597+
/// and legacy setup with SF Symbols or titles.
598+
/// - Parameters:
599+
/// - button: The UIButton to apply the color.
600+
/// - color: The UIColor to be applied.
601+
@MainActor
602+
private func applyTint(_ button: UIButton, color: UIColor) {
603+
if var cfg = button.configuration {
604+
// Se in futuro userai UIButton.Configuration, tieni il colore allineato qui
605+
cfg.baseForegroundColor = color
606+
button.configuration = cfg
607+
} else {
608+
// Config attuale (nessuna configuration): SF Symbols sono template, quindi basta tintColor
609+
button.tintColor = color
610+
button.setTitleColor(color, for: .normal)
611+
}
612+
}
613+
614+
/// Updates the tint color of all preloaded and currently visible right bar buttons.
615+
/// - Parameter color: The UIColor to be applied to all right bar button items.
616+
@MainActor
617+
func updateRightBarButtonsTint(to color: UIColor) {
618+
let rightButtons: [UIButton] = [
619+
menuButton,
620+
assistantButton,
621+
notificationsButton,
622+
transfersButton
623+
]
624+
625+
// Apply color to preloaded button instances
626+
for button in rightButtons {
627+
if var cfg = button.configuration {
628+
cfg.baseForegroundColor = color
629+
button.configuration = cfg
630+
} else {
631+
button.tintColor = color
632+
button.setTitleColor(color, for: .normal)
633+
}
634+
}
635+
636+
// Update also those already visible in the navigation bar
637+
if let rightItems = topViewController?.navigationItem.rightBarButtonItems {
638+
for item in rightItems {
639+
if let button = item.customView as? UIButton {
640+
button.tintColor = color
641+
button.setTitleColor(color, for: .normal)
642+
}
643+
}
644+
}
645+
}
530646
}

iOSClient/Media/NCMedia+CollectionViewDataSource.swift

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,10 @@ extension NCMedia: UICollectionViewDataSource {
3030

3131
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
3232
let numberOfItemsInSection = dataSource.metadatas.count
33-
let capabilities = NCNetworking.shared.capabilities[session.account] ?? NKCapabilities.Capabilities()
34-
let assistantEnabled = capabilities.assistantEnabled
35-
if assistantEnabled {
36-
assistantButton.isHidden = false
37-
} else {
38-
assistantButton.isHidden = true
39-
}
40-
4133
self.numberOfColumns = getColumnCount()
4234

43-
if numberOfItemsInSection == 0 || networking.isOffline {
44-
selectOrCancelButton.isHidden = true
45-
menuButton.isHidden = false
46-
gradientView.alpha = 0
47-
} else if isEditMode {
48-
selectOrCancelButton.isHidden = false
49-
} else {
50-
selectOrCancelButton.isHidden = false
51-
menuButton.isHidden = false
52-
}
53-
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
54-
self.setTitleDate()
55-
}
35+
setElements()
36+
5637
return numberOfItemsInSection
5738
}
5839

0 commit comments

Comments
 (0)