Skip to content

Commit

Permalink
revert: "build: upgrade Flutter to 3.22.0 (#163)" (#172)
Browse files Browse the repository at this point in the history
This reverts commit 1e7ac2d.
  • Loading branch information
poppingmoon authored May 19, 2024
1 parent c411ffe commit b9f2838
Show file tree
Hide file tree
Showing 20 changed files with 168 additions and 153 deletions.
2 changes: 1 addition & 1 deletion .fvmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"flutter": "3.22.0"
"flutter": "3.19.6"
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dart.flutterSdkPath": ".fvm/versions/3.22.0",
"dart.flutterSdkPath": ".fvm/versions/3.19.6",
"editor.formatOnSave": true,
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.expand": false,
Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ SPEC CHECKSUMS:
fluttertoast: 9f2f8e81bb5ce18facb9748d7855bf5a756fe3db
gal: 61e868295d28fe67ffa297fae6dacebf56fd53e1
image_editor_common: d6f6644ae4a6de80481e89fe6d0a8c49e30b4b43
integration_test: ce0a3ffa1de96d1a89ca0ac26fca7ea18a749ef4
integration_test: 13825b8a9334a850581300559b8839134b124670
just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa
libwebp: 1786c9f4ff8a279e4dac1e8f385004d5fc253009
Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d
Expand Down
3 changes: 1 addition & 2 deletions lib/provider/theme_data_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ ThemeData themeData(ThemeDataRef ref, Brightness brightness) {
surface: colors.panel,
onSurface: colors.fg,
onSurfaceVariant: colors.fg,
background: colors.bg,
error: colors.error,
outlineVariant: colors.divider,
),
primaryColor: colors.accent,
dividerColor: colors.divider,
canvasColor: colors.bg,
scaffoldBackgroundColor: colors.bg,
textTheme: ThemeData.light()
.textTheme
.merge(
Expand Down
2 changes: 1 addition & 1 deletion lib/provider/theme_data_provider.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 31 additions & 26 deletions lib/util/format_datetime.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,38 @@ import '../i18n/strings.g.dart';

String relativeTime(DateTime time) {
final duration = DateTime.now().difference(time);
if (duration.isNegative) {
return switch (duration.inSeconds) {
> -3 => t.misskey.ago_.justNow,
> -60 => t.misskey.timeIn_.seconds(n: -duration.inSeconds),
> -3600 => t.misskey.timeIn_.minutes(n: -duration.inMinutes),
_ => switch (duration.inDays) {
> -1 => t.misskey.timeIn_.hours(n: -duration.inHours),
> -7 => t.misskey.timeIn_.days(n: -duration.inDays),
> -30 => t.misskey.timeIn_.weeks(n: (-duration.inDays / 7).round()),
> -365 =>
t.misskey.timeIn_.months(n: (-duration.inDays / 30).round()),
_ => t.misskey.timeIn_.years(n: (-duration.inDays / 365).round()),
}
};
final isFuture = duration.isNegative;
final abs = duration.abs();
if (abs.inDays >= 365) {
return isFuture
? t.misskey.timeIn_.years(n: (abs.inDays / 365).round())
: t.misskey.ago_.yearsAgo(n: (abs.inDays / 365).round());
} else if (abs.inDays >= 30) {
return isFuture
? t.misskey.timeIn_.months(n: (abs.inDays / 30).round())
: t.misskey.ago_.monthsAgo(n: (abs.inDays / 30).round());
} else if (abs.inDays >= 7) {
return isFuture
? t.misskey.timeIn_.weeks(n: (abs.inDays / 7).round())
: t.misskey.ago_.weeksAgo(n: (abs.inDays / 7).round());
} else if (abs.inDays >= 1) {
return isFuture
? t.misskey.timeIn_.days(n: abs.inDays)
: t.misskey.ago_.daysAgo(n: abs.inDays);
} else if (abs.inHours >= 1) {
return isFuture
? t.misskey.timeIn_.hours(n: abs.inHours)
: t.misskey.ago_.hoursAgo(n: abs.inHours);
} else if (abs.inMinutes >= 1) {
return isFuture
? t.misskey.timeIn_.minutes(n: abs.inMinutes)
: t.misskey.ago_.minutesAgo(n: abs.inMinutes);
} else if (duration.inSeconds >= 10 || duration.inSeconds < -3) {
return isFuture
? t.misskey.timeIn_.seconds(n: abs.inSeconds)
: t.misskey.ago_.secondsAgo(n: abs.inSeconds);
} else {
return switch (duration.inSeconds) {
< 10 => t.misskey.ago_.justNow,
< 60 => t.misskey.ago_.secondsAgo(n: duration.inSeconds),
< 3600 => t.misskey.ago_.minutesAgo(n: duration.inMinutes),
_ => switch (duration.inDays) {
< 1 => t.misskey.ago_.hoursAgo(n: duration.inHours),
< 7 => t.misskey.ago_.daysAgo(n: duration.inDays),
< 30 => t.misskey.ago_.weeksAgo(n: (duration.inDays / 7).round()),
< 365 => t.misskey.ago_.monthsAgo(n: (duration.inDays / 30).round()),
_ => t.misskey.ago_.yearsAgo(n: (duration.inDays / 365).round()),
},
};
return t.misskey.ago_.justNow;
}
}

Expand Down
27 changes: 0 additions & 27 deletions lib/util/pretty_bytes.dart

This file was deleted.

4 changes: 2 additions & 2 deletions lib/view/dialog/image_gallery_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ class ImageGalleryDialog extends HookConsumerWidget {
shadows: [
Shadow(
blurRadius: 2.0,
color: Theme.of(context).canvasColor,
color: Theme.of(context).colorScheme.background,
),
Shadow(
blurRadius: 2.0,
color: Theme.of(context).canvasColor,
color: Theme.of(context).colorScheme.background,
),
],
),
Expand Down
15 changes: 10 additions & 5 deletions lib/view/page/drive_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:misskey_dart/misskey_dart.dart' hide Clip;
import 'package:pretty_bytes/pretty_bytes.dart';

import '../../i18n/strings.g.dart';
import '../../model/account.dart';
Expand All @@ -15,7 +16,6 @@ import '../../provider/api/drive_stats_provider.dart';
import '../../provider/general_settings_notifier_provider.dart';
import '../../provider/misskey_colors_provider.dart';
import '../../provider/selected_drive_files_notifier_provider.dart';
import '../../util/pretty_bytes.dart';
import '../widget/drive_create_sheet.dart';
import '../widget/drive_file_widget.dart';
import '../widget/drive_files_sheet.dart';
Expand Down Expand Up @@ -130,10 +130,15 @@ class DrivePage extends HookConsumerWidget {
),
onPressed: () =>
context.push('/settings/accounts/$account/drive'),
child: Text(
'${t.misskey.inUse}: '
'${prettyBytes(stats.usage)} / ${prettyBytes(stats.capacity)}',
),
child: Text('${t.misskey.inUse}: ${prettyBytes(
stats.usage.toDouble(),
locale: Localizations.localeOf(context).toLanguageTag(),
binary: true,
)} / ${prettyBytes(
stats.capacity.toDouble(),
locale: Localizations.localeOf(context).toLanguageTag(),
binary: true,
)}'),
),
if (!selectFiles && !selectFolder)
IconButton(
Expand Down
5 changes: 2 additions & 3 deletions lib/view/page/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ class LoginPage extends HookConsumerWidget {
],
),
],
backgroundColor: Theme.of(context)
.scaffoldBackgroundColor
.withOpacity(0.5),
backgroundColor:
Theme.of(context).colorScheme.background.withOpacity(0.5),
),
),
),
Expand Down
14 changes: 11 additions & 3 deletions lib/view/page/settings/drive_settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:math';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:misskey_dart/misskey_dart.dart';
import 'package:pretty_bytes/pretty_bytes.dart';

