lemmur-app-android/lib/pages/instance/instance_more_menu.dart

60 lines
1.8 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:lemmy_api_client/v3.dart';
import '../../l10n/l10n.dart';
import '../../stores/accounts_store.dart';
2022-04-30 16:23:36 +02:00
import '../../url_launcher.dart';
import '../../util/observer_consumers.dart';
import '../../widgets/bottom_modal.dart';
import '../../widgets/info_table_popup.dart';
class InstanceMoreMenu extends StatelessWidget {
final FullSiteView site;
2022-05-11 22:23:18 +02:00
const InstanceMoreMenu({super.key, required this.site});
@override
Widget build(BuildContext context) {
final instanceUrl = 'https://${site.instanceHost}';
final accountsStore = context.watch<AccountsStore>();
return Column(
children: [
if (!accountsStore.instances.contains(site.instanceHost))
ListTile(
leading: const Icon(Icons.add),
title: Text(L10n.of(context).add_instance),
onTap: () {
accountsStore.addInstance(site.instanceHost, assumeValid: true);
Navigator.of(context).pop();
ScaffoldMessenger.of(context)
..hideCurrentSnackBar()
..showSnackBar(
SnackBar(content: Text(L10n.of(context).instance_added)),
);
},
),
ListTile(
leading: const Icon(Icons.open_in_browser),
title: Text(L10n.of(context).open_in_browser),
2022-04-30 16:23:36 +02:00
onTap: () => launchLink(link: instanceUrl, context: context),
),
ListTile(
leading: const Icon(Icons.info_outline),
title: Text(L10n.of(context).nerd_stuff),
onTap: () {
showInfoTablePopup(context: context, table: site.toJson());
},
),
],
);
}
static void open(BuildContext context, FullSiteView site) {
showBottomModal(
context: context,
builder: (context) => InstanceMoreMenu(site: site),
);
}
}