-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from mirmoktadir/animation
Tween Animation
- Loading branch information
Showing
35 changed files
with
4,695 additions
and
374 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'package:cached_network_image/cached_network_image.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
import 'package:lottie/lottie.dart'; | ||
|
||
import '../../../utils/constants.dart'; | ||
|
||
class NetworkImageBox extends StatelessWidget { | ||
const NetworkImageBox({ | ||
super.key, | ||
required this.url, | ||
required this.radius, | ||
}); | ||
|
||
final String url; | ||
final num radius; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return CachedNetworkImage( | ||
height: 110.sp, | ||
width: 110.sp, | ||
imageUrl: url, | ||
imageBuilder: (context, imageProvider) => Container( | ||
decoration: BoxDecoration( | ||
border: Border.all(color: Colors.white, width: 1), | ||
shape: BoxShape.rectangle, | ||
borderRadius: BorderRadius.circular(radius.r), | ||
image: DecorationImage( | ||
image: imageProvider, | ||
fit: BoxFit.cover, | ||
), | ||
), | ||
), | ||
placeholder: (context, url) => Lottie.asset( | ||
'animations/image_loader.json', | ||
height: 120.sp, | ||
repeat: true, | ||
reverse: true, | ||
fit: BoxFit.cover, | ||
), | ||
errorWidget: (context, url, error) => Container( | ||
height: 300.sp, | ||
width: 300.sp, | ||
padding: const EdgeInsets.all(10), | ||
decoration: BoxDecoration( | ||
color: const Color(0xffF3F3F3), | ||
border: Border.all(color: Colors.white, width: 1), | ||
shape: BoxShape.circle, | ||
), | ||
child: Image.asset( | ||
AppImages.kNoImage, | ||
fit: BoxFit.contain, | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import '../../../modules/example/home-with-restAPI/model/recipes_model.dart'; | ||
import 'my_hive.dart'; | ||
|
||
class HiveAdapters { | ||
static Future<void> registerAll() async { | ||
await MyHive.init(registerAdapters: (hive) { | ||
hive.registerAdapter(RecipesAdapter()); | ||
hive.registerAdapter(ResultsAdapter()); | ||
hive.registerAdapter(TotalTimeTierAdapter()); | ||
hive.registerAdapter(ShowAdapter()); | ||
hive.registerAdapter(SectionsAdapter()); | ||
hive.registerAdapter(ComponentsAdapter()); | ||
hive.registerAdapter(MeasurementsAdapter()); | ||
hive.registerAdapter(UnitAdapter()); | ||
hive.registerAdapter(IngredientAdapter()); | ||
hive.registerAdapter(CompilationsAdapter()); | ||
hive.registerAdapter(TagsAdapter()); | ||
hive.registerAdapter(RenditionsAdapter()); | ||
hive.registerAdapter(NutritionAdapter()); | ||
hive.registerAdapter(PriceAdapter()); | ||
hive.registerAdapter(TopicsAdapter()); | ||
hive.registerAdapter(UserRatingsAdapter()); | ||
hive.registerAdapter(InstructionsAdapter()); | ||
hive.registerAdapter(CreditsAdapter()); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import 'package:getx_standard/app/modules/example/home-with-restAPI/model/recipes_model.dart'; | ||
import 'package:hive_flutter/hive_flutter.dart'; | ||
import 'package:logger/logger.dart'; | ||
|
||
class MyHive { | ||
// Prevent making an instance of this class | ||
MyHive._(); | ||
|
||
// Hive box to store recipe data | ||
static late Box<Results> _recipeBox; | ||
|
||
// Box name, it's like the table name | ||
|
||
static const String _recipeBoxName = 'recipes'; | ||
|
||
/// Initialize local db (HIVE) | ||
/// Pass testPath only if you are testing hive | ||
static Future<void> init( | ||
{Function(HiveInterface)? registerAdapters, String? testPath}) async { | ||
if (testPath != null) { | ||
Hive.init(testPath); | ||
} else { | ||
await Hive.initFlutter(); | ||
} | ||
await registerAdapters?.call(Hive); | ||
|
||
await initRecipesBox(); | ||
} | ||
|
||
/// Initialize recipe box | ||
static Future<void> initRecipesBox() async { | ||
_recipeBox = await Hive.openBox<Results>(_recipeBoxName); | ||
} | ||
|
||
/// Save all recipes to the database | ||
static Future<void> saveAllRecipes(List<Results> recipes) async { | ||
try { | ||
await _recipeBox.clear(); | ||
await _recipeBox.addAll(recipes); | ||
} catch (error) { | ||
Logger().e("$error"); | ||
} | ||
} | ||
|
||
/// Get all recipes from Hive | ||
static List<Results> getAllRecipes() { | ||
final recipes = _recipeBox.values.toList(); | ||
return recipes.cast<Results>(); | ||
} | ||
} |
Oops, something went wrong.