import '../../../i18n/strings.g.dart';
import '../../../model/account.dart';
Expand All @@ -11,7 +12,6 @@ import '../../../provider/api/drive_folder_provider.dart';
import '../../../provider/api/drive_stats_provider.dart';
import '../../../provider/api/i_notifier_provider.dart';
import '../../../util/future_with_dialog.dart';
import '../../../util/pretty_bytes.dart';
import '../../widget/account_settings_scaffold.dart';
import '../../widget/key_value_widget.dart';
import '../drive_page.dart';
Expand Down Expand Up @@ -75,13 +75,21 @@ class DriveSettingsPage extends ConsumerWidget {
Expanded(
child: KeyValueWidget(
label: t.misskey.inUse,
text: prettyBytes(stats.usage),
text: prettyBytes(
stats.usage.toDouble(),
locale: Localizations.localeOf(context).toLanguageTag(),
binary: true,
),
),
),
Expanded(
child: KeyValueWidget(
label: t.misskey.capacity,
text: prettyBytes(stats.capacity),
text: prettyBytes(
stats.capacity.toDouble(),
locale: Localizations.localeOf(context).toLanguageTag(),
binary: true,
),
),
),
],
Expand Down
5 changes: 2 additions & 3 deletions lib/view/page/timelines_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,9 @@ class TimelinesPage extends HookConsumerWidget {
children: [
if (isLargeScreen)
DrawerTheme(
data: DrawerThemeData(
backgroundColor: Theme.of(context).colorScheme.surface,
data: const DrawerThemeData(
elevation: 0.0,
shape: const RoundedRectangleBorder(),
shape: RoundedRectangleBorder(),
),
child: TimelineDrawer(controller: controller),
),
Expand Down
5 changes: 2 additions & 3 deletions lib/view/page/token_login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ class TokenLoginPage extends HookConsumerWidget {
filter: ImageFilter.blur(sigmaX: 6.0, sigmaY: 6.0),
child: AppBar(
title: Text(t.aria.loginWithAccessToken),
backgroundColor: Theme.of(context)
.scaffoldBackgroundColor
.withOpacity(0.5),
backgroundColor:
Theme.of(context).colorScheme.background.withOpacity(0.5),
),
),
),
Expand Down
3 changes: 2 additions & 1 deletion lib/view/widget/ad_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ class AdWidget extends HookConsumerWidget {
alignment: Alignment.topRight,
child: IconButton(
style: IconButton.styleFrom(
backgroundColor: Theme.of(context).canvasColor.withOpacity(0.8),
backgroundColor:
Theme.of(context).colorScheme.background.withOpacity(0.8),
),
onPressed: () => showMenu.value = true,
icon: const Icon(Icons.info_outline),
Expand Down
22 changes: 18 additions & 4 deletions lib/view/widget/drive_file_info.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:misskey_dart/misskey_dart.dart';
import 'package:pretty_bytes/pretty_bytes.dart';

import '../../extension/text_style_extension.dart';
import '../../i18n/strings.g.dart';
Expand All @@ -12,7 +13,6 @@ import '../../util/copy_text.dart';
import '../../util/format_datetime.dart';
import '../../util/future_with_dialog.dart';
import '../../util/navigate.dart';
import '../../util/pretty_bytes.dart';
import '../dialog/text_field_dialog.dart';
import 'media_list.dart';
import 'time_widget.dart';
Expand Down Expand Up @@ -218,11 +218,25 @@ class DriveFileInfo extends ConsumerWidget {
child: Text(t.misskey.fileViewer_.size),
),
InkWell(
onLongPress: () =>
copyToClipboard(context, prettyBytes(file.size)),
onLongPress: () => copyToClipboard(
context,
prettyBytes(
file.size.toDouble(),
locale:
Localizations.localeOf(context).toLanguageTag(),
binary: true,
),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(prettyBytes(file.size.toDouble())),
child: Text(
prettyBytes(
file.size.toDouble(),
locale:
Localizations.localeOf(context).toLanguageTag(),
binary: true,
),
),
),
),
],
Expand Down
18 changes: 15 additions & 3 deletions lib/view/widget/media_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:misskey_dart/misskey_dart.dart' hide Clip;
import 'package:pretty_bytes/pretty_bytes.dart';
import 'package:url_launcher/url_launcher.dart';

import '../../extension/text_style_extension.dart';
Expand All @@ -15,7 +16,6 @@ import '../../provider/data_saver_provider.dart';
import '../../provider/general_settings_notifier_provider.dart';
import '../../provider/misskey_colors_provider.dart';
import '../../provider/static_image_url_provider.dart';
import '../../util/pretty_bytes.dart';
import '../dialog/audio_dialog.dart';
import '../dialog/image_gallery_dialog.dart';
import '../dialog/video_dialog.dart';
Expand Down Expand Up @@ -293,7 +293,12 @@ class MediaCard extends HookConsumerWidget {
),
if (file.size > 0)
TextSpan(
text: prettyBytes(file.size),
text: prettyBytes(
file.size.toDouble(),
locale: Localizations.localeOf(context)
.toLanguageTag(),
binary: true,
),
),
const TextSpan(text: ')'),
],
Expand All @@ -313,7 +318,14 @@ class MediaCard extends HookConsumerWidget {
children: [
if (dataSaver && file.size > 0) ...[
const TextSpan(text: ' '),
TextSpan(text: prettyBytes(file.size)),
TextSpan(
text: prettyBytes(
file.size.toDouble(),
locale: Localizations.localeOf(context)
.toLanguageTag(),
binary: true,
),
),
],
],
),
Expand Down
2 changes: 1 addition & 1 deletion lib/view/widget/mfm/blur.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Blur extends HookWidget {
onLongPress: () => blurred.value = !blurred.value,
onHover: (value) => blurred.value = !value,
splashFactory: NoSplash.splashFactory,
overlayColor: const WidgetStatePropertyAll(Colors.transparent),
overlayColor: const MaterialStatePropertyAll(Colors.transparent),
child: blurred.value
? ImageFiltered(
imageFilter: ImageFilter.blur(
Expand Down
Loading

0 comments on commit b9f2838

Please sign in to comment.