Skip to content

Commit

Permalink
Feat: change admin menu UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Rotheem committed Nov 27, 2024
1 parent 4ec1bcc commit 4b1a002
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 108 deletions.
6 changes: 6 additions & 0 deletions lib/admin/tools/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@ class AdminTextConstants {
static const String emailRegex = "Email Regex";

static const String noSchool = "Sans école";

static const String schools = "Écoles";

static const String visibilities = "Visibilités";

static const String groups = "Groupes";
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter/material.dart';

class CardUi extends StatelessWidget {
class ItemCardUi extends StatelessWidget {
final List<Widget> children;
const CardUi({super.key, required this.children});
const ItemCardUi({super.key, required this.children});

@override
Widget build(BuildContext context) {
Expand All @@ -21,7 +21,7 @@ class CardUi extends StatelessWidget {
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisAlignment: MainAxisAlignment.center,
children: children,
),
);
Expand Down
6 changes: 3 additions & 3 deletions lib/admin/ui/pages/group_page/group_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import 'package:myecl/admin/providers/group_id_provider.dart';
import 'package:myecl/admin/providers/group_list_provider.dart';
import 'package:myecl/admin/router.dart';
import 'package:myecl/admin/ui/admin.dart';
import 'package:myecl/admin/ui/components/item_card_ui.dart';
import 'package:myecl/admin/ui/pages/group_page/group_ui.dart';
import 'package:myecl/admin/ui/pages/main_page/card_ui.dart';
import 'package:myecl/loan/providers/loaner_list_provider.dart';
import 'package:myecl/admin/tools/constants.dart';
import 'package:myecl/tools/constants.dart';
Expand Down Expand Up @@ -64,7 +64,7 @@ class GroupsPage extends HookConsumerWidget {
AdminRouter.addGroup,
);
},
child: CardUi(
child: ItemCardUi(
children: [
const Spacer(),
HeroIcon(
Expand All @@ -84,7 +84,7 @@ class GroupsPage extends HookConsumerWidget {
AdminRouter.addLoaner,
);
},
child: CardUi(
child: ItemCardUi(
children: [
const Spacer(),
Stack(
Expand Down
4 changes: 2 additions & 2 deletions lib/admin/ui/pages/group_page/group_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
import 'package:heroicons/heroicons.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:myecl/admin/class/simple_group.dart';
import 'package:myecl/admin/ui/components/item_card_ui.dart';
import 'package:myecl/admin/ui/pages/group_page/group_button.dart';
import 'package:myecl/admin/ui/pages/main_page/card_ui.dart';
import 'package:myecl/tools/constants.dart';
import 'package:myecl/tools/ui/builders/waiting_button.dart';

Expand All @@ -22,7 +22,7 @@ class GroupUi extends HookConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
return CardUi(
return ItemCardUi(
children: [
const SizedBox(width: 10),
if (isLoaner)
Expand Down
144 changes: 48 additions & 96 deletions lib/admin/ui/pages/main_page/main_page.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:heroicons/heroicons.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:myecl/admin/providers/group_list_provider.dart';
import 'package:myecl/admin/router.dart';
import 'package:myecl/admin/tools/constants.dart';
import 'package:myecl/admin/ui/admin.dart';
import 'package:myecl/admin/ui/pages/main_page/card_ui.dart';
import 'package:myecl/loan/providers/loaner_list_provider.dart';
import 'package:myecl/tools/constants.dart';
import 'package:myecl/tools/ui/builders/async_child.dart';
import 'package:myecl/tools/ui/layouts/refresher.dart';
import 'package:myecl/admin/ui/pages/main_page/menu_card_ui.dart';
import 'package:myecl/user/providers/user_list_provider.dart';
import 'package:qlevar_router/qlevar_router.dart';

Expand All @@ -17,100 +14,55 @@ class AdminMainPage extends HookConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final groups = ref.watch(allGroupListProvider);
final groupsNotifier = ref.watch(allGroupListProvider.notifier);
final loanListNotifier = ref.watch(loanerListProvider.notifier);
ref.watch(userList);

final controller = ScrollController();

return AdminTemplate(
child: Refresher(
onRefresh: () async {
await groupsNotifier.loadGroups();
await loanListNotifier.loadLoanerList();
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 30.0),
child: AsyncChild(
value: groups,
builder: (context, g) {
g.sort(
(a, b) => a.name.toLowerCase().compareTo(b.name.toLowerCase()),
);
return Column(
children: [
Column(
children: [
GestureDetector(
onTap: () {
QR.to(
AdminRouter.root + AdminRouter.editModuleVisibility,
);
},
child: CardUi(
children: [
const Spacer(),
HeroIcon(
HeroIcons.eye,
color: Colors.grey.shade700,
size: 40,
),
const Spacer(),
],
),
),
GestureDetector(
onTap: () {
QR.to(AdminRouter.root + AdminRouter.groups);
},
child: CardUi(
children: [
const Spacer(),
HeroIcon(
HeroIcons.users,
color: Colors.grey.shade700,
size: 40,
),
const Spacer(),
],
),
),
GestureDetector(
onTap: () {
QR.to(AdminRouter.root + AdminRouter.schools);
},
child: CardUi(
children: [
const Spacer(),
Stack(
clipBehavior: Clip.none,
children: [
HeroIcon(
HeroIcons.academicCap,
color: Colors.grey.shade700,
size: 40,
),
Positioned(
right: -2,
top: -2,
child: HeroIcon(
HeroIcons.plus,
size: 15,
color: Colors.grey.shade700,
),
),
],
),
const Spacer(),
],
),
),
],
),
],
);
},
loaderColor: ColorConstants.gradient1,
child: Padding(
padding: const EdgeInsets.all(40),
child: GridView(
controller: controller,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 20,
crossAxisSpacing: 20,
childAspectRatio: MediaQuery.of(context).size.width <
MediaQuery.of(context).size.height
? 0.75
: 1.5,
),
children: [
GestureDetector(
onTap: () {
QR.to(
AdminRouter.root + AdminRouter.editModuleVisibility,
);
},
child: const MenuCardUi(
text: AdminTextConstants.visibilities,
icon: HeroIcons.eye,
),
),
GestureDetector(
onTap: () {
QR.to(AdminRouter.root + AdminRouter.groups);
},
child: const MenuCardUi(
text: AdminTextConstants.groups,
icon: HeroIcons.users,
),
),
GestureDetector(
onTap: () {
QR.to(AdminRouter.root + AdminRouter.schools);
},
child: const MenuCardUi(
text: AdminTextConstants.schools,
icon: HeroIcons.academicCap,
),
),
],
),
),
);
Expand Down
43 changes: 43 additions & 0 deletions lib/admin/ui/pages/main_page/menu_card_ui.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import 'package:flutter/material.dart';
import 'package:heroicons/heroicons.dart';

class MenuCardUi extends StatelessWidget {
final String text;
final HeroIcons icon;
const MenuCardUi({super.key, required this.text, required this.icon});

@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.symmetric(vertical: 10),
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
blurRadius: 5,
spreadRadius: 2,
),
],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
HeroIcon(
icon,
color: Colors.grey.shade700,
size: 40,
),
const SizedBox(width: 10),
Text(
text,
style: const TextStyle(fontSize: 20),
),
],
),
);
}
}
4 changes: 2 additions & 2 deletions lib/admin/ui/pages/school_page/school_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import 'package:myecl/admin/providers/school_list_provider.dart';
import 'package:myecl/admin/providers/school_provider.dart';
import 'package:myecl/admin/router.dart';
import 'package:myecl/admin/ui/admin.dart';
import 'package:myecl/admin/ui/components/item_card_ui.dart';
import 'package:myecl/admin/ui/pages/school_page/school_ui.dart';
import 'package:myecl/admin/ui/pages/main_page/card_ui.dart';
import 'package:myecl/admin/tools/constants.dart';
import 'package:myecl/tools/constants.dart';
import 'package:myecl/tools/ui/builders/async_child.dart';
Expand Down Expand Up @@ -55,7 +55,7 @@ class SchoolsPage extends HookConsumerWidget {
AdminRouter.addSchool,
);
},
child: CardUi(
child: ItemCardUi(
children: [
const Spacer(),
HeroIcon(
Expand Down
4 changes: 2 additions & 2 deletions lib/admin/ui/pages/school_page/school_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
import 'package:heroicons/heroicons.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:myecl/admin/class/school.dart';
import 'package:myecl/admin/ui/components/item_card_ui.dart';
import 'package:myecl/admin/ui/pages/school_page/school_button.dart';
import 'package:myecl/admin/ui/pages/main_page/card_ui.dart';
import 'package:myecl/tools/constants.dart';
import 'package:myecl/tools/ui/builders/waiting_button.dart';

Expand All @@ -20,7 +20,7 @@ class SchoolUi extends HookConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
return CardUi(
return ItemCardUi(
children: [
const SizedBox(width: 10),
Expanded(
Expand Down

0 comments on commit 4b1a002

Please sign in to comment.