Skip to content

Commit

Permalink
Merge pull request #94 from pvdthings/item-details-indicator
Browse files Browse the repository at this point in the history
update item details availability indicator on save
  • Loading branch information
dillonfagan authored Nov 18, 2024
2 parents a79c0bd + 7402dd7 commit bc00147
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 98 deletions.
4 changes: 2 additions & 2 deletions apps/librarian/lib/dashboard/pages/dashboard_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:librarian_app/dashboard/providers/create_loan_controller.dart';
import 'package:librarian_app/dashboard/providers/invalidate_module.dart';
import 'package:librarian_app/dashboard/providers/workspace.dart';
import 'package:librarian_app/dashboard/widgets/end_drawer.dart';
import 'package:librarian_app/modules/authentication/providers/auth_service_provider.dart';
import 'package:librarian_app/modules/authentication/providers/user_tray.dart';
import 'package:librarian_app/modules/members/details/needs_attention_page.dart';
import 'package:librarian_app/dashboard/layouts/members_desktop_layout.dart';
import 'package:librarian_app/modules/members/list/searchable_members_list.dart';
import 'package:librarian_app/dashboard/providers/end_drawer_provider.dart';
import 'package:librarian_app/dashboard/widgets/create_menu_item.dart';
import 'package:librarian_app/dashboard/layouts/inventory_desktop_layout.dart';
import 'package:librarian_app/modules/things/maintenance/view.dart';
Expand Down Expand Up @@ -232,7 +232,7 @@ class _DashboardPageState extends ConsumerState<DashboardPage> {
],
)
: null,
endDrawer: ref.watch(endDrawerProvider).drawer,
endDrawer: const EndDrawer(),
floatingActionButton: mobile ? menuAnchor : null,
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ class EndDrawerController {
EndDrawerController(this.ref);

final Ref ref;
Widget? drawer;
Widget child = const SizedBox.expand();

openEndDrawer(BuildContext context, Widget drawer) {
this.drawer = drawer;
openEndDrawer(BuildContext context, Widget child) {
this.child = child;
ref.notifyListeners();
Future.delayed(const Duration(milliseconds: 500), () {
Future.delayed(const Duration(milliseconds: 750), () {
Scaffold.of(context).openEndDrawer();
});
}
Expand Down
16 changes: 16 additions & 0 deletions apps/librarian/lib/dashboard/widgets/end_drawer.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../providers/end_drawer_provider.dart';

class EndDrawer extends ConsumerWidget {
const EndDrawer({super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
return Drawer(
width: 500,
child: ref.watch(endDrawerProvider).child,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,115 +24,117 @@ class _ItemDetailsDrawerState extends State<ItemDetailsDrawer> {

bool isLoading = false;

convert() {
void convert() {
widget.controller.convertThing(context);
}

@override
Widget build(BuildContext context) {
return Drawer(
width: 500,
child: Stack(
children: [
Column(
children: [
Padding(
padding: const EdgeInsets.all(16),
child: Row(
children: [
getIcon(widget.controller.item!),
const SizedBox(width: 8.0),
Expanded(
child: Text(
'#${widget.controller.item!.number}',
style: Theme.of(context).textTheme.titleLarge,
),
return Stack(
children: [
Column(
children: [
Padding(
padding: const EdgeInsets.all(16),
child: Row(
children: [
ListenableBuilder(
listenable: widget.controller,
builder: (context, child) {
return getIcon(widget.controller.item!);
},
),
const SizedBox(width: 8.0),
Expanded(
child: Text(
'#${widget.controller.item!.number}',
style: Theme.of(context).textTheme.titleLarge,
),
MenuAnchor(
controller: menuController,
menuChildren: [
MenuItemButton(
onPressed: convert,
leadingIcon: const Icon(Icons.transform),
child: const Text('Convert'),
),
],
child: IconButton.filled(
onPressed: () => menuController.open(),
icon: const Icon(Icons.more_vert),
),
MenuAnchor(
controller: menuController,
menuChildren: [
MenuItemButton(
onPressed: convert,
leadingIcon: const Icon(Icons.transform),
child: const Text('Convert'),
),
],
child: IconButton.filled(
onPressed: () => menuController.open(),
icon: const Icon(Icons.more_vert),
),
],
),
),
],
),
const Divider(height: 1),
Expanded(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
ItemDetails(
controller: widget.controller,
item: widget.controller.item!,
isThingHidden: widget.isHiddenLocked,
),
const SizedBox(height: 80),
],
),
),
const Divider(height: 1),
Expanded(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
ItemDetails(
controller: widget.controller,
item: widget.controller.item!,
isThingHidden: widget.isHiddenLocked,
),
const SizedBox(height: 80),
],
),
),
),
],
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Container(
color: Theme.of(context).colorScheme.surface.withAlpha(180),
child: Padding(
padding: const EdgeInsets.all(16),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
ListenableBuilder(
listenable: widget.controller,
builder: (context, child) {
if (!widget.controller.hasUnsavedChanges) {
return child!;
}
),
],
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Container(
color: Theme.of(context).colorScheme.surface.withAlpha(180),
child: Padding(
padding: const EdgeInsets.all(16),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
ListenableBuilder(
listenable: widget.controller,
builder: (context, child) {
if (!widget.controller.hasUnsavedChanges) {
return child!;
}

return OutlinedButton(
onPressed: () {
widget.controller.discardChanges();
},
child: const Text('Discard'),
);
},
child: OutlinedButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text('Cancel'),
),
),
const SizedBox(width: 8),
ListenableBuilder(
listenable: widget.controller,
builder: (_, __) {
return FilledProgressButton(
onPressed: widget.controller.saveChanges,
isLoading: isLoading,
child: const Text('Save'),
);
},
return OutlinedButton(
onPressed: () {
widget.controller.discardChanges();
},
child: const Text('Discard'),
);
},
child: OutlinedButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text('Cancel'),
),
],
),
),
const SizedBox(width: 8),
ListenableBuilder(
listenable: widget.controller,
builder: (_, __) {
return FilledProgressButton(
onPressed: widget.controller.saveChanges,
isLoading: isLoading,
child: const Text('Save'),
);
},
),
],
),
),
),
],
),
),
],
);
}
}

0 comments on commit bc00147

Please sign in to comment.