|
1 | 1 | import 'package:flow/cubits/flow.dart'; |
| 2 | +import 'package:flow/pages/events/note.dart'; |
| 3 | +import 'package:flow/pages/events/resources.dart'; |
2 | 4 | import 'package:flow/pages/groups/select.dart'; |
3 | 5 | import 'package:flutter/material.dart'; |
4 | 6 | import 'package:flutter_bloc/flutter_bloc.dart'; |
@@ -31,85 +33,142 @@ class EventDialog extends StatelessWidget { |
31 | 33 | var currentEvent = event ?? const Event(); |
32 | 34 | var currentSource = source ?? ''; |
33 | 35 | var currentService = cubit.sourcesService.getSource(currentSource).event; |
| 36 | + final noteConnector = cubit.getService(currentSource).eventNote; |
| 37 | + final resourceConnector = cubit.getService(currentSource).eventResource; |
34 | 38 | final nameController = TextEditingController(text: currentEvent.name); |
35 | 39 | final locationController = |
36 | 40 | TextEditingController(text: currentEvent.location); |
| 41 | + final tabs = !create && noteConnector != null && resourceConnector != null; |
37 | 42 | return ResponsiveAlertDialog( |
38 | 43 | title: Text(create |
39 | 44 | ? AppLocalizations.of(context).createEvent |
40 | 45 | : AppLocalizations.of(context).editEvent), |
41 | 46 | constraints: const BoxConstraints(maxWidth: 600, maxHeight: 800), |
42 | | - content: ListView( |
43 | | - shrinkWrap: true, |
44 | | - children: [ |
45 | | - if (source == null) ...[ |
46 | | - SourceDropdown<EventService>( |
47 | | - value: currentSource, |
48 | | - buildService: (source) => source.event, |
49 | | - onChanged: (connected) { |
50 | | - currentSource = connected?.source ?? ''; |
51 | | - currentService = connected?.model; |
52 | | - currentEvent = currentEvent.copyWith( |
53 | | - groupId: null, |
54 | | - ); |
55 | | - }, |
56 | | - ), |
57 | | - const SizedBox(height: 16), |
58 | | - ], |
59 | | - const SizedBox(height: 16), |
60 | | - TextFormField( |
61 | | - controller: nameController, |
62 | | - decoration: InputDecoration( |
63 | | - labelText: AppLocalizations.of(context).name, |
64 | | - icon: const PhosphorIcon(PhosphorIconsLight.fileText), |
65 | | - filled: true, |
66 | | - ), |
67 | | - onChanged: (value) => |
68 | | - currentEvent = currentEvent.copyWith(name: value), |
69 | | - ), |
70 | | - const SizedBox(height: 16), |
71 | | - MarkdownField( |
72 | | - decoration: InputDecoration( |
73 | | - labelText: AppLocalizations.of(context).description, |
74 | | - border: const OutlineInputBorder(), |
75 | | - icon: const PhosphorIcon(PhosphorIconsLight.fileText), |
76 | | - ), |
77 | | - value: currentEvent.description, |
78 | | - onChanged: (value) => |
79 | | - currentEvent = currentEvent.copyWith(description: value), |
80 | | - ), |
81 | | - const SizedBox(height: 16), |
82 | | - GroupSelectTile( |
83 | | - source: currentSource, |
84 | | - value: currentEvent.groupId, |
85 | | - onChanged: (value) { |
86 | | - currentEvent = currentEvent.copyWith(groupId: value?.model); |
87 | | - }, |
88 | | - ), |
89 | | - const SizedBox(height: 8), |
90 | | - StatefulBuilder( |
91 | | - builder: (context, setState) => CheckboxListTile( |
92 | | - secondary: const Icon(PhosphorIconsLight.circleHalfTilt), |
93 | | - title: Text(AppLocalizations.of(context).blocked), |
94 | | - value: currentEvent.blocked, |
95 | | - onChanged: (value) => setState( |
96 | | - () => currentEvent = currentEvent.copyWith( |
97 | | - blocked: value ?? currentEvent.blocked), |
| 47 | + content: DefaultTabController( |
| 48 | + length: tabs ? 3 : 1, |
| 49 | + child: Column( |
| 50 | + children: [ |
| 51 | + if (tabs) |
| 52 | + TabBar( |
| 53 | + tabs: [ |
| 54 | + ( |
| 55 | + PhosphorIconsLight.faders, |
| 56 | + AppLocalizations.of(context).general |
| 57 | + ), |
| 58 | + ( |
| 59 | + PhosphorIconsLight.checkCircle, |
| 60 | + AppLocalizations.of(context).notes |
| 61 | + ), |
| 62 | + ( |
| 63 | + PhosphorIconsLight.cube, |
| 64 | + AppLocalizations.of(context).resources |
| 65 | + ), |
| 66 | + ] |
| 67 | + .map((e) => HorizontalTab( |
| 68 | + icon: PhosphorIcon(e.$1), |
| 69 | + label: Text(e.$2), |
| 70 | + )) |
| 71 | + .toList()), |
| 72 | + Flexible( |
| 73 | + child: TabBarView( |
| 74 | + children: [ |
| 75 | + Material( |
| 76 | + color: Colors.transparent, |
| 77 | + child: ListView( |
| 78 | + shrinkWrap: true, |
| 79 | + children: [ |
| 80 | + if (source == null) ...[ |
| 81 | + SourceDropdown<EventService>( |
| 82 | + value: currentSource, |
| 83 | + buildService: (source) => source.event, |
| 84 | + onChanged: (connected) { |
| 85 | + currentSource = connected?.source ?? ''; |
| 86 | + currentService = connected?.model; |
| 87 | + currentEvent = currentEvent.copyWith( |
| 88 | + groupId: null, |
| 89 | + ); |
| 90 | + }, |
| 91 | + ), |
| 92 | + const SizedBox(height: 16), |
| 93 | + ], |
| 94 | + const SizedBox(height: 16), |
| 95 | + TextFormField( |
| 96 | + controller: nameController, |
| 97 | + decoration: InputDecoration( |
| 98 | + labelText: AppLocalizations.of(context).name, |
| 99 | + icon: |
| 100 | + const PhosphorIcon(PhosphorIconsLight.fileText), |
| 101 | + filled: true, |
| 102 | + ), |
| 103 | + onChanged: (value) => |
| 104 | + currentEvent = currentEvent.copyWith(name: value), |
| 105 | + ), |
| 106 | + const SizedBox(height: 16), |
| 107 | + MarkdownField( |
| 108 | + decoration: InputDecoration( |
| 109 | + labelText: AppLocalizations.of(context).description, |
| 110 | + border: const OutlineInputBorder(), |
| 111 | + icon: |
| 112 | + const PhosphorIcon(PhosphorIconsLight.fileText), |
| 113 | + ), |
| 114 | + value: currentEvent.description, |
| 115 | + onChanged: (value) => currentEvent = |
| 116 | + currentEvent.copyWith(description: value), |
| 117 | + ), |
| 118 | + const SizedBox(height: 16), |
| 119 | + GroupSelectTile( |
| 120 | + source: currentSource, |
| 121 | + value: currentEvent.groupId, |
| 122 | + onChanged: (value) { |
| 123 | + currentEvent = |
| 124 | + currentEvent.copyWith(groupId: value?.model); |
| 125 | + }, |
| 126 | + ), |
| 127 | + const SizedBox(height: 8), |
| 128 | + StatefulBuilder( |
| 129 | + builder: (context, setState) => CheckboxListTile( |
| 130 | + secondary: const Icon( |
| 131 | + PhosphorIconsLight.circleHalfTilt), |
| 132 | + title: Text( |
| 133 | + AppLocalizations.of(context).blocked), |
| 134 | + value: currentEvent.blocked, |
| 135 | + onChanged: (value) => setState( |
| 136 | + () => currentEvent = currentEvent.copyWith( |
| 137 | + blocked: value ?? currentEvent.blocked), |
| 138 | + ), |
| 139 | + )), |
| 140 | + const SizedBox(height: 8), |
| 141 | + TextField( |
| 142 | + decoration: InputDecoration( |
| 143 | + labelText: AppLocalizations.of(context).location, |
| 144 | + icon: const PhosphorIcon(PhosphorIconsLight.mapPin), |
| 145 | + ), |
| 146 | + minLines: 1, |
| 147 | + maxLines: 2, |
| 148 | + controller: locationController, |
| 149 | + onChanged: (value) => currentEvent = |
| 150 | + currentEvent.copyWith(location: value), |
| 151 | + ), |
| 152 | + ], |
98 | 153 | ), |
99 | | - )), |
100 | | - const SizedBox(height: 8), |
101 | | - TextField( |
102 | | - decoration: InputDecoration( |
103 | | - labelText: AppLocalizations.of(context).location, |
104 | | - icon: const PhosphorIcon(PhosphorIconsLight.mapPin), |
| 154 | + ), |
| 155 | + if (tabs) ...[ |
| 156 | + NotesView( |
| 157 | + model: currentEvent, |
| 158 | + connector: noteConnector, |
| 159 | + source: currentSource, |
| 160 | + ), |
| 161 | + ResourcesView( |
| 162 | + model: currentEvent, |
| 163 | + connector: resourceConnector, |
| 164 | + source: currentSource, |
| 165 | + ), |
| 166 | + ], |
| 167 | + ], |
| 168 | + ), |
105 | 169 | ), |
106 | | - minLines: 1, |
107 | | - maxLines: 2, |
108 | | - controller: locationController, |
109 | | - onChanged: (value) => |
110 | | - currentEvent = currentEvent.copyWith(location: value), |
111 | | - ), |
112 | | - ], |
| 170 | + ], |
| 171 | + ), |
113 | 172 | ), |
114 | 173 | actions: [ |
115 | 174 | TextButton( |
|
0 commit comments