Run uninstall.php if a checkbox is checked from settings page

You should have a function (single class, or method in a class) for the task to remove all the data from the plugin, like database or options entries.

On your settings page, call after an active checkbox this function, after sending a request, like via Button. In the uninstall.php have you also the possibility to use this function.

So you have only one function to do the same goal and no redundancy.

register_uninstall_hook

For the un-installion of the plugin via Core Function, Gui in the admin backend use the function register_uninstall_hook.

The uninstall.php

could look like this

<?php
/**
* Uninstallation script
* This file is called automatically by WP when the admin deletes the plugin from the installation.
*/
    
! defined( 'WP_UNINSTALL_PLUGIN' ) && exit;

require_once __DIR__ . '/src/settings.php';
// Use core function to delete items in the options table
delete_site_option( Your_Class_Settings::OPTION_NAME );
// Call method from class
Your_Class_Settings->uninstall();