Revert "Rename everything filcnaplo-related to refilc"
This reverts commit d1a9625d93.
This commit is contained in:
83
filcnaplo_mobile_ui/lib/common/widgets/message/attachment_tile.dart
Executable file
83
filcnaplo_mobile_ui/lib/common/widgets/message/attachment_tile.dart
Executable file
@@ -0,0 +1,83 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:filcnaplo_kreta_api/models/attachment.dart';
|
||||
import 'package:filcnaplo/helpers/attachment_helper.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/widgets/message/image_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
|
||||
class AttachmentTile extends StatelessWidget {
|
||||
const AttachmentTile(this.attachment, {Key? key}) : super(key: key);
|
||||
|
||||
final Attachment attachment;
|
||||
|
||||
Widget buildImage(BuildContext context) {
|
||||
return FutureBuilder<String>(
|
||||
future: attachment.download(context),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
child: Material(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
showModalBottomSheet(
|
||||
useRootNavigator: true,
|
||||
isScrollControlled: true,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return ImageView(snapshot.data!);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Ink.image(
|
||||
image: FileImage(File(snapshot.data ?? "")),
|
||||
height: 200.0,
|
||||
width: double.infinity,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: CircularProgressIndicator(color: Theme.of(context).colorScheme.secondary),
|
||||
));
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (attachment.isImage) return buildImage(context);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
onTap: () {
|
||||
attachment.open(context);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(children: [
|
||||
const Icon(FeatherIcons.paperclip),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||
child: Text(attachment.name, maxLines: 2, overflow: TextOverflow.ellipsis),
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
46
filcnaplo_mobile_ui/lib/common/widgets/message/image_view.dart
Executable file
46
filcnaplo_mobile_ui/lib/common/widgets/message/image_view.dart
Executable file
@@ -0,0 +1,46 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:filcnaplo/helpers/share_helper.dart';
|
||||
import 'package:filcnaplo/theme/colors/colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
|
||||
class ImageView extends StatelessWidget {
|
||||
const ImageView(this.path, {Key? key}) : super(key: key);
|
||||
|
||||
final String path;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
child: SafeArea(
|
||||
minimum: const EdgeInsets.only(top: 24.0),
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: BackButton(color: AppColors.of(context).text),
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 8.0),
|
||||
child: IconButton(
|
||||
onPressed: () => ShareHelper.shareFile(path),
|
||||
icon: Icon(FeatherIcons.share2, color: AppColors.of(context).text),
|
||||
splashRadius: 24.0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: PhotoView(
|
||||
imageProvider: FileImage(File(path)),
|
||||
maxScale: 4.0,
|
||||
minScale: PhotoViewComputedScale.contained,
|
||||
backgroundDecoration: BoxDecoration(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
53
filcnaplo_mobile_ui/lib/common/widgets/message/message_view.dart
Executable file
53
filcnaplo_mobile_ui/lib/common/widgets/message/message_view.dart
Executable file
@@ -0,0 +1,53 @@
|
||||
import 'package:filcnaplo/theme/colors/colors.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/message.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/widgets/message/message_view_tile.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MessageView extends StatefulWidget {
|
||||
const MessageView(this.messages, {Key? key}) : super(key: key);
|
||||
|
||||
final List<Message> messages;
|
||||
|
||||
static show(List<Message> messages, {required BuildContext context}) =>
|
||||
Navigator.of(context, rootNavigator: true).push(CupertinoPageRoute(builder: (context) => MessageView(messages)));
|
||||
|
||||
@override
|
||||
_MessageViewState createState() => _MessageViewState();
|
||||
}
|
||||
|
||||
class _MessageViewState extends State<MessageView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leadingWidth: 64.0,
|
||||
leading: BackButton(color: AppColors.of(context).text),
|
||||
elevation: 0,
|
||||
actions: const [
|
||||
// Padding(
|
||||
// padding: EdgeInsets.only(right: 8.0),
|
||||
// child: IconButton(
|
||||
// onPressed: () {},
|
||||
// icon: Icon(FeatherIcons.archive, color: AppColors.of(context).text),
|
||||
// splashRadius: 32.0,
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
body: SafeArea(
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemCount: widget.messages.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24.0),
|
||||
child: MessageViewTile(widget.messages[index]),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
128
filcnaplo_mobile_ui/lib/common/widgets/message/message_view_tile.dart
Executable file
128
filcnaplo_mobile_ui/lib/common/widgets/message/message_view_tile.dart
Executable file
@@ -0,0 +1,128 @@
|
||||
import 'package:filcnaplo/api/providers/user_provider.dart';
|
||||
import 'package:filcnaplo/utils/color.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/message.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/panel/panel.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/profile_image/profile_image.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/widgets/message/attachment_tile.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:filcnaplo/utils/format.dart';
|
||||
import 'package:flutter_custom_tabs/flutter_custom_tabs.dart';
|
||||
// import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:flutter_linkify/flutter_linkify.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'message_view_tile.i18n.dart';
|
||||
|
||||
class MessageViewTile extends StatelessWidget {
|
||||
const MessageViewTile(this.message, {Key? key}) : super(key: key);
|
||||
|
||||
final Message message;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
UserProvider user = Provider.of<UserProvider>(context, listen: false);
|
||||
String recipientLabel = "";
|
||||
|
||||
if (message.recipients.any((r) => r.name == user.student?.name)) {
|
||||
recipientLabel = "me".i18n;
|
||||
}
|
||||
|
||||
if (recipientLabel != "" && message.recipients.length > 1) {
|
||||
recipientLabel += " +";
|
||||
recipientLabel += message.recipients
|
||||
.where((r) => r.name != user.student?.name)
|
||||
.length
|
||||
.toString();
|
||||
}
|
||||
|
||||
if (recipientLabel == "") {
|
||||
// note: convertint to set to remove duplicates
|
||||
recipientLabel +=
|
||||
message.recipients.map((r) => r.name).toSet().join(", ");
|
||||
}
|
||||
|
||||
List<Widget> attachments = [];
|
||||
for (var a in message.attachments) {
|
||||
attachments.add(AttachmentTile(a));
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Subject
|
||||
Text(
|
||||
message.subject,
|
||||
softWrap: true,
|
||||
maxLines: 10,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 24.0,
|
||||
),
|
||||
),
|
||||
|
||||
// Author
|
||||
ListTile(
|
||||
visualDensity: VisualDensity.compact,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: ProfileImage(
|
||||
name: message.author,
|
||||
backgroundColor: ColorUtils.stringToColor(message.author),
|
||||
),
|
||||
title: Text(
|
||||
message.author,
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 2,
|
||||
),
|
||||
subtitle: Text(
|
||||
"to".i18n + " " + recipientLabel,
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
trailing: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// IconButton(
|
||||
// onPressed: () {},
|
||||
// icon: Icon(FeatherIcons.cornerUpLeft, color: AppColors.of(context).text),
|
||||
// splashRadius: 24.0,
|
||||
// padding: EdgeInsets.zero,
|
||||
// visualDensity: VisualDensity.compact,
|
||||
// ),
|
||||
// IconButton(
|
||||
// onPressed: () {},
|
||||
// icon: Icon(FeatherIcons.share2, color: AppColors.of(context).text),
|
||||
// splashRadius: 24.0,
|
||||
// padding: EdgeInsets.zero,
|
||||
// visualDensity: VisualDensity.compact,
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Content
|
||||
Panel(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: SelectableLinkify(
|
||||
text: message.content.escapeHtml(),
|
||||
options: const LinkifyOptions(looseUrl: true, removeWww: true),
|
||||
onOpen: (link) {
|
||||
launch(link.url,
|
||||
customTabsOption: CustomTabsOption(
|
||||
toolbarColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
showPageTitle: true,
|
||||
));
|
||||
},
|
||||
style: const TextStyle(fontWeight: FontWeight.w400),
|
||||
),
|
||||
),
|
||||
|
||||
// Attachments
|
||||
...attachments,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
24
filcnaplo_mobile_ui/lib/common/widgets/message/message_view_tile.i18n.dart
Executable file
24
filcnaplo_mobile_ui/lib/common/widgets/message/message_view_tile.i18n.dart
Executable file
@@ -0,0 +1,24 @@
|
||||
import 'package:i18n_extension/i18n_extension.dart';
|
||||
|
||||
extension Localization on String {
|
||||
static final _t = Translations.byLocale("hu_hu") +
|
||||
{
|
||||
"en_en": {
|
||||
"me": "me",
|
||||
"to": "to",
|
||||
},
|
||||
"hu_hu": {
|
||||
"me": "én",
|
||||
"to": "Címzett:",
|
||||
},
|
||||
"de_de": {
|
||||
"me": "mich",
|
||||
"to": "zu",
|
||||
}
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
32
filcnaplo_mobile_ui/lib/common/widgets/message/message_viewable.dart
Executable file
32
filcnaplo_mobile_ui/lib/common/widgets/message/message_viewable.dart
Executable file
@@ -0,0 +1,32 @@
|
||||
import 'package:animations/animations.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/message.dart';
|
||||
import 'package:filcnaplo/ui/widgets/message/message_tile.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/widgets/message/message_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MessageViewable extends StatelessWidget {
|
||||
const MessageViewable(this.message, {Key? key}) : super(key: key);
|
||||
|
||||
final Message message;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return OpenContainer(
|
||||
openBuilder: (context, _) {
|
||||
return MessageView([message]);
|
||||
},
|
||||
closedBuilder: (context, VoidCallback openContainer) {
|
||||
return MessageTile(message);
|
||||
},
|
||||
closedElevation: 0,
|
||||
openShape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)),
|
||||
closedShape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)),
|
||||
middleColor: Theme.of(context).colorScheme.background,
|
||||
openColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
closedColor: Theme.of(context).colorScheme.background,
|
||||
transitionType: ContainerTransitionType.fadeThrough,
|
||||
transitionDuration: const Duration(milliseconds: 400),
|
||||
useRootNavigator: true,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user