adguard-home-manager/lib/screens/home/top_items_options_modal.dart

84 lines
2.4 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:adguard_home_manager/widgets/custom_list_tile_dialog.dart';
class TopItemsOptionsModal extends StatelessWidget {
final bool? isBlocked;
final void Function(String status)? changeStatus;
final void Function() copyToClipboard;
2023-02-04 20:47:08 +01:00
final String type;
const TopItemsOptionsModal({
Key? key,
this.isBlocked,
this.changeStatus,
required this.copyToClipboard,
2023-02-04 20:47:08 +01:00
required this.type
}) : super(key: key);
@override
Widget build(BuildContext context) {
return AlertDialog(
contentPadding: const EdgeInsets.symmetric(vertical: 16),
title: Column(
children: [
Icon(
Icons.more_horiz,
size: 24,
color: Theme.of(context).listTileTheme.iconColor
),
const SizedBox(height: 16),
Text(
AppLocalizations.of(context)!.options,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface
),
)
],
),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
2023-02-04 20:47:08 +01:00
if (type == 'topQueriedDomains' || type == 'topBlockedDomains') ...[
if (isBlocked == true && changeStatus != null) CustomListTileDialog(
title: AppLocalizations.of(context)!.unblock,
icon: Icons.check,
onTap: () {
Navigator.pop(context);
changeStatus!('unblock');
},
),
if (isBlocked == false && changeStatus != null) CustomListTileDialog(
title: AppLocalizations.of(context)!.block,
icon: Icons.block,
onTap: () {
Navigator.pop(context);
changeStatus!('block');
},
),
],
CustomListTileDialog(
2023-02-04 20:47:08 +01:00
title: AppLocalizations.of(context)!.copyClipboard,
icon: Icons.copy,
onTap: () {
Navigator.pop(context);
copyToClipboard();
}
),
],
),
actions: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(AppLocalizations.of(context)!.cancel)
)
],
)
],
);
}
}