Line data Source code
1 : // Copyright 2023 The terCAD team. All rights reserved.
2 : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
3 :
4 : import 'package:app_finance/_ext/build_context_ext.dart';
5 : import 'package:material_ui/material_ui.dart';
6 :
7 : class LoadingWidget extends StatefulWidget {
8 : final bool isLoading;
9 : final Size? size;
10 :
11 1 : const LoadingWidget({
12 : super.key,
13 : required this.isLoading,
14 : this.size,
15 : });
16 :
17 0 : @override
18 0 : LoadingWidgetState createState() => LoadingWidgetState();
19 : }
20 :
21 : class LoadingWidgetState extends State<LoadingWidget> with TickerProviderStateMixin {
22 : late AnimationController _controller;
23 :
24 0 : @override
25 : void initState() {
26 0 : _controller = AnimationController(
27 : vsync: this,
28 : duration: const Duration(seconds: 2),
29 0 : )..repeat();
30 0 : super.initState();
31 : }
32 :
33 0 : @override
34 : void dispose() {
35 0 : _controller.dispose();
36 0 : super.dispose();
37 : }
38 :
39 0 : @override
40 : Widget build(BuildContext context) {
41 0 : Size side = widget.size ?? MediaQuery.sizeOf(context);
42 0 : double width = side.width;
43 0 : double height = side.height;
44 0 : double size = (height > width ? width : height) * 0.6;
45 0 : return AnimatedBuilder(
46 0 : animation: _controller,
47 0 : builder: (context, child) {
48 0 : return Center(
49 0 : child: Stack(
50 : alignment: Alignment.center,
51 0 : children: [
52 0 : SizedBox(
53 : height: size,
54 : width: size,
55 0 : child: CircularProgressIndicator(
56 0 : value: _controller.value,
57 0 : color: context.colorScheme.inversePrimary,
58 : strokeWidth: 8,
59 : ),
60 : ),
61 0 : Image.asset(
62 : 'assets/images/logo.png',
63 : width: size,
64 : height: size,
65 : ),
66 : ],
67 : ),
68 : );
69 : },
70 : );
71 : }
72 : }
|