marinofaggiana 3 years ago
parent
commit
44ad344b00

+ 0 - 8
Nextcloud.xcodeproj/project.pbxproj

@@ -89,7 +89,6 @@
 		F7176DDB256672F10017E83C /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = F7176DDA256672D90017E83C /* libsqlite3.tbd */; };
 		F718C24E254D507B00C5C256 /* NCViewerImageDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F718C24D254D507B00C5C256 /* NCViewerImageDetailView.swift */; };
 		F7226EDC1EE4089300EBECB1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7226EDB1EE4089300EBECB1 /* Main.storyboard */; };
-		F722814323C8C34500C41898 /* NCRichWorkspace.xib in Resources */ = {isa = PBXBuildFile; fileRef = F722814223C8C34500C41898 /* NCRichWorkspace.xib */; };
 		F723985C253C95CE00257F49 /* NCViewerRichdocument.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F723985B253C95CE00257F49 /* NCViewerRichdocument.storyboard */; };
 		F7239871253D86B600257F49 /* NCEmptyDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7239870253D86B600257F49 /* NCEmptyDataSet.swift */; };
 		F7239877253D86D300257F49 /* NCEmptyView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7239876253D86D300257F49 /* NCEmptyView.xib */; };
@@ -330,7 +329,6 @@
 		F7EFC0C6256BC77700461AAD /* NCMoreUserCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7EFC0C5256BC77700461AAD /* NCMoreUserCell.xib */; };
 		F7EFC0CD256BF8DD00461AAD /* NCUserStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7EFC0CC256BF8DD00461AAD /* NCUserStatus.swift */; };
 		F7F1E54C2492369A00E42386 /* NCMediaCommandView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7F1E54B2492369A00E42386 /* NCMediaCommandView.xib */; };
-		F7F4B1D823C74B3E00D82A6E /* NCRichWorkspace.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7F4B1D723C74B3E00D82A6E /* NCRichWorkspace.swift */; };
 		F7F878AE1FB9E3B900599E4F /* NCEndToEndMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7F878AD1FB9E3B900599E4F /* NCEndToEndMetadata.swift */; };
 		F7F878AF1FB9E3B900599E4F /* NCEndToEndMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7F878AD1FB9E3B900599E4F /* NCEndToEndMetadata.swift */; };
 		F7F9D1BB25397CE000D9BFF5 /* NCViewer.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7F9D1BA25397CE000D9BFF5 /* NCViewer.swift */; };
