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

api offline mode #527

Open
wants to merge 4 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
49 changes: 22 additions & 27 deletions apps/tasks/lib/components/assignee_select.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'package:flutter/material.dart';
import 'package:helpwave_localization/localization.dart';
import 'package:helpwave_service/tasks.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';

/// A [BottomSheet] for selecting a assignee
class AssigneeSelect extends StatelessWidget {
Expand All @@ -19,31 +19,26 @@ class AssigneeSelect extends StatelessWidget {
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: Consumer<AssigneeSelectController>(builder: (context, assigneeSelectController, __) {
return LoadingAndErrorWidget(
state: assigneeSelectController.state,
child: Column(
children: assigneeSelectController.users.map((user) =>
ListTile(
onTap: () {
assigneeSelectController.changeAssignee(user.id).then((value) {
onChanged(user);
});
},
leading: CircleAvatar(
foregroundColor: Colors.blue, backgroundImage: NetworkImage(user.profileUrl.toString())),
title: Text(user.nickName),
)).toList(),
),
);
}),
),
);
}
Expand Down
376 changes: 187 additions & 189 deletions apps/tasks/lib/components/patient_bottom_sheet.dart

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/tasks/lib/components/patient_card.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:helpwave_service/tasks.dart';
import 'package:tasks/components/task_status_pill_box.dart';
import 'package:helpwave_localization/localization.dart';
import 'package:helpwave_theme/constants.dart';
import 'package:tasks/dataclasses/patient.dart';

