Browse Source

Notification view

Marino Faggiana 8 years ago
parent
commit
d6824908b7

+ 4 - 4
Nextcloud.xcodeproj/project.pbxproj

@@ -545,9 +545,9 @@
 		F7C00D471E2D0D0F0032160B /* CCCellOffline.m in Sources */ = {isa = PBXBuildFile; fileRef = F7C00D431E2D0D0F0032160B /* CCCellOffline.m */; };
 		F7C00D481E2D0D0F0032160B /* CCCellOffline.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7C00D441E2D0D0F0032160B /* CCCellOffline.xib */; };
 		F7C00D491E2D0D0F0032160B /* CCOffline.m in Sources */ = {isa = PBXBuildFile; fileRef = F7C00D461E2D0D0F0032160B /* CCOffline.m */; };
-		F7C5258F1E3B441200FFE02C /* CCNotification.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7C5258E1E3B441200FFE02C /* CCNotification.storyboard */; };
 		F7C5259E1E3B45FA00FFE02C /* CCNotificationPushKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C5259D1E3B45FA00FFE02C /* CCNotificationPushKey.swift */; };
 		F7C525A01E3B48B700FFE02C /* CCNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C5259F1E3B48B700FFE02C /* CCNotification.swift */; };
+		F7C525A21E3B6DA800FFE02C /* CCNotification.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7C525A11E3B6DA800FFE02C /* CCNotification.storyboard */; };
 		F7C994321E3A92C500C2466C /* CCConstant.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C994311E3A92C400C2466C /* CCConstant.swift */; };
 		F7C994331E3A92C500C2466C /* CCConstant.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C994311E3A92C400C2466C /* CCConstant.swift */; };
 		F7C994341E3A92C500C2466C /* CCConstant.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C994311E3A92C400C2466C /* CCConstant.swift */; };
@@ -1461,9 +1461,9 @@
 		F7C1D8BD1D47781C00B89DEA /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/InfoPlist.strings; sourceTree = "<group>"; };
 		F7C1D8BE1D47781D00B89DEA /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Intro.strings; sourceTree = "<group>"; };
 		F7C1D8BF1D47781D00B89DEA /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Error.strings; sourceTree = "<group>"; };
-		F7C5258E1E3B441200FFE02C /* CCNotification.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = CCNotification.storyboard; path = Notification/CCNotification.storyboard; sourceTree = "<group>"; };
 		F7C5259D1E3B45FA00FFE02C /* CCNotificationPushKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CCNotificationPushKey.swift; path = Notification/CCNotificationPushKey.swift; sourceTree = "<group>"; };
 		F7C5259F1E3B48B700FFE02C /* CCNotification.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CCNotification.swift; path = Notification/CCNotification.swift; sourceTree = "<group>"; };
+		F7C525A11E3B6DA800FFE02C /* CCNotification.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = CCNotification.storyboard; path = Notification/CCNotification.storyboard; sourceTree = "<group>"; };
 		F7C8C1721B482A920048180E /* CCMetadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = CCMetadata.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
 		F7C8C1731B482A920048180E /* CCMetadata.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CCMetadata.m; sourceTree = "<group>"; };
 		F7C8C1901B482CEA0048180E /* CCGlobal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGlobal.h; sourceTree = "<group>"; };
@@ -3008,8 +3008,8 @@
 			isa = PBXGroup;
 			children = (
 				F7C5259D1E3B45FA00FFE02C /* CCNotificationPushKey.swift */,
-				F7C5258E1E3B441200FFE02C /* CCNotification.storyboard */,
 				F7C5259F1E3B48B700FFE02C /* CCNotification.swift */,
+				F7C525A11E3B6DA800FFE02C /* CCNotification.storyboard */,
 			);
 			name = Notification;
 			sourceTree = "<group>";
@@ -3655,7 +3655,6 @@
 				F77B0F411D118A16002130FE /* ZSStextcolor@2x.png in Resources */,
 				F77B0F421D118A16002130FE /* ImageSelectedOn.png in Resources */,
 				F77B0F431D118A16002130FE /* Raleway-ExtraBold.ttf in Resources */,
-				F7C5258F1E3B441200FFE02C /* CCNotification.storyboard in Resources */,
 				F77B0F441D118A16002130FE /* Reader-Button-N@2x.png in Resources */,
 				F77B0F461D118A16002130FE /* Reader-Button-H@2x.png in Resources */,
 				F77B0F471D118A16002130FE /* ZSSbgcolor@2x.png in Resources */,
@@ -3689,6 +3688,7 @@
 				F77B0F661D118A16002130FE /* ImageSelectedOff@2x.png in Resources */,
 				F77B0F671D118A16002130FE /* InfoPlist.strings in Resources */,
 				F77B0F691D118A16002130FE /* ImageSelectedSmallOff@2x.png in Resources */,
