XIAO BLE How to Run on Battery with Switch

I have a lipo battery powering my XIAO via the pads on the bottom which is good. I now want to be able to charge the battery using the charging circuit + usbc port and to have a switch so the board can be turned off/on when running on battery anc not charging?

Also is there a way to detect which power source is being used?

Any advice here? Has anybody hooked an on/off switch up to a XIAO? Would really love some help. I can’t figure out how to wire it up to also support charging a rechargeable lipo