mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-02-18 00:17:40 +01:00
58 lines
2.1 KiB
Dart
58 lines
2.1 KiB
Dart
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
|
import 'package:swift_control/utils/core.dart';
|
|
import 'package:swift_control/utils/i18n_extension.dart';
|
|
import 'package:swift_control/widgets/ui/connection_method.dart';
|
|
import 'package:swift_control/widgets/ui/toast.dart';
|
|
|
|
class MyWhooshLinkTile extends StatefulWidget {
|
|
const MyWhooshLinkTile({super.key});
|
|
|
|
@override
|
|
State<MyWhooshLinkTile> createState() => _MywhooshLinkTileState();
|
|
}
|
|
|
|
class _MywhooshLinkTileState extends State<MyWhooshLinkTile> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ValueListenableBuilder(
|
|
valueListenable: core.whooshLink.isStarted,
|
|
builder: (context, isStarted, _) {
|
|
return ValueListenableBuilder(
|
|
valueListenable: core.whooshLink.isConnected,
|
|
builder: (context, isConnected, _) {
|
|
return ConnectionMethod(
|
|
isEnabled: core.settings.getMyWhooshLinkEnabled(),
|
|
type: ConnectionMethodType.network,
|
|
title: context.i18n.connectUsingMyWhooshLink,
|
|
instructionLink: 'INSTRUCTIONS_MYWHOOSH_LINK.md',
|
|
description: isConnected
|
|
? context.i18n.myWhooshLinkConnected
|
|
: isStarted
|
|
? context.i18n.checkMyWhooshConnectionScreen
|
|
: context.i18n.myWhooshLinkDescriptionLocal,
|
|
requirements: [],
|
|
showTroubleshooting: true,
|
|
onChange: (value) {
|
|
core.settings.setMyWhooshLinkEnabled(value);
|
|
if (!value) {
|
|
core.whooshLink.stopServer();
|
|
} else if (value) {
|
|
core.connection.startMyWhooshServer().catchError((e) {
|
|
core.settings.setMyWhooshLinkEnabled(false);
|
|
buildToast(
|
|
context,
|
|
title: context.i18n.errorStartingMyWhooshLink,
|
|
);
|
|
});
|
|
}
|
|
},
|
|
isStarted: isStarted,
|
|
isConnected: isConnected,
|
|
);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|