Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[auth] Delete unused code

Neeraj Gupta4bbac0ca66b2
diff --git a/auth/lib/events/opened_settings_event.dart b/auth/lib/events/opened_settings_event.dart
deleted file mode 100644
index 3aadeb1222..0000000000
--- a/auth/lib/events/opened_settings_event.dart
+++ /dev/null
@@ -1,3 +0,0 @@
-import 'package:ente_auth/events/event.dart';
-
-class OpenedSettingsEvent extends Event {}
diff --git a/auth/lib/json/converter.dart b/auth/lib/json/converter.dart
deleted file mode 100644
index 9f45f8f8e5..0000000000
--- a/auth/lib/json/converter.dart
+++ /dev/null
@@ -1,17 +0,0 @@
-import 'dart:typed_data';
-
-import "package:json_annotation/json_annotation.dart";
-
-class Uint8ListConverter implements JsonConverter<Uint8List, List<int>> {
- const Uint8ListConverter();
-
- @override
- Uint8List fromJson(List<int>? json) {
- return json == null ? Uint8List(0) : Uint8List.fromList(json);
- }
-
- @override
- List<int> toJson(Uint8List object) {
- return object.toList();
- }
-}
diff --git a/auth/lib/models/magic_metadata.dart b/auth/lib/models/magic_metadata.dart
deleted file mode 100644
index 9edab547ee..0000000000
--- a/auth/lib/models/magic_metadata.dart
+++ /dev/null
@@ -1,73 +0,0 @@
-import 'dart:convert';
-
-const visibilityVisible = 0;
-const visibilityArchive = 1;
-
-const magicKeyVisibility = 'visibility';
-
-const pubMagicKeyEditedTime = 'editedTime';
-const pubMagicKeyEditedName = 'editedName';
-
-class MagicMetadata {
- // 0 -> visible
- // 1 -> archived
- // 2 -> hidden etc?
- int visibility;
-
- MagicMetadata({required this.visibility});
-
- factory MagicMetadata.fromEncodedJson(String encodedJson) =>
- MagicMetadata.fromJson(jsonDecode(encodedJson));
-
- factory MagicMetadata.fromJson(dynamic json) => MagicMetadata.fromMap(json);
-
- static fromMap(Map<String, dynamic>? map) {
- if (map == null) return null;
- return MagicMetadata(
- visibility: map[magicKeyVisibility] ?? visibilityVisible,
- );
- }
-}
-
-class PubMagicMetadata {
- int? editedTime;
- String? editedName;
-
- PubMagicMetadata({this.editedTime, this.editedName});
-
- factory PubMagicMetadata.fromEncodedJson(String encodedJson) =>
- PubMagicMetadata.fromJson(jsonDecode(encodedJson));
-
- factory PubMagicMetadata.fromJson(dynamic json) =>
- PubMagicMetadata.fromMap(json);
-
- static fromMap(Map<String, dynamic>? map) {
- if (map == null) return null;
- return PubMagicMetadata(
- editedTime: map[pubMagicKeyEditedTime],
- editedName: map[pubMagicKeyEditedName],
- );
- }
-}
-
-class CollectionMagicMetadata {
- // 0 -> visible
- // 1 -> archived
- // 2 -> hidden etc?
- int visibility;
-
- CollectionMagicMetadata({required this.visibility});
-
- factory CollectionMagicMetadata.fromEncodedJson(String encodedJson) =>
- CollectionMagicMetadata.fromJson(jsonDecode(encodedJson));
-
- factory CollectionMagicMetadata.fromJson(dynamic json) =>
- CollectionMagicMetadata.fromMap(json);
-
- static fromMap(Map<String, dynamic>? map) {
- if (map == null) return null;
- return CollectionMagicMetadata(
- visibility: map[magicKeyVisibility] ?? visibilityVisible,
- );
- }
-}
diff --git a/auth/lib/models/public_key.dart b/auth/lib/models/public_key.dart
deleted file mode 100644
index 0d14a4a557..0000000000
--- a/auth/lib/models/public_key.dart
+++ /dev/null
@@ -1,6 +0,0 @@
-class PublicKey {
- final String email;
- final String publicKey;
-
- PublicKey(this.email, this.publicKey);
-}
diff --git a/auth/lib/services/auth_feature_flag.dart b/auth/lib/services/auth_feature_flag.dart
deleted file mode 100644
index 92a1c540d7..0000000000
--- a/auth/lib/services/auth_feature_flag.dart
+++ /dev/null
@@ -1,23 +0,0 @@
-import 'package:ente_auth/core/configuration.dart';
-import 'package:flutter/foundation.dart';
-
-class FeatureFlagService {
- FeatureFlagService._privateConstructor();
- static final FeatureFlagService instance =
- FeatureFlagService._privateConstructor();
-
- static final _internalUserIDs = const String.fromEnvironment(
- "internal_user_ids",
- defaultValue: "1,2,3,4,191,125,1580559962388044,1580559962392434,10000025",
- ).split(",").map((element) {
- return int.parse(element);
- }).toSet();
-
- bool isInternalUserOrDebugBuild() {
- final String? email = Configuration.instance.getEmail();
- final userID = Configuration.instance.getUserID();
- return (email != null && email.endsWith("@ente.io")) ||
- _internalUserIDs.contains(userID) ||
- kDebugMode;
- }
-}
diff --git a/auth/lib/store/user_store.dart b/auth/lib/store/user_store.dart
deleted file mode 100644
index b191d169d8..0000000000
--- a/auth/lib/store/user_store.dart
+++ /dev/null
@@ -1,14 +0,0 @@
-import 'package:shared_preferences/shared_preferences.dart';
-
-class UserStore {
- UserStore._privateConstructor();
-
- // ignore: unused_field
- late SharedPreferences _preferences;
-
- static final UserStore instance = UserStore._privateConstructor();
-
- Future<void> init() async {
- _preferences = await SharedPreferences.getInstance();
- }
-}
diff --git a/auth/lib/ui/common/bottom_shadow.dart b/auth/lib/ui/common/bottom_shadow.dart
deleted file mode 100644
index 2de7e944e2..0000000000
--- a/auth/lib/ui/common/bottom_shadow.dart
+++ /dev/null
@@ -1,25 +0,0 @@
-import 'package:flutter/material.dart';
-
-class BottomShadowWidget extends StatelessWidget {
- final double offsetDy;
- final Color? shadowColor;
- const BottomShadowWidget({this.offsetDy = 28, this.shadowColor, super.key});
-
- @override
- Widget build(BuildContext context) {
- return Container(
- height: 8,
- decoration: BoxDecoration(
- color: Colors.transparent,
- boxShadow: [
- BoxShadow(
- color: shadowColor ?? Theme.of(context).colorScheme.surface,
- spreadRadius: 42,
- blurRadius: 42,
- offset: Offset(0, offsetDy), // changes position of shadow
- ),
- ],
- ),
- );
- }
-}
diff --git a/auth/lib/ui/common/linear_progress_dialog.dart b/auth/lib/ui/common/linear_progress_dialog.dart
deleted file mode 100644
index 08c46d6c97..0000000000
--- a/auth/lib/ui/common/linear_progress_dialog.dart
+++ /dev/null
@@ -1,49 +0,0 @@
-import 'package:ente_auth/ente_theme_data.dart';
-import 'package:flutter/material.dart';
-
-class LinearProgressDialog extends StatefulWidget {
- final String message;
-
- const LinearProgressDialog(this.message, {super.key});
-
- @override
- LinearProgressDialogState createState() => LinearProgressDialogState();
-}
-
-class LinearProgressDialogState extends State<LinearProgressDialog> {
- double? _progress;
-
- @override
- void initState() {
- _progress = 0;
- super.initState();
- }
-
- void setProgress(double progress) {
- setState(() {
- _progress = progress;
- });
- }
-
- @override
- Widget build(BuildContext context) {
- return PopScope(
- canPop: false,
- child: AlertDialog(
- title: Text(
- widget.message,
- style: const TextStyle(
- fontSize: 16,
- ),
- textAlign: TextAlign.center,
- ),
- content: LinearProgressIndicator(
- value: _progress,
- valueColor: AlwaysStoppedAnimation<Color>(
- Theme.of(context).colorScheme.alternativeColor,
- ),
- ),
- ),
- );
- }
-}
diff --git a/auth/lib/ui/common/rename_dialog.dart b/auth/lib/ui/common/rename_dialog.dart
deleted file mode 100644
index ad93d1abaa..0000000000
--- a/auth/lib/ui/common/rename_dialog.dart
+++ /dev/null
@@ -1,98 +0,0 @@
-
-
-import 'package:ente_auth/utils/dialog_util.dart';
-import 'package:flutter/material.dart';
-
-class RenameDialog extends StatefulWidget {
- final String name;
- final String type;
- final int maxLength;
-
- const RenameDialog(this.name, this.type, {super.key, this.maxLength = 100});
-
- @override
- State<RenameDialog> createState() => _RenameDialogState();
-}
-
-class _RenameDialogState extends State<RenameDialog> {
- String? _newName;
-
- @override
- void initState() {
- super.initState();
- _newName = widget.name;
- }
-
- @override
- Widget build(BuildContext context) {
- return AlertDialog(
- title: const Text("Enter a new name"),
- content: SingleChildScrollView(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- TextFormField(
- decoration: InputDecoration(
- hintText: '${widget.type} name',
- hintStyle: const TextStyle(
- color: Colors.white30,
- ),
- contentPadding: const EdgeInsets.all(12),
- ),
- onChanged: (value) {
- setState(() {
- _newName = value;
- });
- },
- autocorrect: false,
- keyboardType: TextInputType.text,
- initialValue: _newName,
- autofocus: true,
- ),
- ],
- ),
- ),
- actions: [
- TextButton(
- child: const Text(
- "Cancel",
- style: TextStyle(
- color: Colors.redAccent,
- ),
- ),
- onPressed: () {
- Navigator.of(context).pop(null);
- },
- ),
- TextButton(
- child: Text(
- "Rename",
- style: TextStyle(
- color: Theme.of(context).colorScheme.onSurface,
- ),
- ),
- onPressed: () {
- if (_newName!.trim().isEmpty) {
- showErrorDialog(
- context,
- "Empty name",
- "${widget.type} name cannot be empty",
- );
- return;
- }
- if (_newName!.trim().length > widget.maxLength) {
- showErrorDialog(
- context,
- "Name too large",
- "${widget.type} name should be less than ${widget.maxLength} characters",
- );
- return;
- }
- Navigator.of(context).pop(_newName!.trim());
- },
- ),
- ],
- );
- }
-}
diff --git a/auth/lib/ui/components/home_header_widget.dart b/auth/lib/ui/components/home_header_widget.dart
deleted file mode 100644
index 0079cc7fa7..0000000000
--- a/auth/lib/ui/components/home_header_widget.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-import 'package:ente_auth/core/event_bus.dart';
-import 'package:ente_auth/events/opened_settings_event.dart';
-import 'package:flutter/material.dart';
-
-class HomeHeaderWidget extends StatefulWidget {
- final Widget centerWidget;
- const HomeHeaderWidget({required this.centerWidget, super.key});
-
- @override
- State<HomeHeaderWidget> createState() => _HomeHeaderWidgetState();
-}
-
-class _HomeHeaderWidgetState extends State<HomeHeaderWidget> {
- @override
- Widget build(BuildContext context) {
- final hasNotch = View.of(context).viewPadding.top > 65;
- return Padding(
- padding: EdgeInsets.fromLTRB(4, hasNotch ? 4 : 8, 4, 4),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- IconButton(
- visualDensity: const VisualDensity(horizontal: -2, vertical: -2),
- onPressed: () {
- Scaffold.of(context).openDrawer();
- Bus.instance.fire(OpenedSettingsEvent());
- },
- splashColor: Colors.transparent,
- icon: const Icon(
- Icons.menu_outlined,
- ),
- ),
- AnimatedSwitcher(
- duration: const Duration(milliseconds: 250),
- child: widget.centerWidget,
- ),
- ],
- ),
- );
- }
-}
diff --git a/auth/lib/ui/settings/danger_section_widget.dart b/auth/lib/ui/settings/danger_section_widget.dart
deleted file mode 100644
index 4f8160c38e..0000000000
--- a/auth/lib/ui/settings/danger_section_widget.dart
+++ /dev/null
@@ -1,69 +0,0 @@
-import 'package:ente_auth/l10n/l10n.dart';
-import 'package:ente_auth/services/user_service.dart';
-import 'package:ente_auth/theme/ente_theme.dart';
-import 'package:ente_auth/ui/account/delete_account_page.dart';
-import 'package:ente_auth/ui/components/captioned_text_widget.dart';
-import 'package:ente_auth/ui/components/expandable_menu_item_widget.dart';
-import 'package:ente_auth/ui/components/menu_item_widget.dart';
-import 'package:ente_auth/ui/settings/common_settings.dart';
-import 'package:ente_auth/utils/dialog_util.dart';
-import 'package:ente_auth/utils/navigation_util.dart';
-import 'package:flutter/material.dart';
-
-class DangerSectionWidget extends StatelessWidget {
- const DangerSectionWidget({super.key});
-
- @override
- Widget build(BuildContext context) {
- return ExpandableMenuItemWidget(
- title: context.l10n.exit,
- selectionOptionsWidget: _getSectionOptions(context),
- leadingIcon: Icons.logout_outlined,
- );
- }
-
- Widget _getSectionOptions(BuildContext context) {
- return Column(
- children: [
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: context.l10n.logout,
- ),
- pressedColor: getEnteColorScheme(context).fillFaint,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- onTap: () async {
- _onLogoutTapped(context);
- },
- ),
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: context.l10n.deleteAccount,
- ),
- pressedColor: getEnteColorScheme(context).fillFaint,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- onTap: () async {
- // ignore: unawaited_futures
- routeToPage(context, const DeleteAccountPage());
- },
- ),
- sectionOptionSpacing,
- ],
- );
- }
-
- void _onLogoutTapped(BuildContext context) {
- showChoiceActionSheet(
- context,
- title: context.l10n.areYouSureYouWantToLogout,
- firstButtonLabel: context.l10n.yesLogout,
- isCritical: true,
- firstButtonOnTap: () async {
- await UserService.instance.logout(context);
- },
- );
- }
-}
diff --git a/auth/lib/ui/settings/debug_section_widget.dart b/auth/lib/ui/settings/debug_section_widget.dart
deleted file mode 100644
index 03406f7911..0000000000
--- a/auth/lib/ui/settings/debug_section_widget.dart
+++ /dev/null
@@ -1,94 +0,0 @@
-import 'package:ente_auth/core/configuration.dart';
-import 'package:ente_auth/l10n/l10n.dart';
-import 'package:ente_auth/ui/settings/common_settings.dart';
-import 'package:ente_auth/ui/settings/settings_section_title.dart';
-import 'package:ente_auth/ui/settings/settings_text_item.dart';
-import 'package:ente_crypto_dart/ente_crypto_dart.dart';
-import 'package:expandable/expandable.dart';
-import 'package:flutter/material.dart';
-
-class DebugSectionWidget extends StatelessWidget {
- const DebugSectionWidget({super.key});
-
- @override
- Widget build(BuildContext context) {
- // This is a debug only section not shown to end users, so these strings are
- // not translated.
- return ExpandablePanel(
- header: const SettingsSectionTitle("Debug"),
- collapsed: Container(),
- expanded: _getSectionOptions(context),
- theme: getExpandableTheme(),
- );
- }
-
- Widget _getSectionOptions(BuildContext context) {
- return Column(
- children: [
- GestureDetector(
- behavior: HitTestBehavior.translucent,
- onTap: () async {
- _showKeyAttributesDialog(context);
- },
- child: const SettingsTextItem(
- text: "Key attributes",
- icon: Icons.navigate_next,
- ),
- ),
- ],
- );
- }
-
- void _showKeyAttributesDialog(BuildContext context) {
- final l10n = context.l10n;
- final keyAttributes = Configuration.instance.getKeyAttributes()!;
- final AlertDialog alert = AlertDialog(
- title: const Text("key attributes"),
- content: SingleChildScrollView(
- child: Column(
- children: [
- const Text(
- "Key",
- style: TextStyle(fontWeight: FontWeight.bold),
- ),
- Text(CryptoUtil.bin2base64(Configuration.instance.getKey()!)),
- const Padding(padding: EdgeInsets.all(12)),
- const Text(
- "Encrypted Key",
- style: TextStyle(fontWeight: FontWeight.bold),
- ),
- Text(keyAttributes.encryptedKey),
- const Padding(padding: EdgeInsets.all(12)),
- const Text(
- "Key Decryption Nonce",
- style: TextStyle(fontWeight: FontWeight.bold),
- ),
- Text(keyAttributes.keyDecryptionNonce),
- const Padding(padding: EdgeInsets.all(12)),
- const Text(
- "KEK Salt",
- style: TextStyle(fontWeight: FontWeight.bold),
- ),
- Text(keyAttributes.kekSalt),
- const Padding(padding: EdgeInsets.all(12)),
- ],
- ),
- ),
- actions: [
- TextButton(
- child: Text(l10n.ok),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop('dialog');
- },
- ),
- ],
- );
-
- showDialog(
- context: context,
- builder: (BuildContext context) {
- return alert;
- },
- );
- }
-}
diff --git a/auth/lib/ui/settings/made_with_love_widget.dart b/auth/lib/ui/settings/made_with_love_widget.dart
deleted file mode 100644
index a8e12c106b..0000000000
--- a/auth/lib/ui/settings/made_with_love_widget.dart
+++ /dev/null
@@ -1,34 +0,0 @@
-import 'package:ente_auth/l10n/l10n.dart';
-import 'package:flutter/material.dart';
-import 'package:url_launcher/url_launcher.dart';
-
-class MadeWithLoveWidget extends StatelessWidget {
- const MadeWithLoveWidget({
- super.key,
- });
-
- @override
- Widget build(BuildContext context) {
- final l10n = context.l10n;
- return GestureDetector(
- onTap: () {
- launchUrl(Uri.parse("https://ente.io"));
- },
- child: RichText(
- text: TextSpan(
- text: l10n.madeWithLoveAtPrefix,
- style: DefaultTextStyle.of(context).style,
- children: const <TextSpan>[
- TextSpan(
- text: 'ente.io',
- style: TextStyle(
- fontWeight: FontWeight.bold,
- color: Colors.green,
- ),
- ),
- ],
- ),
- ),
- );
- }
-}
diff --git a/auth/lib/ui/settings/settings_text_item.dart b/auth/lib/ui/settings/settings_text_item.dart
deleted file mode 100644
index afaf56432c..0000000000
--- a/auth/lib/ui/settings/settings_text_item.dart
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-import 'dart:io';
-
-import 'package:flutter/material.dart';
-
-class SettingsTextItem extends StatelessWidget {
- final String text;
- final IconData icon;
- const SettingsTextItem({
- super.key,
- required this.text,
- required this.icon,
- });
-
- @override
- Widget build(BuildContext context) {
- return Column(
- children: [
- Padding(padding: EdgeInsets.all(Platform.isIOS ? 4 : 6)),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Align(
- alignment: Alignment.centerLeft,
- child: Text(text, style: Theme.of(context).textTheme.titleMedium),
- ),
- Icon(icon),
- ],
- ),
- Padding(padding: EdgeInsets.all(Platform.isIOS ? 4 : 6)),
- ],
- );
- }
-}
diff --git a/auth/lib/ui/settings/support_dev_widget.dart b/auth/lib/ui/settings/support_dev_widget.dart
deleted file mode 100644
index 849b954153..0000000000
--- a/auth/lib/ui/settings/support_dev_widget.dart
+++ /dev/null
@@ -1,83 +0,0 @@
-import 'package:dotted_border/dotted_border.dart';
-import 'package:ente_auth/core/configuration.dart';
-import 'package:ente_auth/l10n/l10n.dart';
-import 'package:ente_auth/models/subscription.dart';
-import 'package:ente_auth/services/billing_service.dart';
-import 'package:ente_auth/theme/ente_theme.dart';
-import 'package:flutter/material.dart';
-import 'package:styled_text/styled_text.dart';
-import 'package:url_launcher/url_launcher.dart';
-
-class SupportDevWidget extends StatelessWidget {
- const SupportDevWidget({
- super.key,
- });
-
- @override
- Widget build(BuildContext context) {
- final l10n = context.l10n;
-
- // fetch
- if (Configuration.instance.hasConfiguredAccount()) {
- return FutureBuilder<Subscription>(
- future: BillingService.instance.getSubscription(),
- builder: (context, snapshot) {
- if (snapshot.hasData) {
- final subscription = snapshot.data;
- if (subscription != null && subscription.productID == "free") {
- return buildWidget(l10n, context);
- }
- }
- return const SizedBox.shrink();
- },
- );
- } else {
- return buildWidget(l10n, context);
- }
- }
-
- Widget buildWidget(AppLocalizations l10n, BuildContext context) {
- return GestureDetector(
- onTap: () {
- launchUrl(Uri.parse("https://ente.io"));
- },
- child: DottedBorder(
- borderType: BorderType.RRect,
- radius: const Radius.circular(12),
- padding: const EdgeInsets.all(6),
- dashPattern: const <double>[3, 3],
- color: getEnteColorScheme(context).primaryGreen,
- child: ClipRRect(
- borderRadius: const BorderRadius.all(Radius.circular(12)),
- child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 6),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- StyledText(
- text: l10n.supportDevs,
- style: getEnteTextTheme(context).large,
- tags: {
- 'bold-green': StyledTextTag(
- style: TextStyle(
- fontWeight: FontWeight.bold,
- color: getEnteColorScheme(context).primaryGreen,
- ),
- ),
- },
- ),
- const Padding(padding: EdgeInsets.all(6)),
- Text(
- l10n.supportDiscount,
- style: const TextStyle(
- color: Colors.grey,
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- );
- }
-}
diff --git a/auth/lib/ui/settings_section_title.dart b/auth/lib/ui/settings_section_title.dart
deleted file mode 100644
index 613744d49d..0000000000
--- a/auth/lib/ui/settings_section_title.dart
+++ /dev/null
@@ -1 +0,0 @@
-// TODO Implement this library.