π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[auth] Add UI to select algorithm
Aman Raj Singh Mouryab1ed3a6302c6
diff --git a/auth/lib/ui/algorithm_selector_widget.dart b/auth/lib/ui/algorithm_selector_widget.dartnew file mode 100644index 0000000000..d4ef28037d--- /dev/null+++ b/auth/lib/ui/algorithm_selector_widget.dart@@ -0,0 +1,74 @@+import 'package:ente_auth/models/code.dart';+import 'package:flutter/material.dart';++class AlgorithmSelectorWidget extends StatelessWidget {+ final Algorithm currentAlgorithm;+ final void Function(Algorithm) onSelected;+ const AlgorithmSelectorWidget({+ super.key,+ required this.currentAlgorithm,+ required this.onSelected,+ });++ @override+ Widget build(BuildContext context) {+ Text algorithmOptionText(Algorithm algorithm) {+ return Text(+ algorithm.name.toUpperCase(),+ style: Theme.of(context).textTheme.titleMedium!.copyWith(+ fontSize: 14,+ color: Theme.of(context).iconTheme.color!.withOpacity(0.7),+ ),+ );+ }++ return GestureDetector(+ onTapDown: (TapDownDetails details) async {+ final int? selectedValue = await showMenu<int>(+ context: context,+ position: RelativeRect.fromLTRB(+ details.globalPosition.dx,+ details.globalPosition.dy,+ details.globalPosition.dx,+ details.globalPosition.dy + 300,+ ),+ items: List.generate(Algorithm.values.length, (index) {+ return PopupMenuItem(+ value: index,+ child: Row(+ mainAxisAlignment: MainAxisAlignment.spaceBetween,+ children: [+ algorithmOptionText(Algorithm.values[index]),+ if (Algorithm.values[index] == currentAlgorithm)+ Icon(+ Icons.check,+ color: Theme.of(context).iconTheme.color,+ ),+ ],+ ),+ );+ }),+ );+ if (selectedValue != null) {+ onSelected(Algorithm.values[selectedValue]);+ }+ },+ child: Container(+ padding: const EdgeInsets.only(bottom: 4),+ decoration: BoxDecoration(+ border: Border(+ bottom: BorderSide(color: Theme.of(context).dividerColor),+ ),+ ),+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ algorithmOptionText(currentAlgorithm),+ const SizedBox(width: 8),+ const Icon(Icons.arrow_drop_down),+ ],+ ),+ ),+ );+ }+}