Forráskód Böngészése

Refactor: Clean up unused widgets + lint fixes (#928)

Neeraj Gupta 2 éve
szülő
commit
cb1e5ebb72

+ 2 - 1
lib/models/api/storage_bonus/storage_bonus.dart

@@ -131,7 +131,8 @@ class BonusDetails {
 
   factory BonusDetails.fromJson(Map<String, dynamic> json) => BonusDetails(
         referralStats: List<ReferralStat>.from(
-            json["referralStats"].map((x) => ReferralStat.fromJson(x))),
+          json["referralStats"].map((x) => ReferralStat.fromJson(x)),
+        ),
         bonuses:
             List<Bonus>.from(json["bonuses"].map((x) => Bonus.fromJson(x))),
         refCount: json["refCount"],

+ 4 - 1
lib/services/favorites_service.dart

@@ -137,7 +137,10 @@ class FavoritesService {
   }
 
   Future<void> updateFavorites(
-      BuildContext context, List<File> files, bool favFlag) async {
+    BuildContext context,
+    List<File> files,
+    bool favFlag,
+  ) async {
     final int currentUserID = Configuration.instance.getUserID()!;
     if (files.any((f) => f.uploadedFileID == null)) {
       throw AssertionError("Can only favorite uploaded items");

+ 0 - 2
lib/services/search_service.dart

@@ -1,6 +1,5 @@
 import 'package:logging/logging.dart';
 import 'package:photos/core/event_bus.dart';
-import 'package:photos/core/network/network.dart';
 import 'package:photos/data/holidays.dart';
 import 'package:photos/data/months.dart';
 import 'package:photos/data/years.dart';
@@ -21,7 +20,6 @@ import 'package:tuple/tuple.dart';
 
 class SearchService {
   Future<List<File>>? _cachedFilesFuture;
-  final _enteDio = NetworkClient.instance.enteDio;
   final _logger = Logger((SearchService).toString());
   final _collectionService = CollectionsService.instance;
   static const _maximumResultsLimit = 20;

+ 0 - 24
lib/ui/common/divider_with_padding.dart

@@ -1,24 +0,0 @@
-import 'package:flutter/material.dart';
-
-class DividerWithPadding extends StatelessWidget {
-  final double left, top, right, bottom, thickness;
-
-  const DividerWithPadding({
-    Key? key,
-    this.left = 0,
-    this.top = 0,
-    this.right = 0,
-    this.bottom = 0,
-    this.thickness = 0.5,
-  }) : super(key: key);
-
-  @override
-  Widget build(BuildContext context) {
-    return Padding(
-      padding: EdgeInsets.fromLTRB(left, top, right, bottom),
-      child: Divider(
-        thickness: thickness,
-      ),
-    );
-  }
-}

+ 0 - 97
lib/ui/common/rename_dialog.dart

@@ -1,97 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:photos/utils/dialog_util.dart';
-
-class RenameDialog extends StatefulWidget {
-  final String? name;
-  final String type;
-  final int maxLength;
-
-  const RenameDialog(this.name, this.type, {Key? key, this.maxLength = 100})
-      : super(key: key);
-
-  @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());
-          },
-        ),
-      ],
-    );
-  }
-}

+ 4 - 3
lib/ui/growth/apply_code_screen.dart

@@ -135,9 +135,10 @@ class _ApplyCodeScreenState extends State<ApplyCodeScreen> {
                           Logger('$runtimeType')
                               .severe("failed to apply referral", e);
                           showErrorDialogForException(
-                              context: context,
-                              exception: e as Exception,
-                              apiErrorPrefix: "Failed to apply code");
+                            context: context,
+                            exception: e as Exception,
+                            apiErrorPrefix: "Failed to apply code",
+                          );
                         }
                       },
                     )

+ 1 - 1
lib/ui/growth/referral_screen.dart

@@ -43,7 +43,7 @@ class _ReferralScreenState extends State<ReferralScreen> {
         await UserService.instance.getUserDetailsV2(memoryCount: false);
     final referralView =
         await StorageBonusService.instance.getGateway().getReferralView();
-    return Tuple2(referralView, cachedUserDetails!);
+    return Tuple2(referralView, cachedUserDetails);
   }
 
   @override