Line data Source code
1 : import 'package:cwtch/main.dart';
2 : import 'package:cwtch/models/profile.dart';
3 : import 'package:cwtch/models/remoteserver.dart';
4 : import 'package:cwtch/themes/opaque.dart';
5 : import 'package:cwtch/views/remoteserverview.dart';
6 : import 'package:flutter/material.dart';
7 : import 'package:provider/provider.dart';
8 :
9 : import '../cwtch_icons_icons.dart';
10 : import '../settings.dart';
11 :
12 : class RemoteServerRow extends StatefulWidget {
13 0 : @override
14 0 : _RemoteServerRowState createState() => _RemoteServerRowState();
15 : }
16 :
17 : class _RemoteServerRowState extends State<RemoteServerRow> {
18 0 : @override
19 : Widget build(BuildContext context) {
20 0 : var server = Provider.of<RemoteServerInfoState>(context);
21 0 : var description = server.description.isNotEmpty ? server.description : server.onion;
22 0 : var running = server.status == "Synced";
23 0 : return Consumer<ProfileInfoState>(
24 0 : builder: (context, profile, child) {
25 0 : return InkWell(
26 : enableFeedback: true,
27 : splashFactory: InkSplash.splashFactory,
28 0 : child: Ink(
29 : color: Colors.transparent,
30 0 : child: Container(
31 0 : child: Row(
32 : mainAxisAlignment: MainAxisAlignment.spaceBetween,
33 0 : children: [
34 0 : Padding(
35 : padding: const EdgeInsets.all(6.0), //border size
36 0 : child: Row(
37 0 : children: [
38 0 : Icon(
39 : CwtchIcons.dns_24px,
40 0 : color: running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor,
41 : size: 64,
42 : ),
43 0 : Visibility(
44 : visible: !running,
45 0 : child: Icon(CwtchIcons.negative_heart_24px, color: Provider.of<Settings>(context).theme.portraitOfflineBorderColor),
46 : ),
47 : ],
48 : ),
49 : ),
50 0 : Expanded(
51 0 : child: Column(
52 0 : children: [
53 0 : Text(
54 : description,
55 : semanticsLabel: description,
56 0 : style: Provider.of<Settings>(context)
57 0 : .scaleFonts(defaultFormLabelTextStyle)
58 0 : .copyWith(fontWeight: FontWeight.bold)
59 0 : .apply(color: running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor),
60 : softWrap: true,
61 : overflow: TextOverflow.ellipsis,
62 : ),
63 0 : Visibility(
64 0 : visible: !Provider.of<Settings>(context).streamerMode,
65 0 : child: ExcludeSemantics(
66 0 : child: Text(
67 0 : server.onion,
68 : softWrap: true,
69 : overflow: TextOverflow.ellipsis,
70 0 : style: TextStyle(color: running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor),
71 : ),
72 : ),
73 : ),
74 0 : Visibility(
75 0 : visible: server.status == "Authenticated",
76 0 : child: LinearProgressIndicator(
77 0 : color: Provider.of<Settings>(context).theme.defaultButtonActiveColor,
78 0 : backgroundColor: Provider.of<Settings>(context).theme.defaultButtonDisabledColor,
79 0 : value: server.syncProgress,
80 : ),
81 : ),
82 : ],
83 : ),
84 : ),
85 : ],
86 : ),
87 : ),
88 : ),
89 0 : onTap: () {
90 0 : Navigator.of(context).push(
91 0 : PageRouteBuilder(
92 0 : settings: RouteSettings(name: "remoteserverview"),
93 0 : pageBuilder: (bcontext, a1, a2) {
94 0 : return MultiProvider(
95 0 : providers: [
96 0 : ChangeNotifierProvider.value(value: profile),
97 0 : ChangeNotifierProvider.value(value: server),
98 0 : Provider.value(value: Provider.of<FlwtchState>(context)),
99 : ],
100 0 : child: RemoteServerView(),
101 : );
102 : },
103 0 : transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
104 0 : transitionDuration: Duration(milliseconds: 200),
105 : ),
106 : );
107 : },
108 : );
109 : },
110 : );
111 : }
112 : }
|