Skip to content

Commit

Permalink
new Ui with new rest api
Browse files Browse the repository at this point in the history
  • Loading branch information
Moktadir authored and Moktadir committed Sep 20, 2023
1 parent 7102996 commit 77916cb
Show file tree
Hide file tree
Showing 21 changed files with 2,356 additions and 203 deletions.
2,075 changes: 2,074 additions & 1 deletion animations/apiError.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>GetX Standard</string>
<string>GetX Standard</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>GetX Standard</string>
<string>GetX Standard</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
Expand Down
4 changes: 3 additions & 1 deletion lib/app/components/global-widgets/network_image_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ 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) {
Expand All @@ -23,7 +25,7 @@ class NetworkImageBox extends StatelessWidget {
decoration: BoxDecoration(
border: Border.all(color: Colors.white, width: 1),
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(18.r),
borderRadius: BorderRadius.circular(radius.r),
image: DecorationImage(
image: imageProvider,
fit: BoxFit.cover,
Expand Down
1 change: 1 addition & 0 deletions lib/app/components/global-widgets/splash_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class SplashContainer extends StatelessWidget {
splashFactory: InkSplash.splashFactory,
highlightColor: theme.primaryColor.withOpacity(.3),
borderRadius: BorderRadius.circular(radius.r),
radius: 60.r,
onTap: onPressed,
child: Ink(
decoration: BoxDecoration(
Expand Down
27 changes: 27 additions & 0 deletions lib/app/data/local/hive/hive_adapters.dart
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());
});
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:getx_standard/app/modules/example/home-with-restAPI/controllers/home_controller.dart';
import 'package:getx_standard/app/service/handler/exception_handler.dart';

import '../../../../components/navbar/navbar_controller.dart';
Expand Down Expand Up @@ -62,7 +64,7 @@ class GraphQLController extends GetxController with ExceptionHandler {
@override
void onReady() async {
await getAlbums();

Get.find<HomeController>().bottomPadding.value = 18.sp;
super.onReady();
}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,53 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:getx_standard/app/modules/example/home-with-restAPI/model/recipes_model.dart';
import 'package:getx_standard/app/service/helper/network_connectivity.dart';

import '../../../../components/global-widgets/custom_snackbar.dart';
import '../../../../components/navbar/navbar_controller.dart';
import '../../../../data/local/my_hive.dart';
import '../../../../data/local/hive/my_hive.dart';
import '../../../../service/REST/api_urls.dart';
import '../../../../service/REST/dio_client.dart';
import '../../../../service/handler/exception_handler.dart';

class HomeController extends GetxController with ExceptionHandler {
final navController = Get.put(NavbarController());
final scrollController = ScrollController();

RxDouble bottomPadding = 18.sp.obs;

RxString title = "".obs;
RxString body = "".obs;

final recipes = RxList<Results>();

scrollPositionTracker() {
scrollController.addListener(() {
if (scrollController.position.pixels >
scrollController.position.minScrollExtent + 5) {
bottomPadding.value = 18.sp;
// position in Top
}
if (scrollController.position.pixels >=
scrollController.position.maxScrollExtent) {
bottomPadding.value = 130.sp;
// position in Bottom
}
});
}

/// GET ALL RECIPES LIST 'HIVE IMPLEMENTED'
getRecipes() async {
showLoading();
if (await NetworkConnectivity.isNetworkAvailable()) {
/// Fetch recipes from the API
var response = await DioClient().get(
url: ApiUrl.allRecipes,
params: {"from": 0, "size": 20}).catchError(handleError);
var response = await DioClient()
.get(
url: ApiUrl.allRecipes,
)
.catchError(handleError);

if (response == null) return;

Expand Down Expand Up @@ -58,7 +80,31 @@ class HomeController extends GetxController with ExceptionHandler {
@override
void onReady() async {
await getRecipes();

// scrollController.addListener(() {
// if (scrollController.position.atEdge) {
// bool isTop = scrollController.position.pixels == 0;
// if (isTop) {
// bottomPadding.value = 18.sp;
// print('At the top');
// } else {
// bottomPadding.value = 50.sp;
// print('At the bottom');
// }
// }
// });
super.onReady();
}

@override
void onInit() {
super.onInit();

scrollPositionTracker();
}

@override
void dispose() {
scrollController.dispose();
super.dispose();
}
}
Loading

0 comments on commit 77916cb

Please sign in to comment.