|
@@ -19,19 +19,18 @@ class PhotoChat extends StatefulWidget {
|
|
|
final bool? isBroadcast;
|
|
final bool? isBroadcast;
|
|
|
final Uint8List? image;
|
|
final Uint8List? image;
|
|
|
|
|
|
|
|
- PhotoChat(this.data, this.media, this.isBroadcast, this.image);
|
|
|
|
|
|
|
+ const PhotoChat(this.data, this.media, this.isBroadcast, this.image, {super.key});
|
|
|
|
|
|
|
|
@override
|
|
@override
|
|
|
- _PhotoChatState createState() => _PhotoChatState();
|
|
|
|
|
|
|
+ PhotoChatState createState() => PhotoChatState();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-class _PhotoChatState extends State<PhotoChat> {
|
|
|
|
|
|
|
+class PhotoChatState extends State<PhotoChat> {
|
|
|
final ApiAuthProvider apiAuthProvider = ApiAuthProvider();
|
|
final ApiAuthProvider apiAuthProvider = ApiAuthProvider();
|
|
|
- TextEditingController controllerPesan = new TextEditingController();
|
|
|
|
|
|
|
+ TextEditingController controllerPesan = TextEditingController();
|
|
|
Uint8List? image;
|
|
Uint8List? image;
|
|
|
|
|
|
|
|
Future getImage() async {
|
|
Future getImage() async {
|
|
|
-// print('photochat in');
|
|
|
|
|
XFile? pickedFile;
|
|
XFile? pickedFile;
|
|
|
if(widget.media == ImageSource.camera){
|
|
if(widget.media == ImageSource.camera){
|
|
|
await availableCameras().then((camera) => Navigator.push(context, PageTransition(type: PageTransitionType.rightToLeft, child: OpenCamera(cameras: camera))).then((value) async{
|
|
await availableCameras().then((camera) => Navigator.push(context, PageTransition(type: PageTransitionType.rightToLeft, child: OpenCamera(cameras: camera))).then((value) async{
|
|
@@ -45,12 +44,12 @@ class _PhotoChatState extends State<PhotoChat> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (pickedFile != null) {
|
|
if (pickedFile != null) {
|
|
|
- var imagess = img.decodeImage(await pickedFile!.readAsBytes());
|
|
|
|
|
- var imgPercent = (1000 / (imagess!.width / 100)).toDouble();
|
|
|
|
|
- if (imagess.width > 1000) {
|
|
|
|
|
- imagess = img.copyResize(imagess, width: ((imagess.width / 100) * imgPercent).toInt(), height: ((imagess.height / 100) * imgPercent).toInt());
|
|
|
|
|
|
|
+ var images = img.decodeImage(await pickedFile!.readAsBytes());
|
|
|
|
|
+ var imgPercent = (1000 / (images!.width / 100)).toDouble();
|
|
|
|
|
+ if (images.width > 1000) {
|
|
|
|
|
+ images = img.copyResize(images, width: ((images.width / 100) * imgPercent).toInt(), height: ((images.height / 100) * imgPercent).toInt());
|
|
|
}
|
|
}
|
|
|
- var compressed = img.encodeJpg(imagess, quality: 60);
|
|
|
|
|
|
|
+ var compressed = img.encodeJpg(images, quality: 60);
|
|
|
setState(() => image = compressed);
|
|
setState(() => image = compressed);
|
|
|
} else {
|
|
} else {
|
|
|
Navigator.of(context).pop(null);
|
|
Navigator.of(context).pop(null);
|
|
@@ -97,7 +96,6 @@ class _PhotoChatState extends State<PhotoChat> {
|
|
|
Container(
|
|
Container(
|
|
|
alignment: Alignment.bottomCenter,
|
|
alignment: Alignment.bottomCenter,
|
|
|
child: Container(
|
|
child: Container(
|
|
|
-// width: double.infinity,
|
|
|
|
|
padding: const EdgeInsets.all(10),
|
|
padding: const EdgeInsets.all(10),
|
|
|
color: Colors.black54,
|
|
color: Colors.black54,
|
|
|
child: Row(
|
|
child: Row(
|
|
@@ -129,12 +127,12 @@ class _PhotoChatState extends State<PhotoChat> {
|
|
|
height: 50,
|
|
height: 50,
|
|
|
child: ElevatedButton(
|
|
child: ElevatedButton(
|
|
|
style: ButtonStyle(
|
|
style: ButtonStyle(
|
|
|
- backgroundColor: MaterialStateProperty.all<Color>(primaryColor),
|
|
|
|
|
- shape: MaterialStateProperty.all<RoundedRectangleBorder>(RoundedRectangleBorder(
|
|
|
|
|
|
|
+ backgroundColor: WidgetStateProperty.all<Color>(primaryColor),
|
|
|
|
|
+ shape: WidgetStateProperty.all<RoundedRectangleBorder>(RoundedRectangleBorder(
|
|
|
borderRadius: BorderRadius.circular(50),
|
|
borderRadius: BorderRadius.circular(50),
|
|
|
)),
|
|
)),
|
|
|
- elevation: MaterialStateProperty.all(2),
|
|
|
|
|
- padding: MaterialStateProperty.all(const EdgeInsets.only(left: 1)),
|
|
|
|
|
|
|
+ elevation: WidgetStateProperty.all(2),
|
|
|
|
|
+ padding: WidgetStateProperty.all(const EdgeInsets.only(left: 1)),
|
|
|
),
|
|
),
|
|
|
child: Image.asset('assets/image/icon/Send.png', width: 25, height: 25),
|
|
child: Image.asset('assets/image/icon/Send.png', width: 25, height: 25),
|
|
|
onPressed: () async {
|
|
onPressed: () async {
|