Skip to content

Commit af347da

Browse files
committed
[#54] Add Shimmer screen
1 parent 23c3c80 commit af347da

File tree

4 files changed

+123
-1
lines changed

4 files changed

+123
-1
lines changed

lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class App extends StatelessWidget {
3232
GoRoute(
3333
path: routePathLoginScreen,
3434
pageBuilder: (_, __) => const NoTransitionPage<void>(
35-
child: LoginScreen(),
35+
child: HomeShimmerLoading(),
3636
),
3737
),
3838
GoRoute(
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:shimmer/shimmer.dart';
3+
import 'package:survey_flutter/theme/app_constants.dart';
4+
5+
const double _bottomPadding = 62;
6+
const double _rectangleHeight = 20;
7+
const double _circleSize = 36;
8+
9+
class HomeShimmerLoading extends StatelessWidget {
10+
const HomeShimmerLoading({Key? key}) : super(key: key);
11+
12+
@override
13+
Widget build(BuildContext context) {
14+
final screenWidth = MediaQuery.of(context).size.width;
15+
16+
return Shimmer.fromColors(
17+
baseColor: Colors.white.withOpacity(0.12),
18+
highlightColor: Colors.white24,
19+
child: Column(
20+
crossAxisAlignment: CrossAxisAlignment.start,
21+
children: [
22+
_buildTopRows(screenWidth),
23+
const Spacer(),
24+
_buildBottomRows(screenWidth),
25+
],
26+
),
27+
);
28+
}
29+
30+
Widget _buildTopRows(double screenWidth) {
31+
return Row(
32+
children: [
33+
Column(
34+
crossAxisAlignment: CrossAxisAlignment.start,
35+
children: [
36+
_buildShimmerText(
37+
topPadding: 61,
38+
width: screenWidth * 0.3,
39+
),
40+
_buildShimmerText(
41+
topPadding: 10,
42+
width: screenWidth * 0.25,
43+
),
44+
],
45+
),
46+
const Spacer(),
47+
Padding(
48+
padding: const EdgeInsets.only(top: 79, right: Metrics.spacing20),
49+
child: Container(
50+
width: _circleSize,
51+
height: _circleSize,
52+
decoration: const BoxDecoration(
53+
shape: BoxShape.circle,
54+
color: Colors.black,
55+
),
56+
),
57+
),
58+
],
59+
);
60+
}
61+
62+
Widget _buildShimmerText({
63+
double? topPadding,
64+
double? bottomPadding,
65+
double? width,
66+
}) {
67+
return Padding(
68+
padding: EdgeInsets.only(
69+
left: Metrics.spacing20,
70+
top: topPadding ?? 0,
71+
right: Metrics.spacing20,
72+
bottom: bottomPadding ?? 0,
73+
),
74+
child: Container(
75+
decoration: BoxDecoration(
76+
borderRadius: BorderRadius.circular(_rectangleHeight / 2),
77+
color: Colors.black,
78+
),
79+
width: width,
80+
height: _rectangleHeight,
81+
),
82+
);
83+
}
84+
85+
Widget _buildBottomRows(double screenWidth) {
86+
return Column(
87+
crossAxisAlignment: CrossAxisAlignment.start,
88+
children: [
89+
_buildShimmerText(
90+
topPadding: 0,
91+
width: screenWidth * 0.1,
92+
),
93+
_buildShimmerText(
94+
topPadding: Metrics.spacing16,
95+
width: screenWidth * 0.67,
96+
),
97+
_buildShimmerText(
98+
topPadding: Metrics.spacing10,
99+
width: screenWidth * 0.3,
100+
),
101+
_buildShimmerText(
102+
topPadding: Metrics.spacing16,
103+
width: screenWidth * 0.84,
104+
),
105+
_buildShimmerText(
106+
topPadding: Metrics.spacing10,
107+
bottomPadding: _bottomPadding,
108+
width: screenWidth * 0.5,
109+
),
110+
],
111+
);
112+
}
113+
}

pubspec.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,14 @@ packages:
732732
url: "https://pub.dev"
733733
source: hosted
734734
version: "1.0.4"
735+
shimmer:
736+
dependency: "direct main"
737+
description:
738+
name: shimmer
739+
sha256: "5f88c883a22e9f9f299e5ba0e4f7e6054857224976a5d9f839d4ebdc94a14ac9"
740+
url: "https://pub.dev"
741+
source: hosted
742+
version: "3.0.0"
735743
sky_engine:
736744
dependency: transitive
737745
description: flutter

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ dependencies:
4848
internet_connection_checker: ^1.0.0+1
4949
page_view_dot_indicator: ^2.1.0
5050
flutter_secure_storage: ^8.0.0
51+
shimmer: ^3.0.0
5152

5253
dev_dependencies:
5354
build_runner: ^2.4.4

0 commit comments

Comments
 (0)