Skip to content

Commit

Permalink
refactor: replace state management library (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
BBarisKilic authored Dec 3, 2023
2 parents e51c732 + 3a7f181 commit 96efdaf
Show file tree
Hide file tree
Showing 61 changed files with 2,051 additions and 1,502 deletions.
10 changes: 10 additions & 0 deletions assets/images/error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
122 changes: 0 additions & 122 deletions lib/app/widgets/app.dart

This file was deleted.

26 changes: 24 additions & 2 deletions lib/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ import 'dart:developer';
import 'package:bloc/bloc.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:get_it/get_it.dart';
import 'package:launch_review_service/launch_review_service.dart';
import 'package:url_launcher_service/url_launcher_service.dart';
import 'package:vmerge/utilities/utilities.dart';
import 'package:wechat_assets_picker/wechat_assets_picker.dart';

final getIt = GetIt.instance;

class AppBlocObserver extends BlocObserver {
const AppBlocObserver();

Expand All @@ -36,8 +42,24 @@ Future<void> bootstrap(FutureOr<Widget> Function() builder) async {
final widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
// FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
await PhotoManager.clearFileCache();

await Future.wait(
[
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]),
PhotoManager.clearFileCache(),
setup(),
],
).onError((error, stackTrace) => [log('$error', stackTrace: stackTrace)]);

runApp(await builder());
}

Future<void> setup() async {
getIt
..registerLazySingleton<LaunchReviewService>(
() => const LaunchReviewService(androidAppId: kAndroidAppId),
)
..registerLazySingleton<UrlLauncherService>(
() => const UrlLauncherService(),
);
}
83 changes: 83 additions & 0 deletions lib/components/animated_control_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright 2023 BBK Development. All rights reserved.
// Use of this source code is governed by a GPL-style license that can be found
// in the LICENSE file.

import 'package:flutter/material.dart';

class AnimatedControlButtonController {
late void Function() forward;
late void Function() reverse;
}

class AnimatedControlButton extends StatefulWidget {
const AnimatedControlButton({
required this.controller,
this.onTap,
this.size = 32.0,
super.key,
});

final AnimatedControlButtonController controller;
final void Function()? onTap;
final double size;

@override
State<AnimatedControlButton> createState() => _AnimatedControlButtonState();
}

class _AnimatedControlButtonState extends State<AnimatedControlButton>
with TickerProviderStateMixin {
late final AnimationController controller;

@override
void initState() {
super.initState();
controller = AnimationController(
duration: const Duration(milliseconds: 500),
vsync: this,
);
initController();
}

@override
void dispose() {
controller.dispose();
super.dispose();
}

void initController() {
widget.controller.forward = () async {
if (mounted) {
await controller.forward();
}
};

widget.controller.reverse = () async {
if (mounted) {
await controller.reverse();
}
};
}

@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: widget.onTap,
child: Container(
height: MediaQuery.of(context).size.width * 0.12,
width: MediaQuery.of(context).size.width * 0.12,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).focusColor,
),
child: Center(
child: AnimatedIcon(
icon: AnimatedIcons.play_pause,
progress: controller,
size: widget.size,
),
),
),
);
}
}
4 changes: 1 addition & 3 deletions lib/components/components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
// Use of this source code is governed by a GPL-style license that can be found
// in the LICENSE file.

export 'save_modal_bottom_sheet.dart';
export 'settings_modal_bottom_sheet.dart';
export 'video_thumbnail.dart';
export 'animated_control_button.dart';
export 'vmerge_app_bar.dart';
115 changes: 0 additions & 115 deletions lib/components/save_modal_bottom_sheet.dart

This file was deleted.

Loading

0 comments on commit 96efdaf

Please sign in to comment.