Skip to content

Commit

Permalink
ISpect added
Browse files Browse the repository at this point in the history
  • Loading branch information
yelmuratoff committed Apr 8, 2024
1 parent 5fcf741 commit fc8d003
Show file tree
Hide file tree
Showing 167 changed files with 326 additions and 10,832 deletions.
1 change: 0 additions & 1 deletion bash/update_ios.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cd ..
cd ios
pod deintegrate
pod repo update
Expand Down
112 changes: 56 additions & 56 deletions ios/Runner.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

26 changes: 17 additions & 9 deletions lib/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import 'dart:async';

import 'package:base_starter/src/app/logic/app_runner.dart';
import 'package:base_starter/src/common/utils/global_variables.dart';
import 'package:base_starter/src/common/utils/talker_logger.dart';
import 'package:base_starter/src/feature/initialization/logic/initialization_processor.dart';
import 'package:base_starter/src/feature/initialization/model/dependencies.dart';
import 'package:base_starter/src/feature/initialization/model/initialization_hook.dart';
import 'package:base_starter/src/feature/initialization/ui/widget/initialization_failed_app.dart';
import 'package:flutter/material.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:ispect/ispect.dart';

Future<void> bootstrap() async {
InitializationHook? hook;
Expand All @@ -31,22 +31,27 @@ Future<void> bootstrap() async {
hook!,
),
(error, stackTrace) {
talker.handle(error, stackTrace);
talkerWrapper.handle(
message: error.toString(),
exception: error,
stackTrace: stackTrace,
);
},
);
}

