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>(builder: (context, profile, child) {
24 0 : return Card(
25 : clipBehavior: Clip.antiAlias,
26 0 : margin: EdgeInsets.all(0.0),
27 0 : child: InkWell(
28 0 : child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
29 0 : Padding(
30 : padding: const EdgeInsets.all(6.0), //border size
31 0 : child: Row(children: [
32 0 : Icon(CwtchIcons.dns_24px,
33 0 : color: running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor, size: 64),
34 0 : Visibility(
35 : visible: !running,
36 0 : child: Icon(
37 : CwtchIcons.negative_heart_24px,
38 0 : color: Provider.of<Settings>(context).theme.portraitOfflineBorderColor,
39 : )),
40 : ])),
41 0 : Expanded(
42 0 : child: Column(
43 0 : children: [
44 0 : Text(
45 : description,
46 : semanticsLabel: description,
47 0 : style: Provider.of<Settings>(context)
48 0 : .scaleFonts(defaultFormLabelTextStyle)
49 0 : .copyWith(fontWeight: FontWeight.bold)
50 0 : .apply(color: running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor),
51 : softWrap: true,
52 : overflow: TextOverflow.ellipsis,
53 : ),
54 0 : Visibility(
55 0 : visible: !Provider.of<Settings>(context).streamerMode,
56 0 : child: ExcludeSemantics(
57 0 : child: Text(
58 0 : server.onion,
59 : softWrap: true,
60 : overflow: TextOverflow.ellipsis,
61 0 : style: TextStyle(color: running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor),
62 : ))),
63 0 : Visibility(
64 0 : visible: server.status == "Authenticated",
65 0 : child: LinearProgressIndicator(
66 0 : color: Provider.of<Settings>(context).theme.defaultButtonActiveColor,
67 0 : backgroundColor: Provider.of<Settings>(context).theme.defaultButtonDisabledColor,
68 0 : value: server.syncProgress,
69 : )),
70 : ],
71 : )),
72 : ]),
73 0 : onTap: () {
74 0 : Navigator.of(context).push(
75 0 : PageRouteBuilder(
76 0 : settings: RouteSettings(name: "remoteserverview"),
77 0 : pageBuilder: (bcontext, a1, a2) {
78 0 : return MultiProvider(
79 0 : providers: [ChangeNotifierProvider.value(value: profile), ChangeNotifierProvider.value(value: server), Provider.value(value: Provider.of<FlwtchState>(context))],
80 0 : child: RemoteServerView(),
81 : );
82 : },
83 0 : transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
84 0 : transitionDuration: Duration(milliseconds: 200),
85 : ),
86 : );
87 : }));
88 : });
89 : }
90 : }
|