refactor: improve code readability according to formatter

This commit is contained in:
Pun Butrach 2023-07-10 19:36:50 +07:00
parent b272988929
commit 6a45db8a38
No known key found for this signature in database
GPG Key ID: 5F47D61B676D07F6
9 changed files with 55 additions and 48 deletions

View File

@ -81,12 +81,21 @@ class GithubAPI {
);
final Map<String, dynamic> releases = response.data[0];
int updates = 0;
final String currentVersion = await ManagerAPI().getCurrentManagerVersion();
final String currentVersion =
await ManagerAPI().getCurrentManagerVersion();
while (response.data[updates]['tag_name'] != 'v$currentVersion') {
updates++;
}
for (int i = 1; i < updates; i++) {
releases.update('body', (value) => value + '\n' + '# '+ response.data[i]['tag_name']+'\n' + response.data[i]['body']);
releases.update(
'body',
(value) =>
value +
'\n' +
'# ' +
response.data[i]['tag_name'] +
'\n' +
response.data[i]['body']);
}
return releases;
} on Exception catch (e) {

View File

@ -140,7 +140,8 @@ class RevancedAPI {
return null;
}
StreamController<double> managerUpdateProgress = StreamController<double>.broadcast();
StreamController<double> managerUpdateProgress =
StreamController<double>.broadcast();
void updateManagerDownloadProgress(int progress) {
managerUpdateProgress.add(progress.toDouble());

View File

@ -17,8 +17,7 @@ import 'package:stacked/stacked.dart';
import 'package:stacked_services/stacked_services.dart';
class SettingsViewModel extends BaseViewModel {
final NavigationService _navigationService =
locator<NavigationService>();
final NavigationService _navigationService = locator<NavigationService>();
final ManagerAPI _managerAPI = locator<ManagerAPI>();
final Toast _toast = locator<Toast>();
@ -63,11 +62,8 @@ class SettingsViewModel extends BaseViewModel {
try {
final File outFile = File(_managerAPI.storedPatchesFile);
if (outFile.existsSync()) {
final String dateTime = DateTime.now()
.toString()
.replaceAll(' ', '_')
.split('.')
.first;
final String dateTime =
DateTime.now().toString().replaceAll(' ', '_').split('.').first;
await CRFileSaver.saveFileWithDialog(
SaveFileDialogParams(
sourceFilePath: outFile.path,
@ -87,8 +83,7 @@ class SettingsViewModel extends BaseViewModel {
Future<void> importPatches() async {
try {
final FilePickerResult? result =
await FilePicker.platform.pickFiles(
final FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['json'],
);

View File

@ -34,7 +34,8 @@ class AppSkeletonLoader extends StatelessWidget {
style: SkeletonLineStyle(
height: 20,
width: screenWidth * 0.4,
borderRadius: const BorderRadius.all(Radius.circular(10)),
borderRadius:
const BorderRadius.all(Radius.circular(10)),
),
),
),
@ -45,7 +46,8 @@ class AppSkeletonLoader extends StatelessWidget {
style: SkeletonLineStyle(
height: 15,
width: screenWidth * 0.6,
borderRadius: const BorderRadius.all(Radius.circular(10)),
borderRadius:
const BorderRadius.all(Radius.circular(10)),
),
),
),
@ -56,7 +58,8 @@ class AppSkeletonLoader extends StatelessWidget {
style: SkeletonLineStyle(
height: 15,
width: screenWidth * 0.5,
borderRadius: const BorderRadius.all(Radius.circular(10)),
borderRadius:
const BorderRadius.all(Radius.circular(10)),
),
),
),

View File

@ -76,7 +76,8 @@ class _InstalledAppItemState extends State<InstalledAppItem> {
'suggested',
translationParams: {
'version': widget.suggestedVersion.isEmpty
? FlutterI18n.translate(context, 'appSelectorCard.allVersions')
? FlutterI18n.translate(
context, 'appSelectorCard.allVersions')
: 'v${widget.suggestedVersion}',
},
),

View File

@ -60,8 +60,7 @@ class _NotInstalledAppItem extends State<NotInstalledAppItem> {
child: Text(
'',
style: TextStyle(
color:
Theme.of(context).textTheme.titleLarge!.color,
color: Theme.of(context).textTheme.titleLarge!.color,
),
),
),
@ -71,7 +70,8 @@ class _NotInstalledAppItem extends State<NotInstalledAppItem> {
'suggested',
translationParams: {
'version': widget.suggestedVersion.isEmpty
? FlutterI18n.translate(context, 'appSelectorCard.allVersions')
? FlutterI18n.translate(
context, 'appSelectorCard.allVersions')
: 'v${widget.suggestedVersion}',
},
),

View File

@ -45,8 +45,7 @@ class UpdateConfirmationDialog extends StatelessWidget {
children: [
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
I18nText(
'homeView.updateDialogTitle',
@ -63,14 +62,12 @@ class UpdateConfirmationDialog extends StatelessWidget {
children: [
Icon(
Icons.new_releases_outlined,
color: Theme.of(context)
.colorScheme
.secondary,
color:
Theme.of(context).colorScheme.secondary,
),
const SizedBox(width: 8.0),
Text(
snapshot.data!['tag_name'] ??
'Unknown',
snapshot.data!['tag_name'] ?? 'Unknown',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
@ -96,8 +93,7 @@ class UpdateConfirmationDialog extends StatelessWidget {
),
),
Padding(
padding:
const EdgeInsets.only(left: 24.0, bottom: 12.0),
padding: const EdgeInsets.only(left: 24.0, bottom: 12.0),
child: I18nText(
'homeView.updateChangelogTitle',
child: Text(
@ -113,12 +109,9 @@ class UpdateConfirmationDialog extends StatelessWidget {
),
),
Container(
margin:
const EdgeInsets.symmetric(horizontal: 24.0),
margin: const EdgeInsets.symmetric(horizontal: 24.0),
decoration: BoxDecoration(
color: Theme.of(context)
.colorScheme
.secondaryContainer,
color: Theme.of(context).colorScheme.secondaryContainer,
borderRadius: BorderRadius.circular(12.0),
),
child: Markdown(

View File

@ -42,7 +42,9 @@ class PatchItem extends StatefulWidget {
class _PatchItemState extends State<PatchItem> {
@override
Widget build(BuildContext context) {
widget.isSelected = widget.isSelected && (!widget.isUnsupported || widget._managerAPI.areExperimentalPatchesEnabled());
widget.isSelected = widget.isSelected &&
(!widget.isUnsupported ||
widget._managerAPI.areExperimentalPatchesEnabled());
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0),
child: Opacity(
@ -128,14 +130,15 @@ class _PatchItemState extends State<PatchItem> {
!widget._managerAPI
.areExperimentalPatchesEnabled()) {
widget.isSelected = false;
widget.toast
.showBottom('patchItem.unsupportedPatchVersion');
widget.toast.showBottom(
'patchItem.unsupportedPatchVersion');
} else {
widget.isSelected = newValue!;
}
if (widget.isUnsupported &&
widget.isSelected &&
!selectedUnsupportedPatches.contains(widget.name)) {
!selectedUnsupportedPatches
.contains(widget.name)) {
selectedUnsupportedPatches.add(widget.name);
}
});

View File

@ -36,7 +36,9 @@ class _SExperimentalPatchesState extends State<SExperimentalPatches> {
});
if (!value) {
for (final patch in selectedUnsupportedPatches) {
PatchesSelectorViewModel().selectedPatches.removeWhere((element) => patch == element.name);
PatchesSelectorViewModel()
.selectedPatches
.removeWhere((element) => patch == element.name);
}
selectedUnsupportedPatches.clear();
}