@@ -465,7 +463,6 @@
 		F7176DDA256672D90017E83C /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; };
 		F718C24D254D507B00C5C256 /* NCViewerImageDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerImageDetailView.swift; sourceTree = "<group>"; };
 		F7226EDB1EE4089300EBECB1 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
-		F722814223C8C34500C41898 /* NCRichWorkspace.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NCRichWorkspace.xib; sourceTree = "<group>"; };
 		F723985B253C95CE00257F49 /* NCViewerRichdocument.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NCViewerRichdocument.storyboard; sourceTree = "<group>"; };
 		F7239870253D86B600257F49 /* NCEmptyDataSet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCEmptyDataSet.swift; sourceTree = "<group>"; };
 		F7239876253D86D300257F49 /* NCEmptyView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NCEmptyView.xib; sourceTree = "<group>"; };
@@ -711,7 +708,6 @@
 		F7EFC0CC256BF8DD00461AAD /* NCUserStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCUserStatus.swift; sourceTree = "<group>"; };
 		F7F1E54B2492369A00E42386 /* NCMediaCommandView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NCMediaCommandView.xib; sourceTree = "<group>"; };
 		F7F35B592578FB63003F5589 /* CollaboraOnlineWebViewKeyboardManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CollaboraOnlineWebViewKeyboardManager.framework; path = Carthage/Build/iOS/CollaboraOnlineWebViewKeyboardManager.framework; sourceTree = "<group>"; };
-		F7F4B1D723C74B3E00D82A6E /* NCRichWorkspace.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCRichWorkspace.swift; sourceTree = "<group>"; };
 		F7F67BB81A24D27800EE80DA /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
 		F7F878AD1FB9E3B900599E4F /* NCEndToEndMetadata.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCEndToEndMetadata.swift; sourceTree = "<group>"; };
 		F7F9D1BA25397CE000D9BFF5 /* NCViewer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewer.swift; sourceTree = "<group>"; };
@@ -1348,8 +1344,6 @@
 		F7CADB3D23CCDDA1000EEC78 /* RichWorkspace */ = {
 			isa = PBXGroup;
 			children = (
-				F7F4B1D723C74B3E00D82A6E /* NCRichWorkspace.swift */,
-				F722814223C8C34500C41898 /* NCRichWorkspace.xib */,
 				F75C0C4723D1FAE300163CC8 /* NCRichWorkspaceCommon.swift */,
 				F7D1611F23CF19E30039EBBF /* NCViewerRichWorkspace.storyboard */,
 				F78A18B723CDE2B300F681F3 /* NCViewerRichWorkspace.swift */,
@@ -1897,7 +1891,6 @@
 				F77B0F631D118A16002130FE /* Localizable.strings in Resources */,
 				F7632FC1218353AA00721B71 /* NCTrashSectionFooter.xib in Resources */,
 				F774264A22EB4D0000B23912 /* NCShareUserDropDownCell.xib in Resources */,
-				F722814323C8C34500C41898 /* NCRichWorkspace.xib in Resources */,
 				F7CB689A2541676B0050EC94 /* NCMore.storyboard in Resources */,
 				F77B0F7D1D118A16002130FE /* Images.xcassets in Resources */,
 				F73CB3B222E072A000AD728E /* NCShareHeaderView.xib in Resources */,
@@ -2130,7 +2123,6 @@
 				F70D7C3725FFBF82002B9E34 /* NCCollectionViewCommon.swift in Sources */,
 				F7020FCE2233D7F700B7297D /* NCCreateFormUploadVoiceNote.swift in Sources */,
 				F7134186259747BA00768D21 /* NCPushNotification.m in Sources */,
-				F7F4B1D823C74B3E00D82A6E /* NCRichWorkspace.swift in Sources */,
 				F726EEEC1FED1C820030B9C8 /* NCEndToEndInitialize.swift in Sources */,
 				F79A65C62191D95E00FF6DCC /* NCSelect.swift in Sources */,
 				F7FAC2672549E1B5008EE2C4 /* NCKTVHTTPCache.swift in Sources */,

+ 10 - 9
iOSClient/Main/Section Header Footer/NCSectionHeaderFooter.swift

@@ -66,6 +66,13 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
         separator.backgroundColor = NCBrandColor.shared.separator
         separatorHeightConstraint.constant = 0.5
 
+        markdownParser = MarkdownParser(font: UIFont.systemFont(ofSize: 15), color: NCBrandColor.shared.label)
+        markdownParser.header.font = UIFont.systemFont(ofSize: 25)
+        if let richWorkspaceText = richWorkspaceText {
+            textViewRichWorkspace.attributedText = markdownParser.parse(richWorkspaceText)
+        }
+        textViewColor = NCBrandColor.shared.label
+        
         changeColor()
     }
     
@@ -80,17 +87,11 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
         changeColor()
     }
     
