Use the same filter you are using in the gallery to select all.
Filter the data by what the user has, and when he clicks your select all button, change all of those records to have the check box checked.
So do something like:
ForAll(Filter(DATA, equation being used),This.checkbox = true)
or whatever you are using. I don't think my syntax and everything is right, but this should give you a general idea.
Generally, just use ForAll() to do something to each record you get, and use the filter, search, or lookup you are using in the gallery.
Or another way is to find all the current items in the gallery and use a ForAll(), but I don't know how to do that even though it would give cleaner code. The solution I gave is the rough and dirty way to do it - if you want cleaner go with what I just suggested I just don't know how to do it off the top of my head.