refactor(apps): 主题系统迁移至 ColorScheme + 扩展架构并支持 Dark Mode

This commit is contained in:
qzl
2026-03-27 19:07:39 +08:00
parent ecc1ec6ce4
commit ae29a8209b
146 changed files with 4301 additions and 3200 deletions
@@ -0,0 +1,105 @@
import 'package:dio/dio.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:social_app/app/di/injection.dart';
import 'package:social_app/app/router/app_router.dart';
import 'package:social_app/app/router/app_routes.dart';
import 'package:social_app/core/network/i_api_client.dart';
import 'package:social_app/features/chat/presentation/bloc/chat_bloc.dart';
import 'package:social_app/features/auth/presentation/bloc/auth_state.dart';
void main() {
setUp(() async {
if (sl.isRegistered<ChatBloc>()) {
await sl.unregister<ChatBloc>();
}
sl.registerSingleton<ChatBloc>(ChatBloc(apiClient: _FakeApiClient()));
});
tearDown(() async {
if (sl.isRegistered<ChatBloc>()) {
await sl.unregister<ChatBloc>();
}
});
group('resolveAuthRedirect', () {
test('redirects unauthenticated home access to login', () {
final result = resolveAuthRedirect(
authState: const AuthUnauthenticated(),
matchedLocation: AppRoutes.homeMain,
);
expect(result, AppRoutes.authLogin);
});
test('redirects authenticated login access to home', () {
final result = resolveAuthRedirect(
authState: const AuthAuthenticated(
user: AuthUser(id: 'u1', phone: '13800138000'),
),
matchedLocation: AppRoutes.authLogin,
);
expect(result, AppRoutes.homeMain);
});
test('redirects auth checking state to boot route', () {
final result = resolveAuthRedirect(
authState: AuthLoading(),
matchedLocation: AppRoutes.homeMain,
);
expect(result, AppRoutes.authBoot);
});
test('redirects boot route to login for unauthenticated state', () {
final result = resolveAuthRedirect(
authState: const AuthUnauthenticated(),
matchedLocation: AppRoutes.authBoot,
);
expect(result, AppRoutes.authLogin);
});
});
test('home route screen is wrapped with ChatBloc provider', () {
final widget = buildHomeRouteScreen();
expect(widget, isA<BlocProvider<ChatBloc>>());
});
}
class _FakeApiClient implements IApiClient {
@override
Future<Response<T>> delete<T>(String path, {data, Options? options}) {
throw UnimplementedError();
}
@override
Future<Response<T>> get<T>(String path, {Options? options}) {
throw UnimplementedError();
}
@override
Future<Stream<String>> getSseLines(
String path, {
Map<String, String>? headers,
}) {
throw UnimplementedError();
}
@override
Future<Response<T>> patch<T>(String path, {data, Options? options}) {
throw UnimplementedError();
}
@override
Future<Response<T>> post<T>(String path, {data, Options? options}) {
throw UnimplementedError();
}
@override
Future<Response<T>> put<T>(String path, {data, Options? options}) {
throw UnimplementedError();
}
}