/// A [Widget] for displaying a card containing [Patient] information
class PatientCard extends StatelessWidget {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:helpwave_localization/localization.dart';
import 'package:helpwave_service/tasks.dart';
import 'package:helpwave_widget/content_selection.dart';
import 'package:tasks/dataclasses/patient.dart';

enum PatientStatusChipSelectOptions { all, active, unassigned, discharged }

Expand Down
18 changes: 8 additions & 10 deletions apps/tasks/lib/components/subtask_list.dart
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import 'package:flutter/material.dart';
import 'package:helpwave_localization/localization.dart';
import 'package:helpwave_service/tasks.dart';
import 'package:helpwave_theme/constants.dart';
import 'package:helpwave_theme/util.dart';
import 'package:helpwave_widget/lists.dart';
import 'package:provider/provider.dart';
import 'package:tasks/controllers/subtask_list_controller.dart';
import 'package:tasks/dataclasses/subtask.dart';
import 'package:tasks/dataclasses/task.dart';

/// A [Widget] for displaying an updating a [List] of [SubTask]s
/// A [Widget] for displaying an updating a [List] of [Subtask]s
class SubtaskList extends StatelessWidget {
/// The identifier of the [Task] to which all of these [SubTask]s belong
/// The identifier of the [Task] to which all of these [Subtask]s belong
final String taskId;

/// The [List] of initial subtasks
final List<SubTask> subtasks;
final List<Subtask> subtasks;

/// The callback when the [subtasks] are changed
///
/// Should **only** be used when [taskId == ""]
final void Function(List<SubTask> subtasks) onChange;
final void Function(List<Subtask> subtasks) onChange;

const SubtaskList({
super.key,
Expand All @@ -43,7 +41,7 @@ class SubtaskList extends StatelessWidget {
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
),
onAdd: () => subtasksController
.add(SubTask(id: "", name: "Subtask ${subtasksController.subtasks.length + 1}"))
.add(Subtask(id: "", name: "Subtask ${subtasksController.subtasks.length + 1}", taskId: taskId))
.then((_) => onChange(subtasksController.subtasks)),
itemBuilder: (context, _, subtask) => ListTile(
contentPadding: EdgeInsets.zero,
Expand Down Expand Up @@ -71,8 +69,8 @@ class SubtaskList extends StatelessWidget {
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(iconSizeSmall),
),
onChanged: (value) => subtasksController
.changeStatus(subTask: subtask, value: value ?? false)
onChanged: (isDone) => subtasksController
.updateSubtask(subTask: subtask.copyWith(isDone: isDone))
.then((value) => onChange(subtasksController.subtasks)),
),
trailing: GestureDetector(
Expand Down
13 changes: 4 additions & 9 deletions apps/tasks/lib/components/task_bottom_sheet.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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';
Expand All @@ -8,13 +9,7 @@ import 'package:provider/provider.dart';
import 'package:tasks/components/assignee_select.dart';
import 'package:tasks/components/subtask_list.dart';
import 'package:tasks/components/visibility_select.dart';
import 'package:tasks/controllers/task_controller.dart';
import 'package:tasks/controllers/user_controller.dart';
import 'package:tasks/dataclasses/patient.dart';
import 'package:tasks/dataclasses/user.dart';
import 'package:tasks/services/patient_svc.dart';
import '../controllers/assignee_select_controller.dart';
import '../dataclasses/task.dart';
import 'package:helpwave_service/tasks.dart';

/// A private [Widget] similar to a [ListTile] that has an icon and then to text
///
Expand Down Expand Up @@ -216,7 +211,7 @@ class _TaskBottomSheetState extends State<TaskBottomSheet> {
state: taskController.state,
child: ChangeNotifierProvider(
create: (BuildContext context) => AssigneeSelectController(
selected: taskController.task.assignee,
selected: taskController.task.assigneeId,
taskId: taskController.task.id,
),
child: AssigneeSelect(
Expand All @@ -233,7 +228,7 @@ class _TaskBottomSheetState extends State<TaskBottomSheet> {
state: taskController.state,
child: taskController.task.hasAssignee
? ChangeNotifierProvider(
create: (context) => UserController(User.empty(id: taskController.task.assignee!)),
create: (context) => UserController(User.empty(id: taskController.task.assigneeId!)),
child: Consumer<UserController>(
builder: (context, userController, __) => LoadingAndErrorWidget.pulsing(
state: userController.state,
Expand Down
2 changes: 1 addition & 1 deletion apps/tasks/lib/components/task_card.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:helpwave_localization/localization.dart';
import 'package:helpwave_service/tasks.dart';
import 'package:helpwave_theme/constants.dart';
import 'package:helpwave_widget/static_progress_indicator.dart';
import 'package:tasks/dataclasses/task.dart';

/// A [Card] showing a [Task]'s information
class TaskCard extends StatelessWidget {
Expand Down
3 changes: 1 addition & 2 deletions apps/tasks/lib/components/task_expansion_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import 'package:helpwave_widget/shapes.dart';
import 'package:provider/provider.dart';
import 'package:tasks/components/task_bottom_sheet.dart';
import 'package:tasks/components/task_card.dart';
import '../controllers/my_tasks_controller.dart';
import '../dataclasses/task.dart';
import 'package:helpwave_service/tasks.dart';

/// A [ExpansionTile] for showing a [List] of [Task]s
///
Expand Down
9 changes: 3 additions & 6 deletions apps/tasks/lib/components/user_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ 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/user_session_controller.dart';
import 'package:tasks/services/current_ward_svc.dart';
import '../dataclasses/ward.dart';
import '../screens/login_screen.dart';
import '../services/user_session_service.dart';
import '../services/ward_service.dart';
import 'package:helpwave_service/tasks.dart';
import 'package:helpwave_service/auth.dart';
import 'package:tasks/screens/login_screen.dart';

/// A [BottomSheet] for showing the [User]s information
class UserBottomSheet extends StatefulWidget {
Expand Down
6 changes: 2 additions & 4 deletions apps/tasks/lib/components/user_header.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import 'package:flutter/material.dart';
import 'package:helpwave_service/auth.dart';
import 'package:helpwave_service/tasks.dart';
import 'package:helpwave_theme/constants.dart';
import 'package:helpwave_widget/bottom_sheets.dart';
import 'package:provider/provider.dart';
import 'package:tasks/components/user_bottom_sheet.dart';
import 'package:tasks/controllers/user_session_controller.dart';
import 'package:tasks/dataclasses/organization.dart';
import 'package:tasks/dataclasses/ward.dart';
import 'package:tasks/screens/settings_screen.dart';
import 'package:tasks/services/current_ward_svc.dart';

/// A [AppBar] for displaying the current [User], [Organization] and [Ward]
class UserHeader extends StatelessWidget implements PreferredSizeWidget {
Expand Down
1 change: 0 additions & 1 deletion apps/tasks/lib/components/visibility_select.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:helpwave_localization/localization.dart';
import 'package:helpwave_theme/constants.dart';
import 'package:helpwave_widget/bottom_sheets.dart';
import 'package:helpwave_widget/dialog.dart';
import 'package:tasks/dataclasses/task.dart';

/// A [BottomSheet] to change the visibility
class _VisibilityBottomSheet extends StatelessWidget {
Expand Down
2 changes: 1 addition & 1 deletion apps/tasks/lib/config/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const minimumPasswordCharacters = 6;
/// Whether the development mode should be enabled
///
/// Shortens the login
const bool devMode = false;
const bool devMode = true;

/// The API for testing
const String stagingAPIURL = "staging.api.helpwave.de";
Expand Down
17 changes: 0 additions & 17 deletions apps/tasks/lib/dataclasses/organization.dart

This file was deleted.

14 changes: 0 additions & 14 deletions apps/tasks/lib/dataclasses/subtask.dart

This file was deleted.

102 changes: 0 additions & 102 deletions apps/tasks/lib/dataclasses/task.dart

This file was deleted.

Loading
Loading