uias / Tabman

™️ A powerful paging view controller with interactive indicator bars
https://uias.github.io/Tabman
MIT License
2.84k stars 235 forks source link

API for reloading data isn't user friendly. #554

Open jhildensperger opened 3 years ago

jhildensperger commented 3 years ago

New Issue Checklist

Issue Description

Currently, we have the function

TMBar.reloadData(at: ClosedRange<Int>)

The parameter type ClosedRange<Int> is a bit cumbersome because bar.buttons.all.indices is a Range<Int>. If we want to reload all buttons, we now need something like

bar.reloadData(at: 0...bar.buttons.all.indices.endIndex - 1, context: .full)

Can the functions accepting ClosedRange<Int> be changed to use Range<Int> instead?

Also, to the point of this closed issue https://github.com/uias/Tabman/issues/335, adding some other functions for convenience would be nice.

/// Reload all indices within the bar using the given context.
///
/// - Parameters:
///   - context: The context for the reload.
func reloadData(context: TMBarReloadContext)

/// Reload all data within the bar.
///
func reloadData()
msaps commented 3 years ago

@jhildensperger like the suggestion of changing from using a ClosedRange to a Range 👍

Not so easy to add the convenience functions to TMBar as currently the range of the reload / buttons is injected and not maintained as state as such. Maybe would be better to understand what use case you need this functionality for?