Optimised history list displaying
This commit is contained in:
parent
d613203d13
commit
d53e14a965
@ -1080,7 +1080,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 90;
|
CURRENT_PROJECT_VERSION = 91;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||||
@ -1105,7 +1105,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 90;
|
CURRENT_PROJECT_VERSION = 91;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||||
|
|||||||
@ -100,5 +100,21 @@
|
|||||||
landmarkType = "7">
|
landmarkType = "7">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
</BreakpointProxy>
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
uuid = "2B5BCCAE-FCA2-43D1-9835-08DB7E24B91C"
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "AutoCat/Utils/RxRealmDataSource.swift"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "35"
|
||||||
|
endingLineNumber = "35"
|
||||||
|
landmarkName = "init(table:data:cellIdentifier:onSizeChanged:)"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
</Breakpoints>
|
</Breakpoints>
|
||||||
</Bucket>
|
</Bucket>
|
||||||
|
|||||||
@ -38,6 +38,10 @@ class RealmSectionedDataSource<Item,Cell>: NSObject, UITableViewDataSource
|
|||||||
self.insertFirst()
|
self.insertFirst()
|
||||||
} else if deletions.isEmpty && insertions.isEmpty && modifications.count == 1 && modifications.first == 0 {
|
} else if deletions.isEmpty && insertions.isEmpty && modifications.count == 1 && modifications.first == 0 {
|
||||||
self.reloadFirst()
|
self.reloadFirst()
|
||||||
|
} else if modifications.isEmpty && deletions.count == 1 && insertions.count == 1 && insertions.first == 0 {
|
||||||
|
// Probably moving an item to the first position
|
||||||
|
// For example - updating number info
|
||||||
|
self.moveToFirst(deleteIndex: deletions.first!)
|
||||||
} else {
|
} else {
|
||||||
self.reload(animated: false)
|
self.reload(animated: false)
|
||||||
}
|
}
|
||||||
@ -95,16 +99,23 @@ class RealmSectionedDataSource<Item,Cell>: NSObject, UITableViewDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
func insertFirst() {
|
func insertFirst() {
|
||||||
guard !sections.isEmpty, let item = data.first?.clone() else {
|
guard let item = data.first?.clone() else {
|
||||||
|
reload(animated: false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sections[0].insert(item, at: 0)
|
if sections.isEmpty {
|
||||||
tv.insertRows(at: [IndexPath(row: 0, section: 0)], with: .fade)
|
sections = [item].groupedByDate()
|
||||||
|
tv.insertSections(IndexSet(integer: 0), with: .fade)
|
||||||
|
} else {
|
||||||
|
sections[0].insert(item, at: 0)
|
||||||
|
tv.insertRows(at: [IndexPath(row: 0, section: 0)], with: .fade)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func reloadFirst() {
|
func reloadFirst() {
|
||||||
guard !sections.isEmpty, let item = data.first?.clone() else {
|
guard !sections.isEmpty, let item = data.first?.clone() else {
|
||||||
|
reload(animated: false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +123,29 @@ class RealmSectionedDataSource<Item,Cell>: NSObject, UITableViewDataSource
|
|||||||
tv.reloadRows(at: [IndexPath(row: 0, section: 0)], with: .none)
|
tv.reloadRows(at: [IndexPath(row: 0, section: 0)], with: .none)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func moveToFirst(deleteIndex: Int) {
|
||||||
|
var itemIndex = deleteIndex
|
||||||
|
for index in 0..<sections.count {
|
||||||
|
if sections[index].elements.count <= itemIndex {
|
||||||
|
itemIndex -= sections[index].elements.count
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
sections[index].remove(at: itemIndex)
|
||||||
|
sections[0].insert(data[0].clone(), at: 0)
|
||||||
|
let fromIndexPath = IndexPath(row: itemIndex, section: index)
|
||||||
|
let toIndexPath = IndexPath(row: 0, section: 0)
|
||||||
|
tv.moveRow(at: fromIndexPath, to: toIndexPath)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
reload(animated: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getSectionIndex(by numberIndex: Int) -> Int? {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func setFilterPredicate(_ predicate: FilterPredicate<Item>?) {
|
func setFilterPredicate(_ predicate: FilterPredicate<Item>?) {
|
||||||
self.filterPredicate = predicate
|
self.filterPredicate = predicate
|
||||||
self.reload()
|
self.reload()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user