forked from ra1028/Former
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expanded the function of deleting cells And Provide usage examples
- Loading branch information
Showing
6 changed files
with
163 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
Former-Demo/Former-Demo/Controllers/DeleteViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// DeleteViewController.swift | ||
// Former-Demo | ||
// | ||
// Created by ZhangShuai on 2021/2/9. | ||
// Copyright © 2021 Ryo Aoyama. All rights reserved. | ||
// This is a simple removable cell, available IOS 11 later | ||
|
||
import UIKit | ||
import Former | ||
|
||
final class DeleteViewController: FormViewController { | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
configure() | ||
} | ||
|
||
private func configure() { | ||
title = "Delete Cell" | ||
tableView.contentInset.top = 10 | ||
tableView.contentInset.bottom = 30 | ||
tableView.contentOffset.y = -10 | ||
|
||
// Create RowFomers | ||
let titleRow = LabelRowFormer<CenterLabelCell>.init().configure(handler: { | ||
$0.text = "General Cell" | ||
}) | ||
|
||
let removableCell = LabelRowFormer<CenterLabelCell>.init().configure(handler: { | ||
$0.text = "removable Cell" | ||
$0.isCanDeleted = true | ||
$0.deletedTitle = "remove cell" | ||
}) | ||
.deletingCompleted { (row, index) in | ||
print("cell has benn removed at \(index) ") | ||
} | ||
|
||
// Create Headers | ||
let createHeader: (() -> ViewFormer) = { | ||
return CustomViewFormer<FormHeaderFooterView>() | ||
.configure { | ||
$0.viewHeight = 20 | ||
} | ||
} | ||
|
||
// Create SectionFormers | ||
let titleSection = SectionFormer(rowFormer: titleRow, removableCell).set(headerViewFormer: createHeader()) | ||
former.append(sectionFormer: titleSection) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.