forked from eatvio/eatvio_app
refactor(fix): performance metrics
This commit is contained in:
@@ -88,19 +88,24 @@ class ChatScreen extends StatelessWidget {
|
||||
child: Container(
|
||||
color: Color(0xFFF0F2F5),
|
||||
width: double.maxFinite,
|
||||
child: ListView.builder(
|
||||
child: CustomScrollView(
|
||||
reverse: true,
|
||||
padding: EdgeInsets.symmetric(vertical: 16),
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return ChatBubbleWidget(
|
||||
text: state.chatRoomModel.messages[state.chatRoomModel.messages.length - index - 1].data,
|
||||
isCurrentUser:
|
||||
state.chatRoomModel.users['to_chat_user']!.id != state.chatRoomModel.messages[state.chatRoomModel.messages.length - index - 1].authorId,
|
||||
mediaData: state.chatRoomModel.messages[state.chatRoomModel.messages.length - index - 1].mediaData,
|
||||
);
|
||||
},
|
||||
itemCount: state.chatRoomModel.messages.length,
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.symmetric(vertical: 16),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) => ChatBubbleWidget(
|
||||
text: state.chatRoomModel.messages[state.chatRoomModel.messages.length - index - 1].data,
|
||||
isCurrentUser: state.chatRoomModel.users['to_chat_user']!.id !=
|
||||
state.chatRoomModel.messages[state.chatRoomModel.messages.length - index - 1].authorId,
|
||||
mediaData: state.chatRoomModel.messages[state.chatRoomModel.messages.length - index - 1].mediaData,
|
||||
),
|
||||
childCount: state.chatRoomModel.messages.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -112,7 +117,7 @@ class ChatScreen extends StatelessWidget {
|
||||
SizedBox(width: 8),
|
||||
InkWell(
|
||||
onTap: () {},
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
borderRadius: BorderRadiusStyle.circleBorder17,
|
||||
child: Ink(
|
||||
height: 32,
|
||||
width: 32,
|
||||
@@ -147,21 +152,21 @@ class ChatScreen extends StatelessWidget {
|
||||
),
|
||||
filled: true,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
borderRadius: BorderRadiusStyle.circleBorder17,
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFFD1D1D6),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
borderRadius: BorderRadiusStyle.circleBorder17,
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFFD1D1D6),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
borderRadius: BorderRadiusStyle.circleBorder17,
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFFD1D1D6),
|
||||
width: 1,
|
||||
@@ -172,7 +177,7 @@ class ChatScreen extends StatelessWidget {
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
InkWell(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
borderRadius: BorderRadiusStyle.circleBorder17,
|
||||
onTap: () {},
|
||||
child: Ink(
|
||||
height: 32,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
@@ -70,7 +71,7 @@ class _PhotoViewScreenState extends State<PhotoViewScreen> {
|
||||
SizedBox(height: 8),
|
||||
ListTile(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
borderRadius: BorderRadiusStyle.circleBorder17,
|
||||
),
|
||||
contentPadding: EdgeInsets.all(16),
|
||||
onTap: () async {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:eatvio_app/theme/app_decoration.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
@@ -25,69 +26,71 @@ class ChatBubbleWidget extends StatelessWidget {
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: isCurrentUser ? Color(0xFFF6FAFF) : Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
borderRadius: BorderRadiusStyle.circleBorder17,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
children: [
|
||||
if (mediaData != null)
|
||||
ListView.separated(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
CustomScrollView(
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (context, index) {
|
||||
if (!mediaData![index].toString().contains('.png') &&
|
||||
!mediaData![index].toString().contains('.jpg') &&
|
||||
!mediaData![index].toString().contains('.jpeg')) {
|
||||
return ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
horizontalTitleGap: 8,
|
||||
onTap: () async {
|
||||
if (!await launchUrl(Uri.parse(dotenv.env['STORAGE_URL']! + mediaData![index].toString()))) {
|
||||
throw Exception('Could not launch ${mediaData![index].toString()}');
|
||||
}
|
||||
},
|
||||
leading: Icon(
|
||||
Icons.file_copy_outlined,
|
||||
color: Color(0xFF2F80ED),
|
||||
),
|
||||
trailing: Icon(
|
||||
Icons.download_outlined,
|
||||
color: Color(0xFF2F80ED),
|
||||
),
|
||||
title: Text(
|
||||
mediaData![index].toString().replaceAll('chat_files/', ''),
|
||||
maxLines: 2,
|
||||
style: TextStyle(
|
||||
color: Color(0xFF323F4B),
|
||||
fontSize: 12,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
GoRouter.of(context).pushNamed(
|
||||
'photoViewScreen',
|
||||
extra: mediaData!.map((e) => dotenv.env['STORAGE_URL']! + e.toString()).toList(),
|
||||
pathParameters: {
|
||||
'index': index.toString(),
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
SliverList.separated(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
if (!mediaData![index].toString().contains('.png') &&
|
||||
!mediaData![index].toString().contains('.jpg') &&
|
||||
!mediaData![index].toString().contains('.jpeg')) {
|
||||
return ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
horizontalTitleGap: 8,
|
||||
onTap: () async {
|
||||
if (!await launchUrl(Uri.parse(dotenv.env['STORAGE_URL']! + mediaData![index].toString()))) {
|
||||
throw Exception('Could not launch ${mediaData![index].toString()}');
|
||||
}
|
||||
},
|
||||
leading: Icon(
|
||||
Icons.file_copy_outlined,
|
||||
color: Color(0xFF2F80ED),
|
||||
),
|
||||
trailing: Icon(
|
||||
Icons.download_outlined,
|
||||
color: Color(0xFF2F80ED),
|
||||
),
|
||||
title: Text(
|
||||
mediaData![index].toString().replaceAll('chat_files/', ''),
|
||||
maxLines: 2,
|
||||
style: TextStyle(
|
||||
color: Color(0xFF323F4B),
|
||||
fontSize: 12,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
GoRouter.of(context).pushNamed(
|
||||
'photoViewScreen',
|
||||
extra: mediaData!.map((e) => dotenv.env['STORAGE_URL']! + e.toString()).toList(),
|
||||
pathParameters: {
|
||||
'index': index.toString(),
|
||||
},
|
||||
);
|
||||
},
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadiusStyle.roundedBorder8,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + '${mediaData![index]}',
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + '${mediaData![index]}',
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return SizedBox(height: 8);
|
||||
},
|
||||
itemCount: mediaData!.length,
|
||||
separatorBuilder: (BuildContext context, int index) => const SizedBox(height: 8),
|
||||
itemCount: mediaData!.length,
|
||||
),
|
||||
],
|
||||
),
|
||||
if (mediaData!.length > 0 && text.isNotEmpty) SizedBox(height: 8),
|
||||
if (text.isNotEmpty)
|
||||
|
||||
Reference in New Issue
Block a user