View
343
Download
1
Category
Preview:
Citation preview
Filiale privée de la SNCF + de 1100 collaborateurs 35 équipes de développement Paris, Lille, Nantes
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
Voyages-Sncf.com
Sites et applications mobiles Logiciel, middleware, moteur d’itinéraire Digital Factory de la SNCF - sncf.com - application SNCF - TGVPro, IDTGV, - …
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
VSC Technologies
Gwenn Guihal, 32 ans - 2008-2013 : Développeur Flash - depuis 2013: Développeur iOS
@_myrddin_
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
14M de téléchargements 30% de l’audience 10 millions de visites/mois
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
V.
6 devs iOS 6 devs android 2 dev back 1 architecte ui/ux 4 product owners
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
V.
~100 écrans ios8 swift (~35%) iPhone, iPad, Apple watch, widget release tous les 2/3 mois version #32 en production depuis 2009
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
V.
2009 ? 😱
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
Grossissement de l’équipe Refonte technique Refonte UI Refontes intégrées dans le delivery TU
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
Sortir du Legacy
AFNetworking CocoaPods Repository privé Fastlane (intégration continue) Swift CollectionView
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
Quelques étapes
CollectionView 😍
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
Layout personnalisé DecorationView Animations iPad Réutilisation des cellules UICollectionViewFlowLayout
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
versus TableView
Micro-architecture 😶
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
UICollectionViewCell (affiche ce que lui done l’adapter)
Adapter (transforme, formate le
model)
Model (contient les données)
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
class VSTransactionCardCollectionViewCell: UICollectionViewCell, VSCollectionCellProtocol {
@IBOutlet weak var label: UILabel! func updateWithAdapter(adapter aAdapter: VSCollectionAdapter) -> Void { guard let adapter = aAdapter as? VSTransactionCardAdapter else { fatalError("VSTransactionCardAdapter required") } label.attributedText = adapter.label } }
Cellule
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
struct VSTransactionCardAdapter: VSCollectionAdapter {
let label:NSAttributedString init(order:Order) { let creditCardNumber = order.creditCardNumber() let sentence = String(format: trans(message_credit_card), creditCardNumber) label = NSAttributedString(string: sentence, attributes: [ NSFontAttributeName: UIFont.systemFontOfSize(14, weightFont:.Bold), NSForegroundColorAttributeName: UIColor.blackColor() ]) } func labelHeight(forWidth: CGFloat) -> CGFloat { let size = label.boundingRectWithSize(CGSize(width: forWidth, height: CGFloat.max), options: […], context: nil) return ceil(size.height) } }
Adapter
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
class VSLabelCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var label: UILabel! override func awakeFromNib() { super.awakeFromNib() // ... } static func computeHeight(forWidth:CGFloat, text:NSAttributedString) -> CGFloat { //... } }
Cellule Legacy
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
class VSLabelCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var label: UILabel! override func awakeFromNib() { super.awakeFromNib() // ... } static func computeHeight(forWidth:CGFloat, text:NSAttributedString) -> CGFloat { //... } }
extension VSLabelCollectionViewCell : VSCollectionCellProtocol { func updateWithAdapter(adapter aAdapter: VSCollectionAdapter) -> Void { guard let adapter = aAdapter as? VSCollectionLabelAdapter else { fatalError("VSCollectionLabelAdapter required") } label.attributedText = adapter.label } }
protocol VSCollectionLabelAdapter { var label:NSAttributedString! {get} }
Extension 😅
cellForItemAtIndexPath…numberOfItemsInSection… shouldSelectItemAtIndexPath… sizeForItemAtIndexPath… insetForSectionAtIndex…
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
Delegate et Datasource
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
Adapter (transforme, formate le
model)
CellDescriptor (représente la cellule pour le
delegate et datasource)
SectionDescriptor (contient un tableau de
cellDescriptors)
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
class VSCardSectionDescriptor: VSCollectionSectionDescriptor { var cells = [VSCollectionCellDescriptor]() var backgroundColor : UIColor? = nil let backgroundPadding = UIEdgeInsetsZero var isExpanded: Bool = false func sectionInset(collectionView:UICollectionView) -> UIEdgeInsets { return UIEdgeInsets(top: 0, left: 15 + ipadInsetX(), bottom: 10, right: 15 + ipadInsetX()) } }
SectionDescriptor
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
struct VSTransactionCardDescriptor: VSCollectionCellDescriptor { let identifier: String = "VSLabelCollectionViewCell" let className: String = "VSLabelCollectionViewCell" var selectable:Bool = false var adapter: VSCollectionAdapter { return _adapter } let _adapter: VSTransactionCardAdapter init(order:Order) { _adapter = VSTransactionCardAdapter(order:order) } func size(collectionView: UICollectionView, sectionDescriptor: VSCollectionSectionDescriptor) -> CGSize { let sectionInset = sectionDescriptor.sectionInset(collectionView) let width:CGFloat = collectionView.bounds.width - sectionInset.left - sectionInset.right return CGSize(width: width, height: max(_adapter.labelHeight(width), 24)) } }
CellDescriptor
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
class VSCollectionDataSource: NSObject, UICollectionViewDataSource { var collectionDatas: VSCollectionDatas? func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { return collectionDatas?.sectionsCount() ?? 0 } func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return collectionDatas?.sections[section].cells.count ?? 0 } func collectionView(UICollectionView, cellForItemAtIndexPath NSIndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCellWithReuseIdentifier(cellDescriptor.identifier, forIndexPath: indexPath) as VSCollectionCellProtocol cell.updateWithAdapter(adapter: cellDescriptor.adapter) return cell }
func collectionView( UICollectionView, layout UICollectionViewLayout, sizeForItemAtIndexPath : NSIndexPath) -> CGSize { if let sectionDescriptor = collectionDatas?.sections[indexPath.section] { let cellDescriptor = sectionDescriptor.cells[indexPath.item] return cellDescriptor.size(collectionView, sectionDescriptor: sectionDescriptor) } return CGSizeZero }
}
UICollectionViewDataSource
Gwenn Guihal - @_myrrdin_ - 19 Octobre 2016
Merci,
🤔
Recommended