♻️ Refactor router, moved from auto_router to go_router

This commit is contained in:
2025-06-26 14:13:44 +08:00
parent 825e6b5b6d
commit f2829b2012
67 changed files with 587 additions and 2876 deletions

View File

@ -1,4 +1,3 @@
import 'package:auto_route/auto_route.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
@ -40,10 +39,9 @@ sealed class PostComposeInitialState with _$PostComposeInitialState {
_$PostComposeInitialStateFromJson(json);
}
@RoutePage()
class PostEditScreen extends HookConsumerWidget {
final String id;
const PostEditScreen({super.key, @PathParam('id') required this.id});
const PostEditScreen({super.key, required this.id});
@override
Widget build(BuildContext context, WidgetRef ref) {
@ -66,7 +64,6 @@ class PostEditScreen extends HookConsumerWidget {
}
}
@RoutePage()
class PostComposeScreen extends HookConsumerWidget {
final SnPost? originalPost;
final SnPost? repliedPost;
@ -78,7 +75,7 @@ class PostComposeScreen extends HookConsumerWidget {
this.originalPost,
this.repliedPost,
this.forwardedPost,
@QueryParam('type') this.type,
this.type,
this.initialState,
});

View File

@ -26,7 +26,6 @@ $PostComposeInitialStateCopyWith<PostComposeInitialState> get copyWith => _$Post
/// Serializes this PostComposeInitialState to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is PostComposeInitialState&&(identical(other.title, title) || other.title == title)&&(identical(other.description, description) || other.description == description)&&(identical(other.content, content) || other.content == content)&&const DeepCollectionEquality().equals(other.attachments, attachments)&&(identical(other.visibility, visibility) || other.visibility == visibility));
@ -41,7 +40,6 @@ String toString() {
return 'PostComposeInitialState(title: $title, description: $description, content: $content, attachments: $attachments, visibility: $visibility)';
}
}
/// @nodoc
@ -52,9 +50,6 @@ $Res call({
String? title, String? description, String? content, List<UniversalFile> attachments, int? visibility
});
}
/// @nodoc
class _$PostComposeInitialStateCopyWithImpl<$Res>
@ -79,7 +74,6 @@ as int?,
}
/// @nodoc
@JsonSerializable()
@ -124,7 +118,6 @@ String toString() {
return 'PostComposeInitialState(title: $title, description: $description, content: $content, attachments: $attachments, visibility: $visibility)';
}
}
/// @nodoc
@ -135,9 +128,6 @@ $Res call({
String? title, String? description, String? content, List<UniversalFile> attachments, int? visibility
});
}
/// @nodoc
class __$PostComposeInitialStateCopyWithImpl<$Res>
@ -160,7 +150,6 @@ as int?,
));
}
}
// dart format on

View File

@ -1,6 +1,5 @@
import 'dart:async';
import 'package:auto_route/auto_route.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@ -26,10 +25,9 @@ import 'package:island/widgets/post/draft_manager.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:styled_widget/styled_widget.dart';
@RoutePage()
class ArticleEditScreen extends HookConsumerWidget {
final String id;
const ArticleEditScreen({super.key, @PathParam('id') required this.id});
const ArticleEditScreen({super.key, required this.id});
@override
Widget build(BuildContext context, WidgetRef ref) {
@ -50,7 +48,6 @@ class ArticleEditScreen extends HookConsumerWidget {
}
}
@RoutePage()
class ArticleComposeScreen extends HookConsumerWidget {
final SnPost? originalPost;

View File

@ -1,4 +1,3 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
@ -22,10 +21,9 @@ Future<SnPost?> post(Ref ref, String id) async {
return SnPost.fromJson(resp.data);
}
@RoutePage()
class PostDetailScreen extends HookConsumerWidget {
final String id;
const PostDetailScreen({super.key, @PathParam('id') required this.id});
const PostDetailScreen({super.key, required this.id});
@override
Widget build(BuildContext context, WidgetRef ref) {

View File

@ -1,6 +1,6 @@
import 'package:auto_route/auto_route.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:gap/gap.dart';
@ -67,12 +67,11 @@ Future<Color?> publisherAppbarForcegroundColor(Ref ref, String pubName) async {
return dominantColor.computeLuminance() > 0.5 ? Colors.black : Colors.white;
}
@RoutePage()
class PublisherProfileScreen extends HookConsumerWidget {
final String name;
const PublisherProfileScreen({
super.key,
@PathParam("name") required this.name,
required this.name,
});
@override
@ -186,7 +185,7 @@ class PublisherProfileScreen extends HookConsumerWidget {
),
onTap: () {
Navigator.pop(context, true);
context.router.pushPath('/account/${data.name}');
context.push('/account/${data.name}');
},
),
Expanded(