-
Notifications
You must be signed in to change notification settings - Fork 0
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 #13 from mazineab/UI_changes
Create user list page and replace OBX by GetBuilder in comments and p…
- Loading branch information
Showing
11 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
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,31 @@ | ||
import 'package:get/get.dart'; | ||
import 'package:myapp/data/models/user.dart' as my_user; | ||
|
||
import '../../../common/dialogs/custom_snackbar.dart'; | ||
import '../../../data/repositories/home_repo.dart'; | ||
|
||
|
||
class UsersListController extends GetxController{ | ||
List<my_user.User> listUsers=<my_user.User>[].obs; | ||
var isLoad=true.obs; | ||
HomeRepo homeRepo=Get.put(HomeRepo()); | ||
|
||
Future<void> fetchUsers()async{ | ||
try{ | ||
List<my_user.User> list=await homeRepo.getUsers(); | ||
listUsers.assignAll(list); | ||
}catch(e){ | ||
CustomSnackbar.showErrorSnackbar(Get.context!, "Faild to load Users"); | ||
}finally{ | ||
await Future.delayed(const Duration(milliseconds: 30)); | ||
isLoad.value=false; | ||
} | ||
update(); | ||
} | ||
|
||
@override | ||
void onInit()async { | ||
await fetchUsers(); | ||
super.onInit(); | ||
} | ||
} |
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,61 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:myapp/Constants/colors.dart'; | ||
import 'package:myapp/common/widgets/custom_list_tile.dart'; | ||
import 'package:myapp/featues/setting/controller/users_list_controller.dart'; | ||
|
||
class UsersList extends StatelessWidget { | ||
UsersList({super.key}); | ||
|
||
UsersListController controller=Get.put(UsersListController()); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
backgroundColor: MyColors.backgroundColor, | ||
body: CustomScrollView( | ||
slivers: [ | ||
SliverAppBar( | ||
expandedHeight: 40.0, | ||
floating: true, | ||
pinned: false, | ||
flexibleSpace: FlexibleSpaceBar( | ||
title: Text('USERS',style: TextStyle(color: Colors.white),), | ||
), | ||
backgroundColor: MyColors.appBarColor, | ||
iconTheme: IconThemeData(color: Colors.white), | ||
), | ||
GetBuilder<UsersListController>( | ||
builder: (_){ | ||
if(controller.isLoad.value){ | ||
return SliverFillRemaining( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Center( | ||
child: CircularProgressIndicator( | ||
backgroundColor: MyColors.colorbl, | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
return SliverList( | ||
delegate: SliverChildBuilderDelegate( | ||
(context, index) { | ||
final user = controller.listUsers[index]; | ||
return Padding( | ||
padding: const EdgeInsets.symmetric(vertical: 10), | ||
child: CustomListTile(title: user.getFullName(), subtitle: user.email, userId: user.id,profileUrl: user.imageUrl,), | ||
); | ||
}, | ||
childCount: controller.listUsers.length, | ||
), | ||
); | ||
}) | ||
], | ||
), | ||
); | ||
} | ||
} |
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