void _onInitializing(InitializationStepInfo info) {
final percentage = ((info.step / info.stepsCount) * 100).toInt();
talker.info(
'🌀 Inited ${info.stepName} in ${info.msSpent} ms | '
'Progress: $percentage%',
talkerWrapper.info(
message: '🌀 Inited ${info.stepName} in ${info.msSpent} ms | '
'Progress: $percentage%',
);
}

void _onInitialized(InitializationResult result) {
talker
.logTyped(GoodLog('🎉 Initialization completed in ${result.msSpent} ms'));
talkerWrapper.good(
message: '🎉 Initialization completed in ${result.msSpent} ms',
);
}

void _onErrorFactory(
Expand All @@ -55,7 +60,9 @@ void _onErrorFactory(
StackTrace stackTrace,
InitializationHook hook,
) {
talker.error('❗️ Initialization failed on step $step with error: $error');
talkerWrapper.error(
message: '❗️ Initialization failed on step $step with error: $error',
);
FlutterNativeSplash.remove();
runApp(
InitializationFailedApp(
Expand All @@ -67,5 +74,6 @@ void _onErrorFactory(
}

void _onInit() {
talker.info('🚀 Initialization started');
talkerWrapper.initHandling(talker: talker);
talkerWrapper.info(message: '🚀 Initialization started');
}
4 changes: 0 additions & 4 deletions lib/src/app/logic/app_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'dart:async';
import 'package:base_starter/src/app/ui/widget/app.dart';
import 'package:base_starter/src/common/services/provider_observer.dart';
import 'package:base_starter/src/common/ui/pages/restart_wrapper.dart';
import 'package:base_starter/src/common/utils/talker_logger.dart';
import 'package:base_starter/src/feature/initialization/logic/initialization_processor.dart';
import 'package:base_starter/src/feature/initialization/logic/initialization_steps.dart';
import 'package:base_starter/src/feature/initialization/model/initialization_hook.dart';
Expand All @@ -30,9 +29,6 @@ final class AppRunner
// Preserve splash screen
FlutterNativeSplash.preserve(widgetsBinding: binding);

// Override logging
await initHandling();

// Setup bloc observer and transformer
Bloc.transformer = bloc_concurrency.sequential();
Future<void> initializeAndRun(InitializationHook hook) async {
Expand Down
26 changes: 0 additions & 26 deletions lib/src/app/router/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

import 'package:base_starter/src/app/ui/page/root.dart';
import 'package:base_starter/src/common/ui/pages/error_router_page.dart';
import 'package:base_starter/src/common/utils/extensions/context_extension.dart';
import 'package:base_starter/src/common/utils/global_variables.dart';
import 'package:base_starter/src/feature/auth/ui/page/auth.dart';
import 'package:base_starter/src/feature/home/ui/page/home.dart';
import 'package:base_starter/src/feature/initialization/ui/page/splash.dart';
import 'package:base_starter/src/feature/ispect/ispect_page.dart';
import 'package:base_starter/src/feature/settings/ui/settings.dart';
import 'package:flutter/cupertino.dart';
import 'package:go_router/go_router.dart';
import 'package:talker_flutter/talker_flutter.dart';

export 'package:go_router/go_router.dart';

Expand Down Expand Up @@ -131,29 +128,6 @@ GoRouter createRouter = GoRouter(
child: SettingsPage(),
),
),
GoRoute(
name: ISpectPage.name,
path: ISpectPage.routePath,
pageBuilder: (context, pathParameters) {
final Map<String, dynamic>? args =
pathParameters.extra as Map<String, dynamic>?;
return CupertinoPage(
child: ISpectPage(
appBarTitle: args?[ISpectPage.paramTitle] as String?,
theme: args?[ISpectPage.paramTheme]
as TalkerScreenTheme? ??
TalkerScreenTheme(
backgroundColor:
context.theme.colorScheme.background,
textColor: context.colors.text,
cardColor: context.colors.card,
),
itemsBuilder: args?[ISpectPage.paramItemBuilder]
as Widget Function(BuildContext, TalkerData)?,
),
);
},
),
],
),
],
Expand Down
63 changes: 3 additions & 60 deletions lib/src/app/ui/page/root.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import 'package:base_starter/src/app/router/router.dart';
import 'package:base_starter/src/common/ui/widgets/other/feedback_body.dart';
import 'package:base_starter/src/core/localization/localization.dart';
import 'package:base_starter/src/feature/settings/state/app_config.dart';
import 'package:base_starter/src/feature/settings/ui/settings.dart';
import 'package:feedback_plus/feedback_plus.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:inspector/inspector.dart';

part 'view/root_view.dart';

Expand All @@ -27,58 +21,7 @@ class _RootPageState extends ConsumerState<RootPage> {
}

@override
Widget build(BuildContext context) {
final theme = SettingsScope.of(context).theme;
final locale = SettingsScope.of(context).locale;
final appConfigState = ref.watch(appConfigsProvider);
return Inspector(
isPanelVisible: appConfigState.isInspectorEnabled,
backgroundColor: theme.computeTheme().colorScheme.background,
selectedColor: theme.computeTheme().colorScheme.primaryContainer,
textColor: theme.computeTheme().colorScheme.onBackground,
selectedTextColor: theme.computeTheme().colorScheme.primaryContainer,
child: BetterFeedback(
themeMode: theme.mode,
localizationsDelegates: Localization.localizationDelegates,
localeOverride: locale,
theme: FeedbackThemeData(
background: Colors.grey[800]!,
feedbackSheetColor: theme.lightTheme.colorScheme.surface,
activeFeedbackModeColor: theme.lightTheme.colorScheme.primary,
cardColor: theme.lightTheme.scaffoldBackgroundColor,
bottomSheetDescriptionStyle:
theme.lightTheme.textTheme.bodyMedium!.copyWith(
color: Colors.grey[800],
),
dragHandleColor: Colors.grey[400],
inactiveColor: Colors.grey[700]!,
textColor: Colors.grey[800]!,
),
darkTheme: FeedbackThemeData(
background: Colors.grey[800]!,
feedbackSheetColor: theme.darkTheme.colorScheme.surface,
activeFeedbackModeColor: theme.darkTheme.colorScheme.primary,
cardColor: theme.darkTheme.scaffoldBackgroundColor,
bottomSheetDescriptionStyle:
theme.lightTheme.textTheme.bodyMedium!.copyWith(
color: Colors.grey[300],
),
dragHandleColor: Colors.grey[400],
inactiveColor: Colors.grey[600]!,
textColor: Colors.grey[300]!,
),
mode: FeedbackMode.navigate,
feedbackBuilder: (context, extras, scrollController) =>
simpleFeedbackBuilder(
context,
extras,
scrollController,
theme.computeTheme(),
),
child: _RootView(
widget.navigationShell,
),
),
);
}
Widget build(BuildContext context) => _RootView(
widget.navigationShell,
);
}
17 changes: 8 additions & 9 deletions lib/src/app/ui/widget/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import 'package:base_starter/src/app/router/router.dart';
import 'package:base_starter/src/app/ui/widget/material_context.dart';
import 'package:base_starter/src/common/configs/constants.dart';
import 'package:base_starter/src/common/services/router_service.dart';
import 'package:base_starter/src/common/utils/global_variables.dart';
import 'package:base_starter/src/common/utils/talker_logger.dart';
import 'package:base_starter/src/feature/initialization/logic/base_config.dart';
import 'package:base_starter/src/feature/initialization/model/dependencies.dart';
import 'package:base_starter/src/feature/initialization/model/environment.dart';
Expand All @@ -12,6 +10,7 @@ import 'package:base_starter/src/feature/initialization/ui/widget/environment_sc
import 'package:base_starter/src/feature/settings/ui/settings.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:ispect/ispect.dart';

/// [App] is an entry point to the application.
///
Expand All @@ -37,24 +36,23 @@ class App extends StatefulWidget {
}

class _AppState extends State<App> {
final ISpectController controller = ISpectController();
late final GoRouter _router;
String? _environmentKey;

@override
void initState() {
_router = createRouter;
talker.logTyped(GoodLog('📱 App started'));
talker.logTyped(
RouteLog(_router.configuration.debugKnownRoutes()),
talkerWrapper.good(message: '📱 App started');
talkerWrapper.route(
message: _router.configuration.debugKnownRoutes(),
);
_router.routerDelegate.addListener(() {
final String location =
_router.routerDelegate.currentConfiguration.last.matchedLocation;
routerService.setRoute(location);
talker.logTyped(
RouteLog(
location,
),
talkerWrapper.route(
message: location,
);
});
_environmentKey = widget.result.dependencies.sharedPreferences
Expand All @@ -79,6 +77,7 @@ class _AppState extends State<App> {
settingsBloc: widget.result.dependencies.settingsBloc,
child: MaterialContext(
routerConfig: _router,
controller: controller,
),
),
),
Expand Down
75 changes: 41 additions & 34 deletions lib/src/app/ui/widget/material_context.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import 'package:base_starter/src/app/router/router.dart';
import 'package:base_starter/src/common/ui/widgets/builder/performance_builder.dart';
import 'package:base_starter/src/common/ui/widgets/draggable_button.dart';
import 'package:base_starter/src/common/utils/global_variables.dart';
import 'package:base_starter/src/core/localization/localization.dart';
import 'package:base_starter/src/feature/initialization/ui/widget/environment_scope.dart';
import 'package:base_starter/src/feature/settings/state/app_config.dart';
import 'package:base_starter/src/feature/settings/ui/settings.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:ispect/ispect.dart';

/// [MaterialContext] is an entry point to the material context.
/// This widget sets locales, themes and routing.
class MaterialContext extends ConsumerWidget {
const MaterialContext({required this.routerConfig, super.key});
const MaterialContext({
required this.routerConfig,
required this.controller,
super.key,
});

final GoRouter routerConfig;
final ISpectController controller;

// This global key is needed for [MaterialApp]
// to work properly when Widgets Inspector is enabled.
Expand All @@ -26,40 +30,43 @@ class MaterialContext extends ConsumerWidget {
final theme = SettingsScope.themeOf(context).theme;
final locale = SettingsScope.localeOf(context).locale;
final config = EnvironmentScope.of(context);
final appConfigState = ref.watch(appConfigsProvider);

return PerformanceOverlayBuilder(
config: config,
appConfigState: appConfigState,
theme: theme,
child: MaterialApp.router(
key: _globalKey,
title: config.appName,
onGenerateTitle: (context) => config.appName,
theme: theme.lightTheme,
darkTheme: theme.darkTheme,
themeMode: theme.mode,
localizationsDelegates: Localization.localizationDelegates,
supportedLocales: Localization.supportedLocales,
locale: locale,
routerConfig: routerConfig,
builder: (context, child) {
child = EasyLoading.init()(context, child);
return MaterialApp.router(
key: _globalKey,
title: config.appName,
onGenerateTitle: (context) => config.appName,
theme: theme.lightTheme,
darkTheme: theme.darkTheme,
themeMode: theme.mode,
localizationsDelegates: Localization.localizationDelegates,
supportedLocales: Localization.supportedLocales,
locale: locale,
routerConfig: routerConfig,
builder: (context, child) {
child = EasyLoading.init()(context, child);

child = MediaQuery.withClampedTextScaling(
minScaleFactor: 1.0,
maxScaleFactor: 2.0,
child: child,
);
child = MediaQuery.withClampedTextScaling(
minScaleFactor: 1.0,
maxScaleFactor: 2.0,
child: child,
);

child = DraggableButton(
child: child,
);
child = ISpectWrapper(
navigatorKey: navigatorKey,
options: ISpectOptions(
talker: talker,
themeMode: theme.mode,
lightTheme: theme.lightTheme,
darkTheme: theme.darkTheme,
locale: locale,
controller: controller,
),
child: child,
);

child = FToastBuilder()(context, child);
return child;
},
),
child = FToastBuilder()(context, child);
return child;
},
);
}
}
Loading

0 comments on commit fc8d003

Please sign in to comment.