Line data Source code
1 : import 'package:cwtch/cwtch_icons_icons.dart'; 2 : import 'package:flutter/cupertino.dart'; 3 : import 'package:provider/provider.dart'; 4 : import 'package:flutter_gen/gen_l10n/app_localizations.dart'; 5 : import '../settings.dart'; 6 : import '../torstatus.dart'; 7 : 8 : /// A reusable Tor Icon Widget that displays the current status of the underlying Tor connections 9 : class TorIcon extends StatefulWidget { 10 0 : TorIcon(); 11 : 12 0 : @override 13 0 : State<StatefulWidget> createState() => _TorIconState(); 14 : } 15 : 16 : class _TorIconState extends State<TorIcon> { 17 0 : @override 18 : Widget build(BuildContext context) { 19 0 : return RepaintBoundary( 20 0 : child: Icon( 21 0 : Provider.of<TorStatus>(context).progress == 0 ? CwtchIcons.onion_off : (Provider.of<TorStatus>(context).progress == 100 ? CwtchIcons.onion_on : CwtchIcons.onion_waiting), 22 0 : color: Provider.of<Settings>(context).theme.mainTextColor, 23 0 : semanticLabel: Provider.of<TorStatus>(context).progress == 100 24 0 : ? AppLocalizations.of(context)!.networkStatusOnline 25 0 : : (Provider.of<TorStatus>(context).progress == 0 ? AppLocalizations.of(context)!.networkStatusDisconnected : AppLocalizations.of(context)!.networkStatusAttemptingTor), 26 : )); 27 : } 28 : }