2021-11-02 02:29:58 +00:00
|
|
|
import 'package:cwtch/main.dart';
|
|
|
|
import 'package:cwtch/models/servers.dart';
|
|
|
|
import 'package:cwtch/views/addeditservers.dart';
|
|
|
|
import 'package:cwtch/widgets/profileimage.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
|
|
|
|
|
|
import '../cwtch_icons_icons.dart';
|
2021-11-04 01:56:53 +00:00
|
|
|
import '../errorHandler.dart';
|
2021-11-02 02:29:58 +00:00
|
|
|
import '../settings.dart';
|
|
|
|
|
|
|
|
class ServerRow extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_ServerRowState createState() => _ServerRowState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ServerRowState extends State<ServerRow> {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
var server = Provider.of<ServerInfoState>(context);
|
2021-11-25 23:59:54 +00:00
|
|
|
return Card(
|
|
|
|
clipBehavior: Clip.antiAlias,
|
2021-11-02 02:29:58 +00:00
|
|
|
margin: EdgeInsets.all(0.0),
|
|
|
|
child: InkWell(
|
2021-11-25 23:59:54 +00:00
|
|
|
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
2021-12-15 22:29:27 +00:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(6.0), //border size
|
2022-12-11 18:13:07 +00:00
|
|
|
child: Row(children: [
|
|
|
|
Icon(CwtchIcons.dns_24px,
|
|
|
|
color: server.running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor, size: 64),
|
|
|
|
Visibility(
|
|
|
|
visible: !server.running,
|
|
|
|
child: Icon(
|
|
|
|
CwtchIcons.negative_heart_24px,
|
|
|
|
color: Provider.of<Settings>(context).theme.portraitOfflineBorderColor,
|
|
|
|
)),
|
|
|
|
])),
|
2021-12-15 22:29:27 +00:00
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
server.description,
|
|
|
|
semanticsLabel: server.description,
|
|
|
|
style: Provider.of<FlwtchState>(context)
|
|
|
|
.biggerFont
|
|
|
|
.apply(color: server.running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor),
|
2021-11-02 02:29:58 +00:00
|
|
|
softWrap: true,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
2021-12-15 22:29:27 +00:00
|
|
|
),
|
|
|
|
Visibility(
|
|
|
|
visible: !Provider.of<Settings>(context).streamerMode,
|
|
|
|
child: ExcludeSemantics(
|
|
|
|
child: Text(
|
|
|
|
server.onion,
|
|
|
|
softWrap: true,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(color: server.running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor),
|
|
|
|
)))
|
|
|
|
],
|
|
|
|
)),
|
2021-11-02 02:29:58 +00:00
|
|
|
|
2021-12-15 22:29:27 +00:00
|
|
|
// Copy server button
|
|
|
|
IconButton(
|
|
|
|
enableFeedback: true,
|
2022-01-14 22:19:35 +00:00
|
|
|
splashRadius: Material.defaultSplashRadius / 2,
|
2021-12-15 22:29:27 +00:00
|
|
|
tooltip: AppLocalizations.of(context)!.copyServerKeys,
|
2022-09-23 15:48:10 +00:00
|
|
|
icon: Icon(CwtchIcons.address_copy, color: Provider.of<Settings>(context).current().mainTextColor),
|
2021-12-15 22:29:27 +00:00
|
|
|
onPressed: () {
|
|
|
|
Clipboard.setData(new ClipboardData(text: server.serverBundle));
|
2022-06-16 16:40:55 +00:00
|
|
|
final snackBar = SnackBar(content: Text(AppLocalizations.of(context)!.copiedToClipboardNotification));
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
2021-12-15 22:29:27 +00:00
|
|
|
},
|
|
|
|
),
|
2021-11-02 02:29:58 +00:00
|
|
|
|
2021-12-15 22:29:27 +00:00
|
|
|
// Edit button
|
|
|
|
IconButton(
|
|
|
|
enableFeedback: true,
|
2022-01-14 22:19:35 +00:00
|
|
|
splashRadius: Material.defaultSplashRadius / 2,
|
2021-12-15 22:29:27 +00:00
|
|
|
tooltip: AppLocalizations.of(context)!.editServerTitle,
|
|
|
|
icon: Icon(Icons.create, color: Provider.of<Settings>(context).current().mainTextColor),
|
|
|
|
onPressed: () {
|
|
|
|
_pushEditServer(server);
|
|
|
|
},
|
|
|
|
)
|
|
|
|
]),
|
|
|
|
onTap: () {
|
2021-11-19 00:09:55 +00:00
|
|
|
_pushEditServer(server);
|
2021-12-15 22:29:27 +00:00
|
|
|
}));
|
2021-11-02 02:29:58 +00:00
|
|
|
}
|
|
|
|
|
2021-11-25 23:59:54 +00:00
|
|
|
void _pushEditServer(ServerInfoState server) {
|
2021-11-04 01:56:53 +00:00
|
|
|
Provider.of<ErrorHandler>(context).reset();
|
2021-11-02 02:29:58 +00:00
|
|
|
Navigator.of(context).push(MaterialPageRoute<void>(
|
2021-11-04 01:56:53 +00:00
|
|
|
settings: RouteSettings(name: "serveraddedit"),
|
2021-11-02 02:29:58 +00:00
|
|
|
builder: (BuildContext context) {
|
|
|
|
return MultiProvider(
|
2021-11-25 23:59:54 +00:00
|
|
|
providers: [
|
|
|
|
ChangeNotifierProvider<ServerInfoState>(
|
|
|
|
create: (_) => server,
|
|
|
|
)
|
|
|
|
],
|
2021-11-02 02:29:58 +00:00
|
|
|
child: AddEditServerView(),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
));
|
|
|
|
}
|
2021-11-25 23:59:54 +00:00
|
|
|
}
|