Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loading change notifer #530

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 32 additions & 30 deletions apps/tasks/lib/components/assignee_select.dart
Original file line number Diff line number Diff line change
@@ -1,48 +1,50 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:helpwave_localization/localization.dart';
import 'package:helpwave_service/user.dart';
import 'package:helpwave_theme/constants.dart';
import 'package:helpwave_widget/bottom_sheets.dart';
import 'package:helpwave_widget/loading.dart';
import 'package:provider/provider.dart';
import 'package:tasks/controllers/assignee_select_controller.dart';
import 'package:tasks/dataclasses/user.dart';
import 'package:helpwave_widget/content_selection.dart';

/// A [BottomSheet] for selecting a assignee
class AssigneeSelect extends StatelessWidget {
class AssigneeSelectBottomSheet extends StatelessWidget {
/// The callback when the assignee should be changed
final Function(User assignee) onChanged;
///
/// Null if the assignee should be removed
final Function(User? assignee) onChanged;

const AssigneeSelect({super.key, required this.onChanged});
final FutureOr<List<User>> users;

final String? selectedId;

const AssigneeSelectBottomSheet({super.key, required this.onChanged, required this.users, this.selectedId});

@override
Widget build(BuildContext context) {
return BottomSheetBase(
titleText: context.localization!.assignee,
onClosing: () => {},
builder: (context) => Flexible(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: paddingMedium),
child: Consumer<AssigneeSelectController>(builder: (context, assigneeSelectController, __) {
return LoadingAndErrorWidget(
state: assigneeSelectController.state,
child: ListView.builder(
itemCount: assigneeSelectController.users.length,
itemBuilder: (context, index) {
User user = assigneeSelectController.users[index];
return ListTile(
onTap: () {
assigneeSelectController.changeAssignee(user.id).then((value) {
onChanged(user);
});
},
leading: CircleAvatar(
foregroundColor: Colors.blue, backgroundImage: NetworkImage(user.profile.toString())),
title: Text(user.nickName),
);
},
builder: (context) => Padding(
padding: const EdgeInsets.symmetric(vertical: paddingMedium),
child: Column(
children: [
TextButton(
child: Text(context.localization!.remove),
onPressed: () => onChanged(null),
),
const SizedBox(height: 10),
ListSelect(
items: users,
onSelect: onChanged,
builder: (context, user, select) => ListTile(
onTap: select,
leading: CircleAvatar(
foregroundColor: Colors.blue, backgroundImage: NetworkImage(user.profileUrl.toString())),
title: Text(user.nickName,
style: TextStyle(decoration: user.id == selectedId ? TextDecoration.underline : null)),
),
);
}),
),
],
),
),
);
Expand Down
Loading
Loading