Skip to content

Commit cb84814

Browse files
authored
Restructure project layout (#185)
1 parent 1bb9a18 commit cb84814

27 files changed

+142
-130
lines changed

current_results_ui/lib/main.dart

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44

55
import 'package:firebase_core/firebase_core.dart';
66
import 'package:flutter/material.dart';
7-
import 'package:provider/provider.dart';
87

9-
import 'firebase_options.dart';
10-
import 'src/auth_service.dart';
11-
import 'src/platform_specific/url_strategy_stub.dart'
12-
if (dart.library.js_interop) 'src/platform_specific/url_strategy_web.dart';
13-
import 'src/routing.dart';
8+
import 'src/app/app.dart';
9+
import 'src/app/firebase_options.dart';
10+
import 'src/shared/platform/url_strategy_stub.dart'
11+
if (dart.library.js_interop) 'src/shared/platform/url_strategy_web.dart';
1412

1513
Future<void> main() async {
1614
WidgetsFlutterBinding.ensureInitialized();
@@ -25,50 +23,3 @@ Future<void> main() async {
2523
runApp(FirebaseErrorApp(error: e.toString()));
2624
}
2725
}
28-
29-
class FirebaseErrorApp extends StatelessWidget {
30-
final String error;
31-
const FirebaseErrorApp({super.key, required this.error});
32-
33-
@override
34-
Widget build(BuildContext context) {
35-
return MaterialApp(
36-
home: Scaffold(
37-
appBar: AppBar(title: const Text('Initialization Error')),
38-
body: Center(
39-
child: Padding(
40-
padding: const EdgeInsets.all(16.0),
41-
child: SelectionArea(
42-
child: Text(
43-
'Failed to initialize Firebase. Please check your configuration and ensure you have added the necessary platform-specific setup.\n\nError: $error',
44-
textAlign: TextAlign.center,
45-
style: TextStyle(color: Colors.red, fontSize: 16),
46-
),
47-
),
48-
),
49-
),
50-
),
51-
);
52-
}
53-
}
54-
55-
final _router = createRouter();
56-
57-
class CurrentResultsApp extends StatelessWidget {
58-
const CurrentResultsApp({super.key});
59-
60-
@override
61-
Widget build(BuildContext context) {
62-
return ChangeNotifierProvider<AuthService>(
63-
create: (_) => AuthService(),
64-
child: MaterialApp.router(
65-
title: 'Current Results',
66-
theme: ThemeData(
67-
primarySwatch: Colors.blue,
68-
visualDensity: VisualDensity.compact,
69-
),
70-
routerConfig: _router,
71-
),
72-
);
73-
}
74-
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'package:flutter/material.dart';
6+
import 'package:provider/provider.dart';
7+
8+
import 'app_router.dart';
9+
import 'auth_service.dart';
10+
11+
class FirebaseErrorApp extends StatelessWidget {
12+
final String error;
13+
const FirebaseErrorApp({super.key, required this.error});
14+
15+
@override
16+
Widget build(BuildContext context) {
17+
return MaterialApp(
18+
home: Scaffold(
19+
appBar: AppBar(title: const Text('Initialization Error')),
20+
body: Center(
21+
child: Padding(
22+
padding: const EdgeInsets.all(16.0),
23+
child: SelectionArea(
24+
child: Text(
25+
'Failed to initialize Firebase. Please check your configuration and ensure you have added the necessary platform-specific setup.\n\nError: $error',
26+
textAlign: TextAlign.center,
27+
style: TextStyle(color: Colors.red, fontSize: 16),
28+
),
29+
),
30+
),
31+
),
32+
),
33+
);
34+
}
35+
}
36+
37+
final _router = createRouter();
38+
39+
class CurrentResultsApp extends StatelessWidget {
40+
const CurrentResultsApp({super.key});
41+
42+
@override
43+
Widget build(BuildContext context) {
44+
return ChangeNotifierProvider<AuthService>(
45+
create: (_) => AuthService(),
46+
child: MaterialApp.router(
47+
title: 'Current Results',
48+
theme: ThemeData(
49+
primarySwatch: Colors.blue,
50+
visualDensity: VisualDensity.compact,
51+
),
52+
routerConfig: _router,
53+
),
54+
);
55+
}
56+
}

current_results_ui/lib/src/routing.dart renamed to current_results_ui/lib/src/app/app_router.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import 'package:flutter/material.dart';
66
import 'package:go_router/go_router.dart';
77
import 'package:provider/provider.dart';
88

9-
import '../filter.dart';
10-
import '../query.dart';
11-
import '../src/widgets/results_view.dart';
12-
import '../try_results_screen.dart';
13-
import 'data/try_query_results.dart';
9+
import '../data/models/filter.dart';
10+
import '../features/results_overview/data/results_repository.dart';
11+
import '../features/try_results/data/try_results_repository.dart';
12+
import '../features/try_results/widgets/try_results_screen.dart';
13+
import '../shared/widgets/results_view.dart';
1414

1515
typedef QueryResultsFactory = QueryResultsBase Function(Filter filter);
1616
typedef TryQueryResultsFactory =
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of a source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'package:collection/collection.dart';
6+
7+
class Filter {
8+
final List<String> terms;
9+
Filter(String termString) : terms = _parse(termString);
10+
11+
static List<String> _parse(String termString) {
12+
if (termString.trim() == '') return List.unmodifiable([]);
13+
return List.unmodifiable(termString.split(',').map((s) => s.trim()));
14+
}
15+
16+
@override
17+
bool operator ==(Object other) =>
18+
other is Filter && const ListEquality().equals(terms, other.terms);
19+
20+
@override
21+
int get hashCode => const ListEquality().hash(terms);
22+
}

0 commit comments

Comments
 (0)