+				F7C525A21E3B6DA800FFE02C /* CCNotification.storyboard in Resources */,
 				F77B0F6A1D118A16002130FE /* UIBarButtonItemGrid.png in Resources */,
 				F77B0F6B1D118A16002130FE /* ZSSundo.png in Resources */,
 				F77B0F6C1D118A16002130FE /* ZSSsubscript.png in Resources */,

+ 1 - 1
Picker/Base.lproj/MainInterface.storyboard

@@ -98,7 +98,7 @@
                             <constraint firstAttribute="trailing" secondItem="vA7-yc-aM1" secondAttribute="trailing" id="36a-TC-Qul"/>
                             <constraint firstItem="vA7-yc-aM1" firstAttribute="top" secondItem="Vdh-Gp-eV6" secondAttribute="top" id="B3X-Ni-wvz"/>
                             <constraint firstItem="vA7-yc-aM1" firstAttribute="leading" secondItem="Vdh-Gp-eV6" secondAttribute="leading" id="S3f-mR-ElS"/>
-                            <constraint firstItem="vA7-yc-aM1" firstAttribute="bottom" secondItem="UQD-kz-Mfv" secondAttribute="top" constant="-44" id="wSm-cl-ClV"/>
+                            <constraint firstItem="vA7-yc-aM1" firstAttribute="bottom" secondItem="UQD-kz-Mfv" secondAttribute="top" constant="-44" id="osU-tK-fgp"/>
                         </constraints>
                     </view>
                     <connections>

+ 6 - 3
iOSClient/Main/CCMain.m

@@ -1043,11 +1043,14 @@
     if ([JSAlertView isOpenAlertWindows])
         return;
     
