code makeup and folder selection
authorXavier Algarra <xavier@pep-project.org>
Thu, 20 Apr 2017 16:27:03 +0200
changeset 204048f5e39c45a7
parent 2039 7880f7f0adfc
child 2041 eaac91f98aab
code makeup and folder selection
pEpForiOS.xcodeproj/project.pbxproj
pEpForiOS/UI/Folder/CellsAndSections/AccountSection.swift
pEpForiOS/UI/Folder/FolderTableViewController.swift
pEpForiOS/UI/Folder/ViewModel/FolderCellViewModel.swift
pEpForiOS/UI/Folder/ViewModel/FolderSectionViewModel.swift
     1.1 --- a/pEpForiOS.xcodeproj/project.pbxproj	Thu Apr 20 15:53:09 2017 +0200
     1.2 +++ b/pEpForiOS.xcodeproj/project.pbxproj	Thu Apr 20 16:27:03 2017 +0200
     1.3 @@ -203,7 +203,6 @@
     1.4  		B722EC651E5B49BA00A2B9D5 /* FolderSectionViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B722EC641E5B49BA00A2B9D5 /* FolderSectionViewModel.swift */; };
     1.5  		B722EC7A1E5C879000A2B9D5 /* FolderUiProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = B722EC791E5C879000A2B9D5 /* FolderUiProtocols.swift */; };
     1.6  		B722EC831E5CA66900A2B9D5 /* FolderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B722EC821E5CA66900A2B9D5 /* FolderTableViewCell.swift */; };
     1.7 -		B726CF781E5DB1F6005C19EF /* AccountSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = B726CF771E5DB1F6005C19EF /* AccountSection.swift */; };
     1.8  		B729BEC61E7C35E200793110 /* FilterUpdateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B729BEC51E7C35E200793110 /* FilterUpdateProtocol.swift */; };
     1.9  		B740B75D1E4B1C2D002585E1 /* jsonMimeType.txt in Resources */ = {isa = PBXBuildFile; fileRef = B740B75C1E4B1C2D002585E1 /* jsonMimeType.txt */; };
    1.10  		B740B75F1E4B1C46002585E1 /* MimeTypeUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = B740B75E1E4B1C46002585E1 /* MimeTypeUtil.swift */; };
    1.11 @@ -450,7 +449,6 @@
    1.12  		B722EC641E5B49BA00A2B9D5 /* FolderSectionViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FolderSectionViewModel.swift; path = Folder/ViewModel/FolderSectionViewModel.swift; sourceTree = "<group>"; };
    1.13  		B722EC791E5C879000A2B9D5 /* FolderUiProtocols.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FolderUiProtocols.swift; sourceTree = "<group>"; };
    1.14  		B722EC821E5CA66900A2B9D5 /* FolderTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FolderTableViewCell.swift; path = Folder/FolderTableViewCell.swift; sourceTree = "<group>"; };
    1.15 -		B726CF771E5DB1F6005C19EF /* AccountSection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AccountSection.swift; path = Folder/CellsAndSections/AccountSection.swift; sourceTree = "<group>"; };
    1.16  		B729BEC51E7C35E200793110 /* FilterUpdateProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FilterUpdateProtocol.swift; path = Filter/ViewModel/FilterUpdateProtocol.swift; sourceTree = "<group>"; };
    1.17  		B740B75C1E4B1C2D002585E1 /* jsonMimeType.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = jsonMimeType.txt; sourceTree = "<group>"; };
    1.18  		B740B75E1E4B1C46002585E1 /* MimeTypeUtil.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MimeTypeUtil.swift; sourceTree = "<group>"; };
    1.19 @@ -986,7 +984,6 @@
    1.20  		B722EC7B1E5CA59100A2B9D5 /* CellsAndSections */ = {
    1.21  			isa = PBXGroup;
    1.22  			children = (
    1.23 -				B726CF771E5DB1F6005C19EF /* AccountSection.swift */,
    1.24  				B722EC821E5CA66900A2B9D5 /* FolderTableViewCell.swift */,
    1.25  				B7D1EEC71E8BEC8D00F190E3 /* sectionTest.swift */,
    1.26  				B7D1EEC91E8BED2500F190E3 /* extensions.swift */,
    1.27 @@ -1260,7 +1257,6 @@
    1.28  				431394C11E4B11CF00D92F33 /* AppSettings.swift in Sources */,
    1.29  				4381D0FF1E51A124002743C3 /* NetworkServiceWorker.swift in Sources */,
    1.30  				437671481D8FF2A5004DD205 /* DeleteFolderOperation.swift in Sources */,
    1.31 -				B726CF781E5DB1F6005C19EF /* AccountSection.swift in Sources */,
    1.32  				43A26FBA1E0408FB00AF0B84 /* ErrorProtocol.swift in Sources */,
    1.33  				4339477B1D5C9D8C005EE7C2 /* HTMLConvertOperation.swift in Sources */,
    1.34  				43AA825B1E9BC5FF00ABD5A8 /* AttachmentViewContainer.swift in Sources */,
     2.1 --- a/pEpForiOS/UI/Folder/CellsAndSections/AccountSection.swift	Thu Apr 20 15:53:09 2017 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,49 +0,0 @@
     2.4 -//
     2.5 -//  AccountSection.swift
     2.6 -//  pEpForiOS
     2.7 -//
     2.8 -//  Created by Xavier Algarra on 21/02/17.
     2.9 -//  Copyright © 2017 p≡p Security S.A. All rights reserved.
    2.10 -//
    2.11 -
    2.12 -import UIKit
    2.13 -
    2.14 -public class AccountSection: UITableViewCell {
    2.15 -    @IBOutlet weak var profileImage: UIImageView!
    2.16 -    @IBOutlet weak var accountType: UILabel!
    2.17 -    @IBOutlet weak var accountName: UILabel!
    2.18 -    @IBOutlet weak var userAddress: UILabel!
    2.19 -    @IBOutlet weak var disclosureIndeicator: UILabel!
    2.20 -    @IBOutlet weak var actionView: UIView!
    2.21 -
    2.22 -    //var vm : FolderSectionViewModel?
    2.23 -    var section : Int?
    2.24 -    var delegate : TableCollapsableDelegate?
    2.25 -
    2.26 -    func configure(section: FolderSectionViewModel, table: TableCollapsableDelegate, sectionNum: Int) {
    2.27 -        self.delegate = table
    2.28 -        //vm = section
    2.29 -        self.section = sectionNum
    2.30 -        //profileImage.image = section.image
    2.31 -        //self.addGestureRecognizer(UITapGestureRecognizer( target: self, action: #selector( self.tapHeader(_:))))
    2.32 -        accountType.text = section.type
    2.33 -        accountName.text = section.userName
    2.34 -        userAddress.text = section.userAddress
    2.35 -    }
    2.36 -
    2.37 -    public func tapHeader(gestureRecognizer: UITapGestureRecognizer) {
    2.38 -        /*guard let cell = gestureRecognizer.view as? AccountSection else {
    2.39 -            return
    2.40 -        }*/
    2.41 -        delegate?.toggleSection(section: section!)
    2.42 -    }
    2.43 -
    2.44 -    public override func awakeFromNib() {
    2.45 -        super.awakeFromNib()
    2.46 -    }
    2.47 -
    2.48 -}
    2.49 -
    2.50 -public protocol TableCollapsableDelegate {
    2.51 -    func toggleSection(section: Int)
    2.52 -}
     3.1 --- a/pEpForiOS/UI/Folder/FolderTableViewController.swift	Thu Apr 20 15:53:09 2017 +0200
     3.2 +++ b/pEpForiOS/UI/Folder/FolderTableViewController.swift	Thu Apr 20 16:27:03 2017 +0200
     3.3 @@ -7,15 +7,12 @@
     3.4  //
     3.5  
     3.6  import UIKit
     3.7 -import MessageModel
     3.8  
     3.9  class FolderTableViewController: UITableViewController {
    3.10      var appConfig: AppConfig?
    3.11  
    3.12      var folderVM = FolderViewModel()
    3.13  
    3.14 -    var folderToShow :Folder?
    3.15 -
    3.16      override func viewDidLoad() {
    3.17          super.viewDidLoad()
    3.18          //initialConfig()
    3.19 @@ -61,15 +58,6 @@
    3.20          return 0.0
    3.21      }
    3.22  
    3.23 -    /*verride func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
    3.24 -     return 80.0
    3.25 -     }*/
    3.26 -
    3.27 -    /*override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
    3.28 -     return folderVM[section].title
    3.29 -     //reimplement to a custom view and copy the view of mail app
    3.30 -     }*/
    3.31 -
    3.32      override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    3.33          let cell = tableView.dequeueReusableCell(withIdentifier: "Default", for: indexPath)
    3.34          let fcvm = folderVM[indexPath.section][indexPath.item]
    3.35 @@ -84,16 +72,13 @@
    3.36          return folderVM[indexPath.section][indexPath.item].level
    3.37      }
    3.38  
    3.39 -    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    3.40 -        folderToShow = folderVM[indexPath.section][indexPath.item].folder
    3.41 -        performSegue(withIdentifier: "ShowFolder", sender: nil)
    3.42 -    }
    3.43 +    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath){
    3.44  
    3.45 -    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    3.46 -        if let controller = segue.destination as? EmailListViewController
    3.47 -            , let folder = folderToShow {
    3.48 -            let config = EmailListConfig(appConfig: appConfig, folder: folder)
    3.49 -            controller.config = config
    3.50 +        let sb = UIStoryboard(name: "Main", bundle: nil)
    3.51 +        if let vc = sb.instantiateViewController(withIdentifier: "EmailListViewController") as? EmailListViewController {
    3.52 +            let config = EmailListConfig(appConfig: appConfig, folder: folderVM[indexPath.section][indexPath.row].getFolder())
    3.53 +            vc.config = config
    3.54 +            self.navigationController?.pushViewController(vc, animated: false)
    3.55          }
    3.56      }
    3.57  
     4.1 --- a/pEpForiOS/UI/Folder/ViewModel/FolderCellViewModel.swift	Thu Apr 20 15:53:09 2017 +0200
     4.2 +++ b/pEpForiOS/UI/Folder/ViewModel/FolderCellViewModel.swift	Thu Apr 20 16:27:03 2017 +0200
     4.3 @@ -24,7 +24,7 @@
     4.4          return UIImage(named: "arrow_down_icon")!
     4.5      }
     4.6  
     4.7 -    var folder:Folder
     4.8 +    var folder: Folder
     4.9      var level : Int
    4.10  
    4.11      public init(folder: Folder, level: Int) {
    4.12 @@ -32,34 +32,15 @@
    4.13          self.level = level
    4.14      }
    4.15  
    4.16 +
    4.17 +    func getFolder() -> Folder {
    4.18 +        return folder
    4.19 +    }
    4.20 +
    4.21      private var name:String {
    4.22 -        /*var n = ""
    4.23 -        if let parent = self.folder.parent {
    4.24 -            n = self.folder.name.replacingOccurrences(of: parent.name, with: "")
    4.25 -        }
    4.26 -        var ret = ""
    4.27 -        for _ in 0...level {
    4.28 -            ret = ret + "   "
    4.29 -        }
    4.30 -        if n != "" {
    4.31 -            ret += n
    4.32 -        } else {
    4.33 -            ret += self.folder.name
    4.34 -        }
    4.35 -        return ret*/
    4.36          return self.folder.realName
    4.37      }
    4.38  
    4.39 -    /*var name:String {
    4.40 -        if let parent = self.folder.parent {
    4.41 -            if let range = self.folder.name.range(of: parent.name) {
    4.42 -                return self.folder.name.substring(from: range.upperBound)
    4.43 -                //return self.folder.name.replacingOccurrences(of: self.folder.parent?.name, with: "")
    4.44 -            }
    4.45 -        }
    4.46 -        retur                   n self.folder.name
    4.47 -    }*/
    4.48 -
    4.49      var leftPadding: Int {
    4.50          return level
    4.51      }
     5.1 --- a/pEpForiOS/UI/Folder/ViewModel/FolderSectionViewModel.swift	Thu Apr 20 15:53:09 2017 +0200
     5.2 +++ b/pEpForiOS/UI/Folder/ViewModel/FolderSectionViewModel.swift	Thu Apr 20 16:27:03 2017 +0200
     5.3 @@ -12,8 +12,6 @@
     5.4  public class FolderSectionViewModel {
     5.5  
     5.6      public var collapsed: Bool
     5.7 -
     5.8 -    //image, type, user, name
     5.9      private var account: Account
    5.10      private var items: [FolderCellViewModel]
    5.11      private var help :[FolderCellViewModel]
    5.12 @@ -40,17 +38,6 @@
    5.13              childFolder(root: subFolder, level: level + 1)
    5.14          }
    5.15      }
    5.16 -/*
    5.17 -     contactImageView.image = UIImage.init(named: "empty-avatar")
    5.18 -     identityForImage = message.from
    5.19 -     if let ident = identityForImage, let imgProvider = config?.imageProvider {
    5.20 -        imgProvider.image(forIdentity: ident) { img in
    5.21 -            if message.from == self.identityForImage {
    5.22 -                self.contactImageView.image = img
    5.23 -            }
    5.24 -        }
    5.25 -     }
    5.26 - */
    5.27  
    5.28      func getImage(callback: @escaping ImageReadyFunc) {
    5.29          imageProvider.image(forIdentity: account.user, callback: callback)
    5.30 @@ -87,7 +74,6 @@
    5.31              help = items
    5.32              items = [FolderCellViewModel]()
    5.33          }
    5.34 -
    5.35      }
    5.36  
    5.37      subscript(index: Int) -> FolderCellViewModel {
    5.38 @@ -95,6 +81,7 @@
    5.39              return self.items[index]
    5.40          }
    5.41      }
    5.42 +
    5.43      var count : Int {
    5.44          return self.items.count
    5.45      }