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

This commit is contained in:
Neeraj Gupta 2023-03-16 10:26:55 +05:30 committed by GitHub
commit cb1e5ebb72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 11 additions and 129 deletions

View file

@ -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"],

View file

@ -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");

View file

@ -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;

View file

@ -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,
),
);
}
}

View file

@ -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());
},
),
],
);
}
}

View file

@ -137,7 +137,8 @@ class _ApplyCodeScreenState extends State<ApplyCodeScreen> {
showErrorDialogForException(
context: context,
exception: e as Exception,
apiErrorPrefix: "Failed to apply code");
apiErrorPrefix: "Failed to apply code",
);
}
},
)

View file

@ -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