mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 04:57:23 +00:00
Migrate to flutter 3.27.0
This commit is contained in:
@@ -83,7 +83,7 @@ class _IllustWidgetState extends State<IllustWidget> {
|
||||
? ColorScheme.of(context).primary
|
||||
: ColorScheme.of(context)
|
||||
.outlineVariant
|
||||
.withOpacity(0.64);
|
||||
.toOpacity(0.64);
|
||||
var width = emphasis ? 1.6 : 1.0;
|
||||
return Border.all(color: color, width: width);
|
||||
}(),
|
||||
@@ -120,7 +120,7 @@ class _IllustWidgetState extends State<IllustWidget> {
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context)
|
||||
.micaBackgroundColor
|
||||
.withOpacity(0.72),
|
||||
.toOpacity(0.72),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
@@ -143,7 +143,7 @@ class _IllustWidgetState extends State<IllustWidget> {
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context)
|
||||
.errorContainer
|
||||
.withOpacity(0.8),
|
||||
.toOpacity(0.8),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
@@ -166,7 +166,7 @@ class _IllustWidgetState extends State<IllustWidget> {
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context)
|
||||
.primaryContainer
|
||||
.withOpacity(0.8),
|
||||
.toOpacity(0.8),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
@@ -387,7 +387,7 @@ class IllustHistoryWidget extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context)
|
||||
.micaBackgroundColor
|
||||
.withOpacity(0.72),
|
||||
.toOpacity(0.72),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
@@ -410,7 +410,7 @@ class IllustHistoryWidget extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context)
|
||||
.errorContainer
|
||||
.withOpacity(0.8),
|
||||
.toOpacity(0.8),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
@@ -433,7 +433,7 @@ class IllustHistoryWidget extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context)
|
||||
.primaryContainer
|
||||
.withOpacity(0.8),
|
||||
.toOpacity(0.8),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
|
@@ -132,7 +132,9 @@ abstract class MultiPageLoadingState<T extends StatefulWidget, S extends Object>
|
||||
if(message.length > 20) {
|
||||
message = "${message.substring(0, 20)}...";
|
||||
}
|
||||
context.showToast(message: message);
|
||||
if (mounted) {
|
||||
context.showToast(message: message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/components/md.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
|
||||
void showToast(BuildContext context, {required String message, IconData? icon}) {
|
||||
var newEntry = OverlayEntry(
|
||||
@@ -30,7 +31,7 @@ class ToastOverlay extends StatelessWidget {
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: PhysicalModel(
|
||||
color: ColorScheme.of(context).surface.withOpacity(1),
|
||||
color: ColorScheme.of(context).surface.toOpacity(1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
elevation: 1,
|
||||
child: Container(
|
||||
|
@@ -330,7 +330,7 @@ class SideBarRoute<T> extends PopupRoute<T> {
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context)
|
||||
.micaBackgroundColor
|
||||
.withOpacity(0.98),
|
||||
.toOpacity(0.98),
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(4),
|
||||
bottomLeft: Radius.circular(4))),
|
||||
|
@@ -40,7 +40,7 @@ class SegmentedButton<T> extends StatelessWidget {
|
||||
onPressed: () => onPressed(e.key),
|
||||
builder: (context, states) {
|
||||
var textColor = active ? null : ColorScheme.of(context).outline;
|
||||
var backgroundColor = active ? null : ButtonState.resolveWith((states) {
|
||||
var backgroundColor = active ? null : WidgetStateProperty.resolveWith((states) {
|
||||
return ButtonThemeData.buttonColor(context, states);
|
||||
}).resolve(states);
|
||||
|
||||
|
@@ -32,11 +32,11 @@ class Log {
|
||||
static const String? logFile = null;
|
||||
|
||||
static void printWarning(String text) {
|
||||
print('\x1B[33m$text\x1B[0m');
|
||||
debugPrint('\x1B[33m$text\x1B[0m');
|
||||
}
|
||||
|
||||
static void printError(String text) {
|
||||
print('\x1B[31m$text\x1B[0m');
|
||||
debugPrint('\x1B[31m$text\x1B[0m');
|
||||
}
|
||||
|
||||
static void addLog(LogLevel level, String title, String content) {
|
||||
@@ -44,15 +44,13 @@ class Log {
|
||||
content = "${content.substring(0, maxLogLength)}...";
|
||||
}
|
||||
|
||||
if (kDebugMode) {
|
||||
switch (level) {
|
||||
case LogLevel.error:
|
||||
printError(content);
|
||||
case LogLevel.warning:
|
||||
printWarning(content);
|
||||
case LogLevel.info:
|
||||
print(content);
|
||||
}
|
||||
switch (level) {
|
||||
case LogLevel.error:
|
||||
printError(content);
|
||||
case LogLevel.warning:
|
||||
printWarning(content);
|
||||
case LogLevel.info:
|
||||
debugPrint(content);
|
||||
}
|
||||
|
||||
var newLog = LogItem(level, title, content);
|
||||
|
@@ -64,4 +64,10 @@ extension WidgetExtension on Widget{
|
||||
Widget fixHeight(double height){
|
||||
return SizedBox(height: height, child: this);
|
||||
}
|
||||
}
|
||||
|
||||
extension ColorExt on Color {
|
||||
Color toOpacity(double opacity){
|
||||
return withValues(alpha: opacity);
|
||||
}
|
||||
}
|
@@ -183,21 +183,28 @@ class MyApp extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// from https://stackoverflow.com/a/60191441
|
||||
int _floatToInt8(double x) {
|
||||
return (x * 255.0).round() & 0xff;
|
||||
}
|
||||
|
||||
Color darken(Color c, [int percent = 10]) {
|
||||
assert(1 <= percent && percent <= 100);
|
||||
var f = 1 - percent / 100;
|
||||
return Color.fromARGB(c.alpha, (c.red * f).round(), (c.green * f).round(),
|
||||
(c.blue * f).round());
|
||||
return Color.fromARGB(
|
||||
_floatToInt8(c.a),
|
||||
_floatToInt8(c.r * f),
|
||||
_floatToInt8(c.g * f),
|
||||
_floatToInt8(c.b * f),
|
||||
);
|
||||
}
|
||||
|
||||
/// from https://stackoverflow.com/a/60191441
|
||||
Color lighten(Color c, [int percent = 10]) {
|
||||
assert(1 <= percent && percent <= 100);
|
||||
var p = percent / 100;
|
||||
return Color.fromARGB(
|
||||
c.alpha,
|
||||
c.red + ((255 - c.red) * p).round(),
|
||||
c.green + ((255 - c.green) * p).round(),
|
||||
c.blue + ((255 - c.blue) * p).round());
|
||||
_floatToInt8(c.a),
|
||||
_floatToInt8(c.r + (1 - c.r) * p),
|
||||
_floatToInt8(c.g + (1 - c.g) * p),
|
||||
_floatToInt8(c.b + (1 - c.b) * p),
|
||||
);
|
||||
}
|
||||
|
@@ -143,15 +143,15 @@ class _CommentsPageState extends MultiPageLoadingState<CommentsPage, Comment> {
|
||||
return Card(
|
||||
padding: EdgeInsets.zero,
|
||||
backgroundColor:
|
||||
FluentTheme.of(context).micaBackgroundColor.withOpacity(0.96),
|
||||
FluentTheme.of(context).micaBackgroundColor.toOpacity(0.96),
|
||||
child: SizedBox(
|
||||
height: 52,
|
||||
child: TextBox(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
placeholder: "Comment".tl,
|
||||
foregroundDecoration: BoxDecoration(
|
||||
foregroundDecoration: WidgetStatePropertyAll(BoxDecoration(
|
||||
border: Border.all(color: Colors.transparent),
|
||||
),
|
||||
)),
|
||||
onSubmitted: (s) {
|
||||
showToast(context, message: "Sending".tl);
|
||||
if (isCommenting) return;
|
||||
@@ -161,10 +161,12 @@ class _CommentsPageState extends MultiPageLoadingState<CommentsPage, Comment> {
|
||||
if (widget.isNovel) {
|
||||
Network().commentNovel(widget.id, s).then((value) {
|
||||
if (value.error) {
|
||||
context.showToast(message: "Network Error");
|
||||
setState(() {
|
||||
isCommenting = false;
|
||||
});
|
||||
if (context.mounted) {
|
||||
context.showToast(message: "Network Error");
|
||||
setState(() {
|
||||
isCommenting = false;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
isCommenting = false;
|
||||
nextUrl = null;
|
||||
@@ -174,10 +176,12 @@ class _CommentsPageState extends MultiPageLoadingState<CommentsPage, Comment> {
|
||||
} else {
|
||||
Network().comment(widget.id, s).then((value) {
|
||||
if (value.error) {
|
||||
context.showToast(message: "Network Error");
|
||||
setState(() {
|
||||
isCommenting = false;
|
||||
});
|
||||
if(context.mounted) {
|
||||
context.showToast(message: "Network Error");
|
||||
setState(() {
|
||||
isCommenting = false;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
isCommenting = false;
|
||||
nextUrl = null;
|
||||
|
@@ -620,7 +620,7 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
||||
borderRadius:
|
||||
const BorderRadius.vertical(top: Radius.circular(8)),
|
||||
backgroundColor:
|
||||
FluentTheme.of(context).micaBackgroundColor.withOpacity(0.96),
|
||||
FluentTheme.of(context).micaBackgroundColor.toOpacity(0.96),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
@@ -1219,7 +1219,7 @@ class __BlockingPageState extends State<_BlockingPage> {
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
borderColor: blockedTags.contains(index)
|
||||
? ColorScheme.of(context).outlineVariant
|
||||
: ColorScheme.of(context).outlineVariant.withOpacity(0.2),
|
||||
: ColorScheme.of(context).outlineVariant.toOpacity(0.2),
|
||||
padding: EdgeInsets.zero,
|
||||
child: ListTile(
|
||||
title: Text(text),
|
||||
|
@@ -122,7 +122,7 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
||||
await file.readAsBytes(),
|
||||
quality: 100,
|
||||
name: fileName);
|
||||
if (mounted) {
|
||||
if (context.mounted) {
|
||||
showToast(context, message: "Saved".tl);
|
||||
}
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ class _LogsPageState extends State<LogsPage> {
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context).surfaceVariant,
|
||||
color: ColorScheme.of(context).surfaceContainerHighest,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||
),
|
||||
child: Padding(
|
||||
|
@@ -129,7 +129,7 @@ class _MainPageState extends State<MainPage>
|
||||
);
|
||||
}
|
||||
return DefaultSelectionStyle.merge(
|
||||
selectionColor: FluentTheme.of(context).selectionColor.withOpacity(0.4),
|
||||
selectionColor: FluentTheme.of(context).selectionColor.toOpacity(0.4),
|
||||
child: NavigationView(
|
||||
appBar: buildAppBar(context, navigatorKey),
|
||||
pane: NavigationPane(
|
||||
@@ -355,9 +355,7 @@ class _MainPageState extends State<MainPage>
|
||||
ValueListenable<bool> get canPopNotifier => popValue;
|
||||
|
||||
@override
|
||||
PopInvokedCallback? get onPopInvoked => onPop;
|
||||
|
||||
void onPop(bool value) {
|
||||
void onPopInvokedWithResult(bool didPop, result) {
|
||||
if (App.rootNavigatorKey.currentState?.canPop() ?? false) {
|
||||
App.rootNavigatorKey.currentState?.pop();
|
||||
} else if (App.mainNavigatorKey?.currentState?.canPop() ?? false) {
|
||||
@@ -366,6 +364,9 @@ class _MainPageState extends State<MainPage>
|
||||
SystemNavigator.pop();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onPopInvoked(bool didPop) { }
|
||||
}
|
||||
|
||||
class _BackButton extends StatefulWidget {
|
||||
@@ -416,7 +417,7 @@ class _BackButtonState extends State<_BackButton> {
|
||||
|
||||
return NavigationPaneTheme(
|
||||
data: NavigationPaneTheme.of(context).merge(NavigationPaneThemeData(
|
||||
unselectedIconColor: ButtonState.resolveWith((states) {
|
||||
unselectedIconColor: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.isDisabled) {
|
||||
return ButtonThemeData.buttonColor(context, states);
|
||||
}
|
||||
@@ -669,16 +670,16 @@ class UserPane extends PaneItem {
|
||||
final tileColor = this.tileColor ??
|
||||
theme.tileColor ??
|
||||
kDefaultPaneItemColor(context, mode == PaneDisplayMode.top);
|
||||
final newStates = states.toSet()..remove(ButtonStates.disabled);
|
||||
final newStates = states.toSet()..remove(WidgetState.disabled);
|
||||
if (selected && selectedTileColor != null) {
|
||||
return selectedTileColor!.resolve(newStates);
|
||||
}
|
||||
return tileColor.resolve(
|
||||
selected
|
||||
? {
|
||||
states.isHovering
|
||||
? ButtonStates.pressing
|
||||
: ButtonStates.hovering,
|
||||
states.isHovered
|
||||
? WidgetState.pressed
|
||||
: WidgetState.hovered,
|
||||
}
|
||||
: newStates,
|
||||
);
|
||||
|
@@ -214,7 +214,7 @@ class _NovelPageState extends State<NovelPage> {
|
||||
constraints: const BoxConstraints(maxWidth: 560),
|
||||
child: Card(
|
||||
margin: const EdgeInsets.only(left: 2, right: 2, bottom: 12),
|
||||
borderColor: ColorScheme.of(context).outlineVariant.withOpacity(0.52),
|
||||
borderColor: ColorScheme.of(context).outlineVariant.toOpacity(0.52),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
@@ -555,7 +555,7 @@ class _NovelSeriesWidgetState
|
||||
color: FluentTheme.of(context).cardColor,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant.withOpacity(0.6),
|
||||
color: ColorScheme.of(context).outlineVariant.toOpacity(0.6),
|
||||
width: 0.5,
|
||||
)),
|
||||
sliver: SliverMainAxisGroup(slivers: [
|
||||
|
@@ -105,12 +105,13 @@ class _SearchPageState extends State<SearchPage> {
|
||||
'${searchTypes[searchType].tl} / ${"Open link".tl}',
|
||||
onChanged: (s) => text = s,
|
||||
onSubmitted: (s) => search(),
|
||||
foregroundDecoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context)
|
||||
.outlineVariant
|
||||
.withOpacity(0.6)),
|
||||
borderRadius: BorderRadius.circular(4)),
|
||||
foregroundDecoration: WidgetStatePropertyAll(
|
||||
BoxDecoration(
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context)
|
||||
.outlineVariant
|
||||
.toOpacity(0.6)),
|
||||
borderRadius: BorderRadius.circular(4))),
|
||||
suffix: MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: GestureDetector(
|
||||
@@ -247,7 +248,7 @@ class _TrendingTagsViewState
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context)
|
||||
.micaBackgroundColor
|
||||
.withOpacity(0.84),
|
||||
.toOpacity(0.84),
|
||||
borderRadius: BorderRadius.circular(4)),
|
||||
child: Text(text)
|
||||
.paddingHorizontal(4)
|
||||
@@ -517,12 +518,16 @@ class _SearchResultPageState
|
||||
placeholder: "Search artworks".tl,
|
||||
onChanged: (s) => keyword = s,
|
||||
onSubmitted: (s) => search(),
|
||||
foregroundDecoration: BoxDecoration(
|
||||
foregroundDecoration: WidgetStatePropertyAll(
|
||||
BoxDecoration(
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context)
|
||||
.outlineVariant
|
||||
.withOpacity(0.6)),
|
||||
borderRadius: BorderRadius.circular(4)),
|
||||
color: ColorScheme.of(context)
|
||||
.outlineVariant
|
||||
.toOpacity(0.6),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
),
|
||||
suffix: MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: GestureDetector(
|
||||
@@ -709,12 +714,14 @@ class _SearchNovelResultPageState
|
||||
placeholder: "Search artworks".tl,
|
||||
onChanged: (s) => keyword = s,
|
||||
onSubmitted: (s) => search(),
|
||||
foregroundDecoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context)
|
||||
.outlineVariant
|
||||
.withOpacity(0.6)),
|
||||
borderRadius: BorderRadius.circular(4)),
|
||||
foregroundDecoration: WidgetStatePropertyAll(
|
||||
BoxDecoration(
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context)
|
||||
.outlineVariant
|
||||
.toOpacity(0.6)),
|
||||
borderRadius: BorderRadius.circular(4)),
|
||||
),
|
||||
suffix: MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: GestureDetector(
|
||||
|
Reference in New Issue
Block a user