How to hide and show a List or popup a List from a button

I'm absolutely new at coding for Apple and am trying to learn it by reading and creating some code for macOS that I plan to use for in-house projects. I'm using Xcode 14.2 and Swift 5.7.2 on Ventura.

The bit of code that I'm working on allows the user to choose a folder and then make a sorted array of all the file paths with a specific extension; I show the files in a List. The array will later be input to the processing code.

I do not want to display the possibly long list of file paths unless the user chooses to do so so not to clutter the window. The only user actions would be to show the List and then Close it.

I've been searching for examples of popups and have found some that are simple but they always have something that won't compile and they don't show how to pass the array to the code.

This does display the contents of the array fileList
List {
ForEach(fileList, id: .self) {
string in Text(string)