mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-08-23 17:13:54 +08:00

Instead we're going to move back to standard exceptions. Using a custom Result class has created far far more problems - The Stacktraces aren't always right - Sometimes one forgets to check the Result error - All other exception throwing code needing to be converted to Results - Non idiomatic Dart code I think it's better to just go back to exceptions. They have their problems, but overall, I think it's a better approach.
106 lines
3.0 KiB
Dart
106 lines
3.0 KiB
Dart
/*
|
|
* SPDX-FileCopyrightText: 2023 Vishesh Handa <me@vhanda.in>
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
// ignore_for_file: depend_on_referenced_packages
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:gitjournal/app_router.dart';
|
|
import 'package:gitjournal/change_notifiers.dart';
|
|
import 'package:gitjournal/l10n.dart';
|
|
import 'package:gitjournal/logger/logger.dart';
|
|
import 'package:gitjournal/repository_manager.dart';
|
|
import 'package:gitjournal/screens.dart';
|
|
import 'package:gitjournal/settings/app_config.dart';
|
|
import 'package:gitjournal/settings/settings.dart';
|
|
import 'package:gitjournal/themes.dart';
|
|
import 'package:path_provider/path_provider.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:widgetbook/widgetbook.dart';
|
|
|
|
Future<void> main() async {
|
|
//TestWidgetsFlutterBinding.ensureInitialized();
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
// SharedPreferences.setMockInitialValues({});
|
|
|
|
var pref = await SharedPreferences.getInstance();
|
|
|
|
AppConfig.instance.load(pref);
|
|
|
|
var appConfig = AppConfig.instance;
|
|
Log.i("AppConfig ${appConfig.toMap()}");
|
|
|
|
final gitBaseDirectory = (await getTemporaryDirectory()).path;
|
|
final cacheDir = (await getTemporaryDirectory()).path;
|
|
|
|
var repoManager = RepositoryManager(
|
|
gitBaseDir: gitBaseDirectory,
|
|
cacheDir: cacheDir,
|
|
pref: pref,
|
|
);
|
|
await repoManager.buildActiveRepository();
|
|
var repo = repoManager.currentRepo!;
|
|
var settings = repo.settings;
|
|
var storageConfig = repo.storageConfig;
|
|
var appRouter = AppRouter(
|
|
settings: settings,
|
|
appConfig: appConfig,
|
|
storageConfig: storageConfig,
|
|
);
|
|
|
|
var buildAppDeps = (BuildContext context, Widget child) {
|
|
return GitJournalChangeNotifiers(
|
|
repoManager: repoManager,
|
|
appConfig: appConfig,
|
|
pref: pref,
|
|
child: child,
|
|
);
|
|
};
|
|
|
|
var widgetBook = Widgetbook(
|
|
localizationsDelegates: gitJournalLocalizationDelegates,
|
|
supportedLocales: gitJournalSupportedLocales,
|
|
categories: [
|
|
buildWidgetbookCategory("Screens", allScreens, buildAppDeps),
|
|
WidgetbookCategory(
|
|
name: 'Router',
|
|
widgets: [
|
|
WidgetbookComponent(
|
|
name: "All Components",
|
|
isExpanded: true,
|
|
useCases: [
|
|
for (var routeName in AppRoute.all)
|
|
WidgetbookUseCase(
|
|
name: routeName,
|
|
builder: (_) => appRouter.screenForRoute(
|
|
routeName, repo, storageConfig, "", [], () {})!),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
appInfo: AppInfo(name: 'GitJournal'),
|
|
themes: [
|
|
WidgetbookTheme(
|
|
name: 'Light',
|
|
data: Themes.fromName(DEFAULT_LIGHT_THEME_NAME),
|
|
),
|
|
WidgetbookTheme(
|
|
name: 'Dark',
|
|
data: Themes.fromName(DEFAULT_DARK_THEME_NAME),
|
|
),
|
|
],
|
|
devices: const [
|
|
Apple.iPhone13Mini,
|
|
Apple.iPhone11,
|
|
Apple.iPhone8Plus,
|
|
Samsung.s21ultra,
|
|
],
|
|
);
|
|
|
|
runApp(widgetBook);
|
|
}
|