start of profile server manager
This commit is contained in:
parent
1d884cab9d
commit
1d5359e645
|
@ -14,10 +14,10 @@ class ProfileServerListState extends ChangeNotifier {
|
||||||
return idx >= 0 ? _servers[idx] : null;
|
return idx >= 0 ? _servers[idx] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateServerCache(String onion, String status) {
|
void updateServerCache(String onion, String description, String status) {
|
||||||
int idx = _servers.indexWhere((element) => element.onion == onion);
|
int idx = _servers.indexWhere((element) => element.onion == onion);
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
_servers[idx] = RemoteServerInfoState(onion: onion, status: status);
|
_servers[idx] = RemoteServerInfoState(onion: onion, description: description, status: status);
|
||||||
} else {
|
} else {
|
||||||
print("Tried to update server cache without a starting state...this is probably an error");
|
print("Tried to update server cache without a starting state...this is probably an error");
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ class ProfileServerListState extends ChangeNotifier {
|
||||||
class RemoteServerInfoState extends ChangeNotifier {
|
class RemoteServerInfoState extends ChangeNotifier {
|
||||||
final String onion;
|
final String onion;
|
||||||
final String status;
|
final String status;
|
||||||
|
final String description;
|
||||||
|
|
||||||
RemoteServerInfoState({required this.onion, required this.status});
|
RemoteServerInfoState({required this.onion, required this.description, required this.status});
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,15 @@ class _ContactsViewState extends State<ContactsView> {
|
||||||
Clipboard.setData(new ClipboardData(text: Provider.of<ProfileInfoState>(context, listen: false).onion));
|
Clipboard.setData(new ClipboardData(text: Provider.of<ProfileInfoState>(context, listen: false).onion));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// TODO servers
|
// Manage servers
|
||||||
|
if (Provider.of<Settings>(context, listen: false).isExperimentEnabled(ServerManagementExperiment)) {
|
||||||
|
actions.add(IconButton(
|
||||||
|
icon: Icon(CwtchIcons.dns_24px),
|
||||||
|
tooltip: "Manage known servers", //AppLocalizations.of(context)!.copyAddress,
|
||||||
|
onPressed: () {
|
||||||
|
_pushServers();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
// Search contacts
|
// Search contacts
|
||||||
actions.add(IconButton(
|
actions.add(IconButton(
|
||||||
|
@ -162,12 +170,12 @@ class _ContactsViewState extends State<ContactsView> {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _pushTorStatus() {
|
void _pushServers() {
|
||||||
Navigator.of(context).push(MaterialPageRoute<void>(
|
Navigator.of(context).push(MaterialPageRoute<void>(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [Provider.value(value: Provider.of<FlwtchState>(context))],
|
providers: [Provider.value(value: Provider.of<FlwtchState>(context))],
|
||||||
child: TorStatusView(),
|
child: ProfileServersView(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
|
|
||||||
|
class ProfileServersView extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_ProfileServersView createState() => _ProfileServersView();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ProfileServersView extends State<ProfileServersView> {
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text( MediaQuery.of(context).size.width > 600 ? AppLocalizations.of(context)!.serversManagerTitleLong : AppLocalizations.of(context)!.serversManagerTitleShort),
|
||||||
|
//actions: getActions(),
|
||||||
|
),
|
||||||
|
body: Consumer<ServerListState>(
|
||||||
|
builder: (context, svrs, child) {
|
||||||
|
final tiles = svrs.servers.map((ServerInfoState server) {
|
||||||
|
return ChangeNotifierProvider<ServerInfoState>.value(
|
||||||
|
value: server,
|
||||||
|
builder: (context, child) => RepaintBoundary(child: ServerRow()),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
final divided = ListTile.divideTiles(
|
||||||
|
context: context,
|
||||||
|
tiles: tiles,
|
||||||
|
).toList();
|
||||||
|
|
||||||
|
if (tiles.isEmpty) {
|
||||||
|
return Center(
|
||||||
|
child: Text(
|
||||||
|
AppLocalizations.of(context)!.unlockServerTip,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ListView(children: divided);
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
Loading…
Reference in New Issue