fixed warnings and added bottom sheet to message sending
This commit is contained in:
parent
969aec0f11
commit
a175a9ea1c
@ -8,7 +8,6 @@ import 'package:filcnaplo/models/user.dart';
|
||||
import 'package:filcnaplo_kreta_api/client/api.dart';
|
||||
import 'package:filcnaplo_kreta_api/client/client.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/message.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@ -30,6 +29,7 @@ class MessageProvider with ChangeNotifier {
|
||||
_context = context;
|
||||
|
||||
if (_messages.isEmpty) restore();
|
||||
if (_recipients.isEmpty) restoreRecipients();
|
||||
}
|
||||
|
||||
Future<void> restore() async {
|
||||
@ -172,11 +172,11 @@ class MessageProvider with ChangeNotifier {
|
||||
SendRecipient.fromJson(e, addressable[AddresseeType.directorate]!)));
|
||||
}
|
||||
|
||||
if (kDebugMode) {
|
||||
print(addressable);
|
||||
print(recipients);
|
||||
print(recipients.first.json);
|
||||
}
|
||||
// if (kDebugMode) {
|
||||
// print(addressable);
|
||||
// print(recipients);
|
||||
// print(recipients.first.json);
|
||||
// }
|
||||
|
||||
storeRecipients(recipients);
|
||||
}
|
||||
|
@ -14,15 +14,15 @@ import 'package:provider/provider.dart';
|
||||
import 'grade_calculator.i18n.dart';
|
||||
|
||||
class GradeCalculator extends StatefulWidget {
|
||||
const GradeCalculator(this.subject, {Key? key}) : super(key: key);
|
||||
const GradeCalculator(this.subject, {super.key});
|
||||
|
||||
final GradeSubject? subject;
|
||||
|
||||
@override
|
||||
_GradeCalculatorState createState() => _GradeCalculatorState();
|
||||
GradeCalculatorState createState() => GradeCalculatorState();
|
||||
}
|
||||
|
||||
class _GradeCalculatorState extends State<GradeCalculator> {
|
||||
class GradeCalculatorState extends State<GradeCalculator> {
|
||||
late GradeCalculatorProvider calculatorProvider;
|
||||
|
||||
final _weightController = TextEditingController(text: "100");
|
||||
|
@ -1,3 +1,5 @@
|
||||
// ignore_for_file: no_leading_underscores_for_local_identifiers
|
||||
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
@ -36,13 +38,13 @@ import 'calculator/grade_calculator_provider.dart';
|
||||
import 'grades_page.i18n.dart';
|
||||
|
||||
class GradesPage extends StatefulWidget {
|
||||
const GradesPage({Key? key}) : super(key: key);
|
||||
const GradesPage({super.key});
|
||||
|
||||
@override
|
||||
_GradesPageState createState() => _GradesPageState();
|
||||
GradesPageState createState() => GradesPageState();
|
||||
}
|
||||
|
||||
class _GradesPageState extends State<GradesPage> {
|
||||
class GradesPageState extends State<GradesPage> {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
PersistentBottomSheetController? _sheetController;
|
||||
@ -424,8 +426,8 @@ class _GradesPageState extends State<GradesPage> {
|
||||
return Padding(
|
||||
padding: panelPadding,
|
||||
child: PanelBody(
|
||||
child: subjectTiles[index],
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: subjectTiles[index],
|
||||
));
|
||||
} else {
|
||||
return Padding(
|
||||
@ -448,7 +450,7 @@ class _GradesPageState extends State<GradesPage> {
|
||||
|
||||
_sheetController = _scaffoldKey.currentState?.showBottomSheet(
|
||||
(context) => const RoundedBottomSheet(
|
||||
child: GradeCalculator(null), borderRadius: 14.0),
|
||||
borderRadius: 14.0, child: GradeCalculator(null)),
|
||||
backgroundColor: const Color(0x00000000),
|
||||
elevation: 12.0,
|
||||
);
|
||||
|
@ -6,27 +6,31 @@ import 'package:filcnaplo_kreta_api/providers/message_provider.dart';
|
||||
import 'package:filcnaplo/api/providers/user_provider.dart';
|
||||
import 'package:filcnaplo/theme/colors/colors.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/message.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/bottom_sheet_menu/rounded_bottom_sheet.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/empty.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/filter_bar.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/profile_image/profile_button.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/profile_image/profile_image.dart';
|
||||
import 'package:filcnaplo/ui/filter/sort.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/soon_alert/soon_alert.dart';
|
||||
// import 'package:filcnaplo_mobile_ui/common/soon_alert/soon_alert.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/widgets/message/message_viewable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'messages_page.i18n.dart';
|
||||
import 'send_message/send_message.dart';
|
||||
|
||||
class MessagesPage extends StatefulWidget {
|
||||
const MessagesPage({Key? key}) : super(key: key);
|
||||
const MessagesPage({super.key});
|
||||
|
||||
@override
|
||||
_MessagesPageState createState() => _MessagesPageState();
|
||||
MessagesPageState createState() => MessagesPageState();
|
||||
}
|
||||
|
||||
class _MessagesPageState extends State<MessagesPage>
|
||||
class MessagesPageState extends State<MessagesPage>
|
||||
with TickerProviderStateMixin {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
late UserProvider user;
|
||||
late MessageProvider messageProvider;
|
||||
late UpdateProvider updateProvider;
|
||||
@ -50,6 +54,7 @@ class _MessagesPageState extends State<MessagesPage>
|
||||
firstName = nameParts.length > 1 ? nameParts[1] : nameParts[0];
|
||||
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.only(top: 12.0),
|
||||
child: NestedScrollView(
|
||||
@ -81,7 +86,8 @@ class _MessagesPageState extends State<MessagesPage>
|
||||
// [DeviceOrientation.portraitUp]);
|
||||
// setSystemChrome(context);
|
||||
// });
|
||||
SoonAlert.show(context: context);
|
||||
// SoonAlert.show(context: context);
|
||||
showSendMessageSheet(context);
|
||||
},
|
||||
icon: Icon(
|
||||
FeatherIcons.send,
|
||||
@ -219,4 +225,16 @@ class _MessagesPageState extends State<MessagesPage>
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showSendMessageSheet(BuildContext context) {
|
||||
messageProvider.fetchRecipients();
|
||||
|
||||
_scaffoldKey.currentState?.showBottomSheet(
|
||||
(context) => RoundedBottomSheet(
|
||||
borderRadius: 14.0,
|
||||
child: SendMessageSheet(messageProvider.recipients)),
|
||||
backgroundColor: const Color(0x00000000),
|
||||
elevation: 12.0,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,131 @@
|
||||
import 'package:filcnaplo_kreta_api/models/message.dart';
|
||||
import 'package:filcnaplo_kreta_api/providers/message_provider.dart';
|
||||
// import 'package:filcnaplo_mobile_ui/common/custom_snack_bar.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/material_action_button.dart';
|
||||
import 'package:filcnaplo_mobile_ui/pages/messages/send_message/send_message.i18n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class SendMessageSheet extends StatefulWidget {
|
||||
const SendMessageSheet(this.availableRecipients, {super.key});
|
||||
|
||||
final List<SendRecipient> availableRecipients;
|
||||
|
||||
@override
|
||||
SendMessageSheetState createState() => SendMessageSheetState();
|
||||
}
|
||||
|
||||
class SendMessageSheetState extends State<SendMessageSheet> {
|
||||
late MessageProvider messageProvider;
|
||||
|
||||
final _subjectController = TextEditingController();
|
||||
final _messageController = TextEditingController();
|
||||
|
||||
double newValue = 5.0;
|
||||
double newWeight = 100.0;
|
||||
|
||||
List<Widget> buildRecipientTiles() {
|
||||
return [];
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
messageProvider = Provider.of<MessageProvider>(context);
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(6.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: Text(
|
||||
"send_message".i18n,
|
||||
style:
|
||||
const TextStyle(fontSize: 20.0, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
|
||||
// message recipients
|
||||
Row(children: buildRecipientTiles()),
|
||||
|
||||
// message content
|
||||
Column(children: [
|
||||
Container(
|
||||
// width: 180.0,
|
||||
padding: const EdgeInsets.only(right: 12.0, left: 12.0),
|
||||
child: Center(
|
||||
child: TextField(
|
||||
controller: _subjectController,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600, fontSize: 18.0),
|
||||
autocorrect: true,
|
||||
textAlign: TextAlign.left,
|
||||
keyboardType: TextInputType.text,
|
||||
inputFormatters: [
|
||||
LengthLimitingTextInputFormatter(100),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
// border: InputBorder.none,
|
||||
// enabledBorder: InputBorder.none,
|
||||
// focusedBorder: InputBorder.none,
|
||||
hintText: "message_subject".i18n,
|
||||
suffixStyle: const TextStyle(fontSize: 16.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 200,
|
||||
padding: const EdgeInsets.only(right: 12.0, left: 12.0),
|
||||
child: TextField(
|
||||
controller: _messageController,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w500, fontSize: 16.0),
|
||||
autocorrect: true,
|
||||
textAlign: TextAlign.left,
|
||||
keyboardType: TextInputType.multiline,
|
||||
maxLines: 10,
|
||||
minLines: 1,
|
||||
inputFormatters: [
|
||||
LengthLimitingTextInputFormatter(500),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
// border: InputBorder.none,
|
||||
// enabledBorder: InputBorder.none,
|
||||
// focusedBorder: InputBorder.none,
|
||||
hintText: "message_text".i18n,
|
||||
suffixStyle: const TextStyle(fontSize: 14.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
Container(
|
||||
width: 120.0,
|
||||
padding: const EdgeInsets.symmetric(vertical: 12.0),
|
||||
child: MaterialActionButton(
|
||||
child: Text("send".i18n),
|
||||
onPressed: () async {
|
||||
if (_messageController.text.replaceAll(' ', '') == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
String subjectText =
|
||||
_subjectController.text.replaceAll(' ', '') != ''
|
||||
? _subjectController.text
|
||||
: 'Nincs tárgy';
|
||||
|
||||
messageProvider.sendMessage(
|
||||
recipients: [],
|
||||
subject: subjectText,
|
||||
messageText: _subjectController.text,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
import 'package:i18n_extension/i18n_extension.dart';
|
||||
|
||||
extension Localization on String {
|
||||
static final _t = Translations.byLocale("hu_hu") +
|
||||
{
|
||||
"en_en": {
|
||||
"recipients": "Recipients",
|
||||
"send_message": "Send Message",
|
||||
"send": "Send",
|
||||
"sent": "Message sent successfully.",
|
||||
"message_subject": "Tárgy...",
|
||||
"message_text": "Üzenet szövege...",
|
||||
},
|
||||
"hu_hu": {
|
||||
"recipients": "Recipients",
|
||||
"send_message": "Send Message",
|
||||
"send": "Send",
|
||||
"sent": "Message sent successfully.",
|
||||
"message_subject": "Tárgy...",
|
||||
"message_text": "Üzenet szövege...",
|
||||
},
|
||||
"de_de": {
|
||||
"recipients": "Recipients",
|
||||
"send_message": "Send Message",
|
||||
"send": "Send",
|
||||
"sent": "Message sent successfully.",
|
||||
"message_subject": "Tárgy...",
|
||||
"message_text": "Üzenet szövege...",
|
||||
},
|
||||
};
|
||||
|
||||
String get i18n => localize(this, _t);
|
||||
String fill(List<Object> params) => localizeFill(this, params);
|
||||
String plural(int value) => localizePlural(value, this, _t);
|
||||
String version(Object modifier) => localizeVersion(modifier, this, _t);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user