-    @objc func changeColor() {
-        
-        markdownParser = MarkdownParser(font: UIFont.systemFont(ofSize: 15), color: NCBrandColor.shared.label)
-        markdownParser.header.font = UIFont.systemFont(ofSize: 25)
-        if let richWorkspaceText = richWorkspaceText {
-            textViewRichWorkspace.attributedText = markdownParser.parse(richWorkspaceText)
-        }
-        textViewColor = NCBrandColor.shared.label
-        gradient.colors = [UIColor.init(white: 1, alpha: 0).cgColor, UIColor.white.cgColor]
+    func changeColor() {
         if traitCollection.userInterfaceStyle == .dark {
             gradient.colors = [UIColor.init(white: 0, alpha: 0).cgColor, UIColor.black.cgColor]
+        } else {
+            gradient.colors = [UIColor.init(white: 1, alpha: 0).cgColor, UIColor.white.cgColor]
         }
     }
     

+ 0 - 80
iOSClient/RichWorkspace/NCRichWorkspace.swift

@@ -1,80 +0,0 @@
-//
-//  NCViewRichWorkspace.swift
-//  Nextcloud
-//
-//  Created by Marino Faggiana on 09/01/2020.
-//  Copyright © 2020 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  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 MarkdownKit
-
-@objc class NCViewRichWorkspace: UIView {
-    
-    @IBOutlet weak var topView: UIView!
-    @IBOutlet weak var richView: UIView!
-    @IBOutlet weak var sortButton: UIButton!
-    @objc @IBOutlet weak var textView: UITextView!
-    
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-
-    private var markdownParser = MarkdownParser()
-    private var richWorkspaceText: String?
-    private var textViewColor: UIColor?
-    private let gradient : CAGradientLayer = CAGradientLayer()
-
-    override func awakeFromNib() {
-        NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
-        
-        changeTheming()
-        
-        // Gradient
-        gradient.startPoint = CGPoint(x: 0, y: 0.60)
-        gradient.endPoint = CGPoint(x: 0, y: 1)
-        richView.layer.addSublayer(gradient)
-    }
-    
-    override func layoutSublayers(of layer: CALayer) {
-        super.layoutSublayers(of: layer)
-        gradient.frame = self.richView.bounds
-    }
-
-    @objc func changeTheming() {
-        if textViewColor != NCBrandColor.shared.label {
-            markdownParser = MarkdownParser(font: UIFont.systemFont(ofSize: 15), color: NCBrandColor.shared.label)
-            markdownParser.header.font = UIFont.systemFont(ofSize: 25)
-            if let richWorkspaceText = richWorkspaceText {
-                textView.attributedText = markdownParser.parse(richWorkspaceText)
-            }
-            textViewColor = NCBrandColor.shared.label
-            
-            if traitCollection.userInterfaceStyle == .dark {
-                gradient.colors = [UIColor.init(white: 0, alpha: 0).cgColor, UIColor.black.cgColor]
-            } else {
-                gradient.colors = [UIColor.init(white: 1, alpha: 0).cgColor, UIColor.white.cgColor]
-            }
-        }
-    }
-    
-    @objc func load(richWorkspaceText: String) {
-        if richWorkspaceText != self.richWorkspaceText {
-            textView.attributedText = markdownParser.parse(richWorkspaceText)
-            self.richWorkspaceText = richWorkspaceText
-        }
-    }
-}

+ 0 - 97
iOSClient/RichWorkspace/NCRichWorkspace.xib

@@ -1,97 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
-    <device id="retina5_5" orientation="portrait" appearance="light"/>
-    <dependencies>
-        <deployment version="4624" identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17505"/>
-        <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>
-        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
-        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
-        <view clipsSubviews="YES" contentMode="scaleToFill" id="iN0-l3-epB" customClass="NCViewRichWorkspace" customModule="Nextcloud" customModuleProvider="target">
-            <rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
-            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-            <subviews>
-                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="HlU-kk-zSG">
-                    <rect key="frame" x="0.0" y="0.0" width="414" height="40.666666666666664"/>
-                    <subviews>
-                        <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="whP-vX-7tm">
-                            <rect key="frame" x="0.0" y="0.0" width="414" height="32"/>
-                            <constraints>
-                                <constraint firstAttribute="height" constant="32" id="zgp-GM-5ua"/>
-                            </constraints>
-                            <fontDescription key="fontDescription" type="system" pointSize="18"/>
-                            <inset key="titleEdgeInsets" minX="24" minY="0.0" maxX="16" maxY="0.0"/>
-                            <state key="normal" title="Order by"/>
-                        </button>
-                        <view alpha="0.59999999999999998" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="iLg-Pa-y0u">
-                            <rect key="frame" x="0.0" y="40" width="414" height="0.6666666666666643"/>
-                            <color key="backgroundColor" systemColor="separatorColor"/>
-                            <constraints>
-                                <constraint firstAttribute="height" constant="0.5" id="3hR-TI-kRk"/>
-                            </constraints>
-                        </view>
-                    </subviews>
-                    <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                    <constraints>
-                        <constraint firstAttribute="bottom" secondItem="iLg-Pa-y0u" secondAttribute="bottom" id="7GT-SF-5YZ"/>
-                        <constraint firstItem="iLg-Pa-y0u" firstAttribute="leading" secondItem="HlU-kk-zSG" secondAttribute="leading" id="CXc-YZ-5Po"/>
-                        <constraint firstItem="whP-vX-7tm" firstAttribute="leading" secondItem="HlU-kk-zSG" secondAttribute="leading" id="CZf-VB-F7L"/>
-                        <constraint firstItem="iLg-Pa-y0u" firstAttribute="top" secondItem="whP-vX-7tm" secondAttribute="bottom" constant="8" id="GaZ-ao-ygn"/>
-                        <constraint firstAttribute="trailing" secondItem="iLg-Pa-y0u" secondAttribute="trailing" id="WMv-Zi-7Yu"/>
-                        <constraint firstAttribute="trailing" secondItem="whP-vX-7tm" secondAttribute="trailing" id="bBp-TM-j1W"/>
-                        <constraint firstItem="whP-vX-7tm" firstAttribute="top" secondItem="HlU-kk-zSG" secondAttribute="top" id="oXj-DQ-Zjb"/>
-                    </constraints>
-                </view>
-                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="orF-i7-sVP">
-                    <rect key="frame" x="0.0" y="40.666666666666686" width="414" height="695.33333333333326"/>
-                    <subviews>
-                        <textView clipsSubviews="YES" multipleTouchEnabled="YES" userInteractionEnabled="NO" contentMode="scaleToFill" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="wri-16-tQY">
-                            <rect key="frame" x="10" y="0.0" width="394" height="695.33333333333337"/>
-                            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                            <color key="textColor" systemColor="labelColor"/>
-                            <fontDescription key="fontDescription" type="system" pointSize="14"/>
-                            <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
-                        </textView>
-                    </subviews>
-                    <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                    <constraints>
-                        <constraint firstItem="wri-16-tQY" firstAttribute="top" secondItem="orF-i7-sVP" secondAttribute="top" id="7js-7b-K16"/>
-                        <constraint firstAttribute="bottom" secondItem="wri-16-tQY" secondAttribute="bottom" id="a18-oE-B43"/>
-                        <constraint firstAttribute="trailing" secondItem="wri-16-tQY" secondAttribute="trailing" constant="10" id="fLE-9r-zk7"/>
-                        <constraint firstItem="wri-16-tQY" firstAttribute="leading" secondItem="orF-i7-sVP" secondAttribute="leading" constant="10" id="sHh-SV-ESA"/>
-                    </constraints>
-                </view>
-            </subviews>
-            <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
-            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-            <constraints>
-                <constraint firstItem="orF-i7-sVP" firstAttribute="bottom" secondItem="vUN-kp-3ea" secondAttribute="bottom" id="5Lm-EL-ubo"/>
-                <constraint firstItem="orF-i7-sVP" firstAttribute="trailing" secondItem="vUN-kp-3ea" secondAttribute="trailing" id="VlR-kH-SMa"/>
-                <constraint firstItem="HlU-kk-zSG" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="goy-iY-b90"/>
-                <constraint firstItem="HlU-kk-zSG" firstAttribute="trailing" secondItem="vUN-kp-3ea" secondAttribute="trailing" id="kDK-rY-LQb"/>
-                <constraint firstItem="orF-i7-sVP" firstAttribute="top" secondItem="HlU-kk-zSG" secondAttribute="bottom" id="sde-2m-MmE"/>
-                <constraint firstItem="orF-i7-sVP" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="xGI-uT-wsD"/>
-                <constraint firstItem="HlU-kk-zSG" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="z3E-6z-6PD"/>
-            </constraints>
-            <connections>
-                <outlet property="richView" destination="orF-i7-sVP" id="sWH-ON-Cum"/>
-                <outlet property="sortButton" destination="whP-vX-7tm" id="4Yt-90-Nnj"/>
-                <outlet property="textView" destination="wri-16-tQY" id="pwA-gm-dfK"/>
-                <outlet property="topView" destination="HlU-kk-zSG" id="KBp-vo-AWI"/>
-            </connections>
-            <point key="canvasLocation" x="136.875" y="88.75"/>
-        </view>
-    </objects>
-    <resources>
-        <systemColor name="labelColor">
-            <color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-        </systemColor>
-        <systemColor name="separatorColor">
-            <color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.28999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
-        </systemColor>
-    </resources>
-</document>

+ 4 - 12
iOSClient/RichWorkspace/NCViewerRichWorkspace.swift

@@ -48,10 +48,11 @@ import MarkdownKit
                 
         let editItem = UIBarButtonItem(image: UIImage(named: "actionSheetModify"), style: UIBarButtonItem.Style.plain, target: self, action: #selector(editItemAction(_:)))
         self.navigationItem.rightBarButtonItem = editItem
-
-        NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
         
-        changeTheming()
+        markdownParser = MarkdownParser(font: UIFont.systemFont(ofSize: 15), color: NCBrandColor.shared.label)
+        markdownParser.header.font = UIFont.systemFont(ofSize: 25)
+        textView.attributedText = markdownParser.parse(richWorkspaceText)
+        textViewColor = NCBrandColor.shared.label
     }
     
     override func viewWillAppear(_ animated: Bool) {
@@ -79,15 +80,6 @@ import MarkdownKit
         self.viewWillAppear(true)
     }
     
-    @objc func changeTheming() {
-        if textViewColor != NCBrandColor.shared.label {
-            markdownParser = MarkdownParser(font: UIFont.systemFont(ofSize: 15), color: NCBrandColor.shared.label)
-            markdownParser.header.font = UIFont.systemFont(ofSize: 25)
-            textView.attributedText = markdownParser.parse(richWorkspaceText)
-            textViewColor = NCBrandColor.shared.label
-        }
-    }
-    
     @objc func closeItemTapped(_ sender: UIBarButtonItem) {
         self.dismiss(animated: false, completion: nil)
     }