-    CCNotification *notificationVC = [[UIStoryboard storyboardWithName:@"CCNotification" bundle:nil] instantiateViewControllerWithIdentifier:@"CCNotification"];
+    if ([app.listOfNotifications count] > 0) {
+    
+        CCNotification *notificationVC = [[UIStoryboard storyboardWithName:@"CCNotification" bundle:nil] instantiateViewControllerWithIdentifier:@"CCNotification"];
 
-    notificationVC.view.superview.frame = CGRectMake(100,100,self.view.bounds.size.width-100,self.view.bounds.size.height-100);
+        notificationVC.view.superview.frame = CGRectMake(100,100,self.view.bounds.size.width-100,self.view.bounds.size.height-100);
 
-    [self presentViewController:notificationVC animated:YES completion:nil];
+        [self presentViewController:notificationVC animated:YES completion:nil];
+    }
     
     /*
     for (NSString *idNotification in app.listOfNotifications) {

+ 4 - 0
iOSClient/Nextcloud-Bridging-Header.h

@@ -4,3 +4,7 @@
 
 #import "AHKActionSheet.h"
 #import "AppDelegate.h"
+
+#import <OCCommunicationLib/OCNotifications.h>
+#import <OCCommunicationLib/OCNotificationsAction.h>
+#import <OCCommunicationLib/OCFrameworkConstants.h>

+ 38 - 13
iOSClient/Notification/CCNotification.storyboard

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="XR4-7S-Rf2">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
@@ -10,33 +10,58 @@
     </dependencies>
     <scenes>
         <!--Notification-->
-        <scene sceneID="qpr-sp-LUL">
+        <scene sceneID="dZP-R1-zZF">
             <objects>
-                <tableViewController restorationIdentifier="CCNotification" storyboardIdentifier="CCNotification" id="XR4-7S-Rf2" customClass="CCNotification" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
-                    <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="zcw-hW-s5f">
+                <tableViewController storyboardIdentifier="CCNotification" id="c26-Us-IIn" customClass="CCNotification" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
+                    <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="90" sectionHeaderHeight="28" sectionFooterHeight="28" id="vzh-aE-2MF">
                         <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                         <prototypes>
-                            <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" id="3oo-s1-wBg">
-                                <rect key="frame" x="0.0" y="28" width="375" height="44"/>
+                            <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" rowHeight="90" id="R1c-h5-BOp" customClass="CCNotificationCell" customModule="Nextcloud" customModuleProvider="target">
+                                <rect key="frame" x="0.0" y="28" width="375" height="90"/>
                                 <autoresizingMask key="autoresizingMask"/>
-                                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="3oo-s1-wBg" id="tdl-RT-gBI">
-                                    <rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
+                                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="R1c-h5-BOp" id="9Bv-1W-yVV">
+                                    <rect key="frame" x="0.0" y="0.0" width="375" height="89.5"/>
                                     <autoresizingMask key="autoresizingMask"/>
+                                    <subviews>
+                                        <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YM1-uH-2Cz" userLabel="icon">
+                                            <rect key="frame" x="8" y="8" width="30" height="30"/>
+                                            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                        </imageView>
+                                        <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="pg1-7p-7Rz" userLabel="subject">
+                                            <rect key="frame" x="46" y="13" width="321" height="21"/>
+                                            <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="9fz-sr-8Gv" userLabel="message">
+                                            <rect key="frame" x="8" y="46" width="359" height="44"/>
+                                            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                            <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                            <nil key="textColor"/>
+                                            <nil key="highlightedColor"/>
+                                        </label>
+                                    </subviews>
                                 </tableViewCellContentView>
+                                <connections>
+                                    <outlet property="icon" destination="YM1-uH-2Cz" id="MPX-ZL-wVR"/>
+                                    <outlet property="message" destination="9fz-sr-8Gv" id="3Zx-pz-gEK"/>
+                                    <outlet property="subject" destination="pg1-7p-7Rz" id="FP7-vS-vEk"/>
+                                </connections>
                             </tableViewCell>
                         </prototypes>
                         <connections>
-                            <outlet property="dataSource" destination="XR4-7S-Rf2" id="Hvz-Xk-ZXo"/>
-                            <outlet property="delegate" destination="XR4-7S-Rf2" id="LRC-DV-UHC"/>
+                            <outlet property="dataSource" destination="c26-Us-IIn" id="6zO-S0-2Cf"/>
+                            <outlet property="delegate" destination="c26-Us-IIn" id="tCb-C6-XGN"/>
                         </connections>
                     </tableView>
                 </tableViewController>
-                <searchDisplayController id="mtt-zO-7ej"/>
-                <placeholder placeholderIdentifier="IBFirstResponder" id="ck0-Wt-nZk" userLabel="First Responder" sceneMemberID="firstResponder"/>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="I7i-N5-tEB" userLabel="First Responder" sceneMemberID="firstResponder"/>
+                <searchDisplayController id="8eI-WG-bvp"/>
             </objects>
-            <point key="canvasLocation" x="-186" y="-349"/>
+            <point key="canvasLocation" x="-303.19999999999999" y="167.76611694152925"/>
         </scene>
     </scenes>
 </document>

+ 83 - 5
iOSClient/Notification/CCNotification.swift

@@ -1,18 +1,34 @@
 //
 //  CCNotification.swift
-//  Nextcloud
+//  Crypto Cloud Technology Nextcloud
 //
 //  Created by Marino Faggiana on 27/01/17.
-//  Copyright © 2017 TWS. All rights reserved.
+//  Copyright (c) 2017 TWS. All rights reserved.
+//
+//  Author Marino Faggiana <m.faggiana@twsweb.it>
+//
+//  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 UIKit
 
 class CCNotification: UITableViewController, UISearchResultsUpdating {
 
-
     var resultSearchController = UISearchController()
     
+    let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    
     override func viewDidLoad() {
         
         super.viewDidLoad()
@@ -27,19 +43,81 @@ class CCNotification: UITableViewController, UISearchResultsUpdating {
             controller.searchBar.scopeButtonTitles = ["A", "B", "C", "D"]
             
             self.tableView.tableHeaderView = controller.searchBar
+            self.tableView.tableFooterView = UIView()
             
             return controller
         })()
         
-        //aggiorniamo la tabella in caso ci fossero modifiche alla lista
         self.tableView.reloadData()
     }
     
+    override func didReceiveMemoryWarning() {
+        super.didReceiveMemoryWarning()
+    }
+
+    override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
+        return true
+    }
+    
+   
+    override func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? {
+        
+        let favorite = UITableViewRowAction(style: .normal, title: "Favorite") { action, index in
+            print("favorite button tapped")
+        }
+        favorite.backgroundColor = .red
+        
+        let share = UITableViewRowAction(style: .normal, title: "Share") { action, index in
+            print("share button tapped")
+        }
+        share.backgroundColor = .green
+        
+        return [share, favorite]
+    }
+    
+    override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
+        return 90
+    }
+    
     override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
         
-        return 0
+        if self.resultSearchController.isActive {
+            return 0
+        } else {
+            let numRecord = appDelegate.listOfNotifications.count
+            return numRecord
+        }
+    }
+    
+    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+    
+        let cell = self.tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! CCNotificationCell
+        
+        if self.resultSearchController.isActive {
+            
+        } else {
+            
+            let idsNotification: [String] = appDelegate.listOfNotifications.allKeys as! [String]
+
+            let idNotification : String! = idsNotification[indexPath.row]
+            let notification = appDelegate.listOfNotifications[idNotification] as! OCNotifications
+            
+            cell.subject.text = notification.subject
+            cell.message.text = notification.message
+        }
+        
+        return cell
     }
     
     func updateSearchResults(for searchController: UISearchController) {
     }
 }
+
+// MARK: - Class UITableViewCell
+
+class CCNotificationCell: UITableViewCell {
+    
+    @IBOutlet weak var icon : UIImageView!
+    @IBOutlet weak var subject: UILabel!
+    @IBOutlet weak var message: UILabel!
+}