diff --git a/lib/common_ui/theme/my_theme.dart b/lib/common_ui/theme/my_theme.dart index d59c6b9..a4f6ad8 100644 --- a/lib/common_ui/theme/my_theme.dart +++ b/lib/common_ui/theme/my_theme.dart @@ -1,10 +1,17 @@ import 'package:flutter/material.dart'; +import 'package:hadi_hoda_flutter/common_ui/resources/my_colors.dart'; class MyTheme { static const MyTheme _i = MyTheme._internal(); const MyTheme._internal(); factory MyTheme() => _i; - static final ThemeData light = ThemeData(brightness: Brightness.light); - static final ThemeData dark = ThemeData(brightness: Brightness.dark); + static final ThemeData light = ThemeData( + brightness: Brightness.light, + scaffoldBackgroundColor: MyColors.purple, + ); + static final ThemeData dark = ThemeData( + brightness: Brightness.dark, + scaffoldBackgroundColor: MyColors.purple, + ); } \ No newline at end of file diff --git a/lib/features/intro/presentation/bloc/intro_bloc.dart b/lib/features/intro/presentation/bloc/intro_bloc.dart index 34eb70c..4a4695d 100644 --- a/lib/features/intro/presentation/bloc/intro_bloc.dart +++ b/lib/features/intro/presentation/bloc/intro_bloc.dart @@ -20,6 +20,7 @@ class IntroBloc extends Bloc { /// ------------constructor------------ IntroBloc() : super(const IntroState()) { initVideos(); + listenController(); on(_initVideosEvent); on(_changeVideosEvent); } @@ -70,6 +71,27 @@ class IntroBloc extends Bloc { } } + void listenController() { + // A helper function to check for video completion + void _onVideoEnd(PodPlayerController controller, int controllerIndex) { + final position = controller.videoPlayerValue?.position; + final duration = controller.videoPlayerValue?.duration; + + if (position != null && duration != null && position >= duration) { + // Only trigger the change if the completed video is the current one + if (state.currentIntro == controllerIndex) { + add(ChangeVideosEvent()); + } + } + } + + podController1.addListener(() => _onVideoEnd(podController1, 0)); + podController2.addListener(() => _onVideoEnd(podController2, 1)); + podController3.addListener(() => _onVideoEnd(podController3, 2)); + podController4.addListener(() => _onVideoEnd(podController4, 3)); + podController5.addListener(() => _onVideoEnd(podController5, 4)); + } + /// ------------Api Calls------------ FutureOr _changeVideosEvent(ChangeVideosEvent event, Emitter emit) async { switch (state.currentIntro) {