Allow shutdown to be called by method handler
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
This commit is contained in:
parent
213a29c691
commit
87732a2ba2
|
@ -50,6 +50,7 @@ class FlwtchState extends State<Flwtch> {
|
|||
//var columns = [1, 1, 2];
|
||||
late ProfileListState profs;
|
||||
final MethodChannel notificationClickChannel = MethodChannel('im.cwtch.flwtch/notificationClickHandler');
|
||||
final MethodChannel shutdownMethodChannel = MethodChannel('im.cwtch.flwtch/shutdown');
|
||||
final GlobalKey<NavigatorState> navKey = GlobalKey<NavigatorState>();
|
||||
|
||||
@override
|
||||
|
@ -59,6 +60,7 @@ class FlwtchState extends State<Flwtch> {
|
|||
|
||||
profs = ProfileListState();
|
||||
notificationClickChannel.setMethodCallHandler(_externalNotificationClicked);
|
||||
shutdownMethodChannel.setMethodCallHandler(shutdown);
|
||||
print("initState set cwtch...");
|
||||
if (Platform.isAndroid) {
|
||||
var cwtchNotifier = new CwtchNotifier(profs, globalSettings, globalErrorHandler, globalTorStatus, NullNotificationsManager(), globalAppState);
|
||||
|
@ -114,6 +116,7 @@ class FlwtchState extends State<Flwtch> {
|
|||
}
|
||||
|
||||
Future<void> shutdown(MethodCall call) async {
|
||||
cwtch.Shutdown();
|
||||
// Wait a few seconds as shutting down things takes a little time..
|
||||
Future.delayed(Duration(seconds: 2)).then((value) {
|
||||
if (Platform.isAndroid) {
|
||||
|
|
|
@ -120,7 +120,6 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
|
|||
Widget continueButton = TextButton(
|
||||
child: Text(AppLocalizations.of(context)!.shutdownCwtchAction),
|
||||
onPressed: () {
|
||||
Provider.of<FlwtchState>(context, listen: false).cwtch.Shutdown();
|
||||
// Directly call the shutdown command, Android will do this for us...
|
||||
Provider.of<FlwtchState>(context, listen: false).shutdown(MethodCall(""));
|
||||
closeApp = true;
|
||||
|
|
|
@ -9,26 +9,29 @@ class SplashView extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<AppState>(
|
||||
builder: (context, appState, child) => Scaffold(
|
||||
body: Center(child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Image(image: AssetImage("assets/knott.png"),
|
||||
filterQuality: FilterQuality.medium,
|
||||
isAntiAlias: true,
|
||||
width: 200,
|
||||
height: 200,),
|
||||
Image(image: AssetImage("assets/cwtch_title.png"),
|
||||
filterQuality: FilterQuality.medium,
|
||||
isAntiAlias: true,),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Text(appState.appError == "" ? "Loading Cwtch..." : appState.appError,
|
||||
style: TextStyle(fontSize: 16.0, color: appState.appError == "" ? Provider.of<Settings>(context).theme.mainTextColor() : Provider.of<Settings>(context).theme.textfieldErrorColor())),
|
||||
),
|
||||
Image(image: AssetImage("assets/Open_Privacy_Logo_lightoutline.png")),
|
||||
])),
|
||||
));
|
||||
builder: (context, appState, child) => Scaffold(
|
||||
body: Center(
|
||||
child: Column(mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [
|
||||
Image(
|
||||
image: AssetImage("assets/knott.png"),
|
||||
filterQuality: FilterQuality.medium,
|
||||
isAntiAlias: true,
|
||||
width: 200,
|
||||
height: 200,
|
||||
),
|
||||
Image(
|
||||
image: AssetImage("assets/cwtch_title.png"),
|
||||
filterQuality: FilterQuality.medium,
|
||||
isAntiAlias: true,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Text(appState.appError == "" ? "Loading Cwtch..." : appState.appError,
|
||||
style: TextStyle(
|
||||
fontSize: 16.0, color: appState.appError == "" ? Provider.of<Settings>(context).theme.mainTextColor() : Provider.of<Settings>(context).theme.textfieldErrorColor())),
|
||||
),
|
||||
Image(image: AssetImage("assets/Open_Privacy_Logo_lightoutline.png")),
|
||||
])),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue