Swiftui list padding - swift

I have a list of list items in swiftui - and all I want to do is get rid of the list padding. I've found a large number of stack overflow posts covering this. There are many solutions identified. I've tried them all - particularly :
List( data.treeLines ) {
item in
TreeLineView( line: item, selectedId: $selectedItem )
.listRowInsets(EdgeInsets()).background(Color.yellow)
})
Some people say that doesn't work because you need foreach - I've tried
List() {
ForEach( data.treeLines ) {
item in
TreeLineView( line: item, selectedId: $selectedItem ).listRowInsets(EdgeInsets()).background(Color.yellow)
}.listRowInsets(EdgeInsets()).background(Color.green)
}
I've tried .none instead of edge insets.. I've tried EdgeInsets( row:0, top:0, leading:0:, trailing:0) - I've tried -20 leading and trailing. I've tried putting the directive on the list itself. I've even tried .listStyle - planliststyle did nothing and the other one I found just gave me an error saying it was only available on iOS.
In every case, the list looks like:
where I want it to go from edge to edge (and in fact, I also want to get rid of the spacing in between the list items, but that's extra credit)
the one way I did manage to get a change is by doing the following on the list itself:
.padding(.horizontal, -40)
which does actually get rid of some of the padding, but also starts putting some of my actual content underneath the border, and still seems to have only gotten rid of half of the padding. Making that number bigger just shifts my content worse, it doesn't get rid of any more border - it looks like this:
so basically - I've read everything I can find, tried every solution, and am now at a bit of a loss :(
note - this is a MacOS app running under macOS 11 - not an IOS app.

Related

VS Code brings search result line to the center of the screen

When you search for a keyword in VS Code, and it returns x results, as you start browsing among those results, the screen always centers vertically the active result on the screen. This may be useful in some situations, but in cases where I want to "frame" all my results in the same active screen, it's very annoying that it jumps the code, even by 2-3 lines...
OK, if in that viewable portion of the code there are no results, and I click on the next result, it'd make sense to bring me to the first one. But if let's say 4-5 results are already in the viewable portion of the code, I would like to set it so that it prevents that centering all the time. So is there such a setting?
I hope I explained it well enough so that you understand what I mean. TIA for any help.
I don't think that is configurable if the next find match is outside of the viewport. I see this in the code:
(https://github.com/microsoft/vscode/blob/7a0a293b38c353cd9773316a022d8f926d481715/src/vs/editor/contrib/find/browser/findModel.ts)
private _setCurrentFindMatch(match: Range): void {
let matchesPosition = this._decorations.setCurrentFindMatch(match);
this._state.changeMatchInfo(
matchesPosition,
this._decorations.getCount(),
match
);
this._editor.setSelection(match);
this._editor.revealRangeInCenterIfOutsideViewport(match, ScrollType.Smooth);
}
So revealRangeInCenterIfOutsideViewport() will always put the next find match into the center if it is not initially not in the viewport.
In the search code, there is the similar:
this.searchResultEditor.revealLineInCenterIfOutsideViewport(matchRange.startLineNumber);
So I would think there is no scrolling if the next serach result is already in view.
For me, there is no scrolliing at all if the next find match is anywhere in the viewport. Do you see some scrolling if it is at the very bottom, for example?

How to avoid the ugly empty space of the placeholder for the vertical scrollbar in QTableView?

In a QTableView instance, rows are variable, the row count are not fixed most of the time. In a moment, if the row count is lower than the display count of the viewport, a ugly empty-space placeholder for the vertical scroll bar will show up as in the below picture.
I tried viewportSizeHint(), maximumViewPortSize(), ... finally, a very simple solution.
Solution: If there is a n-column table originally, super().__init(m,n+1) should be called. The extra empty column is to fix the visual effect.
The last thing to remind, just ignore this extra column. Ignore it! No need any other specific codes for it. No any bad side effects have been found until now.
Feel free to post your reviews.
class KBWWTableModel(QtGui.QStandardItemModel):
def __init__(self, parent: QtCore.QObject=None):
# add a extra empty column to fix the visual effect
# super().__init__(1, 3, parent=parent)
super().__init__(1, 4, parent=parent)

Xamarin Forms SearchBar + ListView slow to update

I would like some help into speeding up the process of filtering a long list of list items and viewing them on a ListView.
My app has a search bar, a ListView and a very long list of strings to choose from.
When the user enter a search term, the ListView is updated with every key stroke and filter out the irrelevant items.
Sorting itself takes a few milliseconds, but updating the ListView afterwards with the new filter-event takes a long time (20 seconds easy, if only a single character has been entered as search criteria)
I believe the time is spent on inflating a large number of ViewCells every time the filtered list updates.
Do any of you know how to speed up the process? I thought the way it could work was to have a very limited number of ViewCells (like 10 or 20) and then have them update and just show a selection of the filtered list. Scrolling would to be reusing the top/bottom one, update the content and put it back on the bottom/top - but I have not been able to wrap my head around how to do this.
Maybe it is the wrong approach and you know a better way?
I just had a similar problem that my list with just 20 elements would search extremely slow. Maybe your problem is similar. Sadly you didn't post any code. I had something like this:
List l = originalItems.Where((i) => i.Name.Contains(filterText));
listView.ItemsSource = l;
And I could not understand why this would be so slow. I found a different approach with more overhead that for some reason is faster and more responsive and overall feels better for the user. My ListView always has an ObservableCollection as ItemsSource. When I filter I calculate the difference to this ObservableCollection (the extra items and the removed items) and then remove or add accordingly. This avoids replacing the ItemsSource property which seems to be too harsh on the ListView.
//property of the class
ObservableCollection<FlightListItem> listViewItems;
// ....
//somewhere at initialization
listView.ItemsSoure = listViewItems;
// ....
//in the filter method:
List l = originalItems.Where((i) => i.Name.Contains(filterText));
IEnumerable itemsToAdd = l.Except(listViewItems).ToList();
IEnumerable itemsToRemove = listViewItems.Except(l).ToList();
listView.BeginRefresh();
foreach (FlightListItem item in removes)
listViewItems.Remove(item);
foreach (FlightListItem item in added)
listViewItems.Add(item);
listView.EndRefresh();
Notes:
removing the listView.BeginRefresh() and EndRefresh() did not seem to impact performance, but it seems the right thing to call them here.
We need to call ToList() on the itemsToAdd and itemsToRemove even though we only need IEnumerables! This is because Except is a lazy operation and will otherwise only be evaluated during the for loop. However during the for loop one of the parameters to Except changes which leads to an IllegalArgumentException due to modifying an IEnumerable while going over it.
If anyone knows a good filterable observable collection that would probably be a nicer solution.

Ionic3 virtualScroll gives blank list when scrolling far ahead on large list

Using Ionic3 to implement large list scrolling with virtualScroll.
I added a vertical slider (input range) linked to a function using Ionic3
this.content.scrollTo(0, yVal, 1000)
to scroll back and forth but if I scroll too far ahead in the list, I get the error
ERROR TypeError: Cannot read property 'scrollTop' of null
I played with the time parameter but nothing seems to make a difference.
My list has 10k items and if I scroll one step at a time (1%), everything is fine. But if I try to go all the way to 50% of the list, I get a blank output with the above error.
What am I doing wrong ???
Live sample and code can be found here:
https://ionic-list100k-segment-index.stackblitz.io
https://stackblitz.com/edit/ionic-list100k-segment-index

Erratic UIPageControls

I'm using two UIPageControls in a view to reflect chapters and pages. So I have defined one UIPageControl named chapterCount and one named pageCount just to show where the user is. I handle the flipping of the pages with swipes rather than using the UIPageControls (so no methods defined for them).
I change their values as the user change pages with the following code:
chapterCount.numberOfPages = chapters;
chapterCount.currentPage = chapterNumber;
pageCount.numberOfPages = pages;
pageCount.currentPage = pageNumber;
[chapterCount updateCurrentPageDisplay];
[pageCount updateCurrentPageDisplay];
Where chapters, chapterNumber, pages and pageNumber all are integers.
The first time I flip through the pages it normally works fine, but when I go to a previous chapter or start a new chapter, the first (or last depending on direction) dot is not showed. Please see picture (upper half is missing a dot, lower one OK).
alt text http://img80.imageshack.us/img80/3339/pagecontrol.png
Its the same code updating the controls and sometime I get a dot, sometimes not. When I check the variables with NSLOG they are correct (eg the same for both pictures above).
I have checked Apple's documentation and tried their example but no luck.
Where should I start troubleshooting? I'm getting crazy!!
I finally found the problem :-)
An UIPageControl that is given a value 0 for number of pages will not show correctly the next time it is updated. I was reading chapter and page numbers from an array and in the beginning (let's say cover of the book) there are no pages and no chapters to show, so I happily set these to 0. Since I did not want to change the source data in my array I used MAX(pages , 1) for numberOfPages, so now it's working like clockwork.
Are you sure your chapterCount and pageCount views are not nil? You can have valid values all day, a message to nil does nothing and returns nil. Double check your view and controller wiring/unwiring when you change chapters.
EDIT:
confirm the size of the control is big enough to hold all your pages, and the view bounds is not clipped. For example, if you had 10 pages, and the "current" page was 10, but there were only 9 dots visible, it would appear as though nothing is highlighted because the white dot would be clipped from the visible area by being outside the viewable bounds. You can adjust the size dynamically using this:
- (CGSize)sizeForNumberOfPages:(NSInteger)pageCount