flutter_app/lib/widgets/tor_icon.dart

29 lines
1.2 KiB
Dart
Raw Normal View History

2021-06-03 18:32:25 +00:00
import 'package:cwtch/cwtch_icons_icons.dart';
2021-04-27 20:07:59 +00:00
import 'package:flutter/cupertino.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../settings.dart';
import '../torstatus.dart';
/// A reusable Tor Icon Widget that displays the current status of the underlying Tor connections
class TorIcon extends StatefulWidget {
TorIcon();
@override
State<StatefulWidget> createState() => _TorIconState();
}
class _TorIconState extends State<TorIcon> {
@override
Widget build(BuildContext context) {
2021-05-25 20:43:13 +00:00
return RepaintBoundary(
2021-06-04 18:13:52 +00:00
child: Icon(
Provider.of<TorStatus>(context).progress == 0 ? CwtchIcons.onion_off : (Provider.of<TorStatus>(context).progress == 100 ? CwtchIcons.onion_on : CwtchIcons.onion_waiting),
2021-04-27 20:07:59 +00:00
color: Provider.of<Settings>(context).theme.mainTextColor(),
2021-06-04 18:13:52 +00:00
semanticLabel: Provider.of<TorStatus>(context).progress == 100
2021-05-25 00:11:39 +00:00
? AppLocalizations.of(context)!.networkStatusOnline
: (Provider.of<TorStatus>(context).progress == 0 ? AppLocalizations.of(context)!.networkStatusDisconnected : AppLocalizations.of(context)!.networkStatusAttemptingTor),
2021-05-25 20:43:13 +00:00
));
2021-04-27 20:07:59 +00:00
}
}