Skip to content

Commit

Permalink
smooth loader
Browse files Browse the repository at this point in the history
  • Loading branch information
mirmoktadir committed Feb 3, 2023
1 parent 17b1475 commit 0c6ddb3
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 59 deletions.
1 change: 1 addition & 0 deletions animations/nodata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"v":"5.8.0","fr":60,"ip":0,"op":121,"w":500,"h":500,"nm":"Comp 1","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":3,"nm":"Null 1","sr":1,"ks":{"o":{"a":0,"k":0,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":0,"s":[250,245,0],"to":[0,1.667,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":60,"s":[250,255,0],"to":[0,0,0],"ti":[0,1.667,0]},{"t":120,"s":[250,245,0]}],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"ip":0,"op":121,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"face","parent":1,"sr":1,"ks":{"o":{"a":0,"k":50,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.748,"y":0},"t":30,"s":[0,0,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.352,"y":1},"o":{"x":0.178,"y":0},"t":45,"s":[8,0,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.491,"y":1},"o":{"x":0.077,"y":0},"t":60,"s":[-8,0,0],"to":[0,0,0],"ti":[-1.333,0,0]},{"i":{"x":0.491,"y":1},"o":{"x":0.333,"y":0},"t":73,"s":[3,0,0],"to":[1.333,0,0],"ti":[0.5,0,0]},{"t":84,"s":[0,0,0]}],"ix":2,"l":2},"a":{"a":0,"k":[250,250,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0.964,0],[0.926,1.269],[-2.109,1.537],[-12.421,0],[-9.638,-6.507],[1.46,-2.163],[2.164,1.463],[9.78,0],[8.382,-6.108]],"o":[[-1.46,0],[-1.537,-2.109],[10.009,-7.294],[11.67,0],[2.163,1.46],[-1.458,2.163],[-8.071,-5.448],[-10.408,0],[-0.84,0.612]],"v":[[-30.712,9.847],[-34.536,7.904],[-33.499,1.302],[0.788,-9.847],[33.361,0.099],[34.633,6.66],[28.073,7.932],[0.788,-0.396],[-27.934,8.941]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.38823529411764707,0.43137254901960786,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tr","p":{"a":0,"k":[250,273.902],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":1,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-5.22],[5.22,0],[0,5.22],[-5.22,0]],"o":[[0,5.22],[-5.22,0],[0,-5.22],[5.22,0]],"v":[[9.451,0],[0,9.451],[-9.451,0],[0,-9.451]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.38823529411764707,0.43137254901960786,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[212.197,225.702],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-5.22],[5.22,0],[0,5.22],[-5.22,0]],"o":[[0,5.22],[-5.22,0],[0,-5.22],[5.22,0]],"v":[[9.451,0],[0,9.451],[-9.451,0],[0,-9.451]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.38823529411764707,0.43137254901960786,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[287.803,225.702],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 2","np":2,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false},{"ty":"tr","p":{"a":0,"k":[287.803,225.702],"ix":2},"a":{"a":0,"k":[287.803,225.702],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 2","np":2,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":121,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"magnification glass","parent":1,"sr":1,"ks":{"o":{"a":0,"k":50,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[27,24,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[14.17,-15.84],[0.87,-0.89],[25.14,0],[0,49.35],[-49.35,0],[0,-49.35]],"o":[[-0.82,0.93],[-16.27,16.75],[-49.35,0],[0,-49.35],[49.35,0],[0,22.88]],"v":[[39.949,35.36],[37.419,38.08],[-26.751,65.25],[-116.251,-24.25],[-26.751,-113.75],[62.749,-24.25]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[4.11,4.1],[0,0],[0,25.41],[60.93,0],[0,-60.93],[-60.93,0],[-19.48,17.2],[0,0],[-2.69,0],[-2.05,2.05]],"o":[[0,0],[14.48,-18.69],[0,-60.93],[-60.93,0],[0,60.93],[27.96,0],[0,0],[2.05,2.05],[2.69,0],[4.11,-4.1]],"v":[[134.169,116.83],[60.639,43.3],[83.749,-24.25],[-26.751,-134.75],[-137.251,-24.25],[-26.751,86.25],[46.269,58.61],[119.329,131.67],[126.749,134.75],[134.169,131.67]],"c":true},"ix":2},"nm":"Path 2","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.38823529411764707,0.43137254901960786,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":121,"st":0,"bm":0}],"markers":[]}
10 changes: 0 additions & 10 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ PODS:
- awesome_notifications (0.0.5):
- Flutter
- IosAwnCore (= 0.7.3)
- connectivity_plus (0.0.1):
- Flutter
- ReachabilitySwift
- DKImagePickerController/Core (4.3.4):
- DKImagePickerController/ImageDataManager
- DKImagePickerController/Resource
Expand Down Expand Up @@ -107,7 +104,6 @@ PODS:
- Flutter
- FlutterMacOS
- PromisesObjC (2.1.1)
- ReachabilitySwift (5.0.0)
- SDWebImage (5.15.0):
- SDWebImage/Core (= 5.15.0)
- SDWebImage/Core (5.15.0)
Expand All @@ -118,7 +114,6 @@ PODS:

DEPENDENCIES:
- awesome_notifications (from `.symlinks/plugins/awesome_notifications/ios`)
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
- file_picker (from `.symlinks/plugins/file_picker/ios`)
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
Expand All @@ -142,15 +137,12 @@ SPEC REPOS:
- IosAwnCore
- nanopb
- PromisesObjC
- ReachabilitySwift
- SDWebImage
- SwiftyGif

EXTERNAL SOURCES:
awesome_notifications:
:path: ".symlinks/plugins/awesome_notifications/ios"
connectivity_plus:
:path: ".symlinks/plugins/connectivity_plus/ios"
file_picker:
:path: ".symlinks/plugins/file_picker/ios"
firebase_core:
Expand All @@ -170,7 +162,6 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
awesome_notifications: d63d9a25f126860f9a600850d99772237895b3ba
connectivity_plus: 413a8857dd5d9f1c399a39130850d02fe0feaf7e
DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
file_picker: ce3938a0df3cc1ef404671531facef740d03f920
Expand All @@ -190,7 +181,6 @@ SPEC CHECKSUMS:
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
path_provider_foundation: 37748e03f12783f9de2cb2c4eadfaa25fe6d4852
PromisesObjC: ab77feca74fa2823e7af4249b8326368e61014cb
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
SDWebImage: 9bec4c5cdd9579e1f57104735ee0c37df274d593
shared_preferences_foundation: 297b3ebca31b34ec92be11acd7fb0ba932c822ca
SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f
Expand Down
13 changes: 6 additions & 7 deletions lib/app/components/empty_widget.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:iconly/iconly.dart';
import 'package:iconsax/iconsax.dart';
import 'package:ionicons/ionicons.dart';
import 'package:lottie/lottie.dart';

Expand All @@ -11,14 +9,15 @@ class EmptyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
var theme = Theme.of(context);

return Padding(
padding: EdgeInsets.only(bottom: 100.h),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Lottie.asset(
'animations/error.json',
'animations/nodata.json',
height: 170.h,
repeat: true,
reverse: true,
Expand All @@ -29,8 +28,8 @@ class EmptyWidget extends StatelessWidget {
"Empty or No data !",
style: TextStyle(
fontSize: 18.sp,
fontWeight: FontWeight.w400,
color: theme.hintColor,
fontWeight: FontWeight.w500,
color: theme.hintColor.withOpacity(.5),
),
),
),
Expand All @@ -41,8 +40,8 @@ class EmptyWidget extends StatelessWidget {
onPressed: onPressed,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.grey.shade50,
elevation: 4,
shadowColor: theme.primaryColor,
elevation: 1,
shadowColor: theme.hintColor,
),
child: Icon(
Ionicons.refresh,
Expand Down
6 changes: 3 additions & 3 deletions lib/app/modules/home/controllers/home_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class HomeController extends GetxController with BaseController {
final postList = RxList<Posts>();

getPostList() async {
showLoading('Loading post');
showLoading();

var response = await DioClient().get(url: ApiUrl.allPosts, header: {
'Accept': 'application/json',
Expand All @@ -26,9 +26,9 @@ class HomeController extends GetxController with BaseController {
}

@override
void onReady() async {
void onReady() {
// TODO: implement onReady
await getPostList();
getPostList();
super.onReady();
}
}
36 changes: 21 additions & 15 deletions lib/app/modules/home/views/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class HomeView extends GetView<HomeController> {
onPressed: () async => await controller.getPostList(),
)
: RefreshIndicator(
color: theme.primaryColor,
onRefresh: () async => await controller.getPostList(),
child: Padding(
padding: const EdgeInsets.all(18.0),
Expand All @@ -37,22 +38,27 @@ class HomeView extends GetView<HomeController> {
separatorBuilder: (_, __) => SizedBox(
height: 20.h,
),
itemBuilder: (ctx, index) => Container(
padding: const EdgeInsets.all(5),
width: double.infinity,
color: theme.canvasColor,
child: Center(
child: Text(
controller.postList[index].title ?? "",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: MyFonts.headline6TextSize,
fontWeight: FontWeight.w500,
color: theme.primaryColor,
itemBuilder: (ctx, index) => controller.postList.isEmpty
? EmptyWidget(
onPressed: () async =>
await controller.getPostList(),
)
: Container(
padding: const EdgeInsets.all(5),
width: double.infinity,
color: theme.canvasColor,
child: Center(
child: Text(
controller.postList[index].title ?? "",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: MyFonts.headline6TextSize,
fontWeight: FontWeight.w500,
color: theme.primaryColor,
),
),
),
),
),
),
),
),
),
),
Expand Down
12 changes: 9 additions & 3 deletions lib/app/service/base_controller.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:async';

import 'package:flutter/foundation.dart';

import '../components/custom_snackbar.dart';
Expand All @@ -9,14 +11,18 @@ class BaseController {
hideLoading();

var errorText = DioExceptions.fromDioError(error).toString();
CustomSnackBar.showCustomErrorSnackBar(title: "Error", message: errorText);
Timer(const Duration(seconds: 1), () {
CustomSnackBar.showCustomErrorSnackBar(
title: "Error", message: errorText);
});

if (kDebugMode) {
print(errorText);
}
}

showLoading([String? message]) {
DialogHelper.showLoading(message);
showLoading() {
DialogHelper.showLoading();
}

hideLoading() {
Expand Down
49 changes: 30 additions & 19 deletions lib/app/service/helper/dialog_helper.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:lottie/lottie.dart';

class DialogHelper {
static get context => null;

//show error dialog
static void showErroDialog(
static void showErrorDialog(
{String title = 'Error', String? description = 'Something went wrong'}) {
Get.dialog(
Dialog(
Expand All @@ -16,11 +20,11 @@ class DialogHelper {
children: [
Text(
title,
style: Get.textTheme.headline4,
style: Get.textTheme.headlineMedium,
),
Text(
description ?? '',
style: Get.textTheme.headline6,
style: Get.textTheme.titleLarge,
),
ElevatedButton(
onPressed: () {
Expand All @@ -38,22 +42,25 @@ class DialogHelper {
//show toast
//show snack bar
//show loading
static void showLoading([String? message]) {
static void showLoading() {
Get.dialog(
Dialog(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Lottie.asset(
'animations/loader.json',
height: 170.h,
repeat: true,
reverse: true,
fit: BoxFit.cover,
),
],
Center(
child: Container(
height: 80.h,
decoration: const BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
child: OverflowBox(
minHeight: 130.h,
maxHeight: 130.h,
child: Lottie.asset(
'animations/loader.json',
height: 130.h,
repeat: true,
reverse: true,
fit: BoxFit.cover,
),
),
),
),
Expand All @@ -62,6 +69,10 @@ class DialogHelper {

//hide loading
static void hideLoading() {
if (Get.isDialogOpen!) Get.back();
Timer(const Duration(seconds: 1), () {
if (Get.isDialogOpen!) {
Get.back();
}
});
}
}
3 changes: 2 additions & 1 deletion lib/config/theme/light_theme_colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import 'package:flutter/material.dart';

class LightThemeColors {
//dark swatch
static const Color primaryColor = Color(0xFF40A76A);
//static const Color primaryColor = Color(0xFF40A76A);
static const Color primaryColor = Colors.deepOrangeAccent;
static const Color accentColor = Color(0xFFD9EDE1);

//APPBAR
Expand Down
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:getx_standard/app/modules/home/bindings/home_binding.dart';

import 'app/data/local/my_shared_pref.dart';
import 'app/routes/app_pages.dart';
Expand Down Expand Up @@ -38,6 +39,7 @@ Future<void> main() async {
),
);
},

initialRoute:
AppPages.INITIAL, // first screen to show when app is running
getPages: AppPages.routes, // app screens
Expand Down
5 changes: 4 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ dependencies:
http: ^0.13.5
file_picker: ^5.2.2
lottie: ^2.0.0
ionicons: ^0.2.2

flutter:
sdk: flutter
ionicons: ^0.2.2





dev_dependencies:
Expand Down

0 comments on commit 0c6ddb3

Please sign in to comment.