Fix InkWell on the beneficiary image
This commit is contained in:
@@ -1,40 +1,57 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
const _BORDER_RADIUS = 8.0;
|
||||
|
||||
class ImageWrapper extends StatelessWidget {
|
||||
final String title;
|
||||
final String? path;
|
||||
final VoidCallback onTap;
|
||||
final VoidCallback? onTap;
|
||||
final double width;
|
||||
final double height;
|
||||
|
||||
const ImageWrapper({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.onTap,
|
||||
this.onTap,
|
||||
this.path,
|
||||
this.width = 45,
|
||||
this.height = 45,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget widget;
|
||||
if (path == null) {
|
||||
widget = SizedBox(
|
||||
width: 45,
|
||||
height: 45,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(_BORDER_RADIUS),
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
height: height,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey,
|
||||
borderRadius: BorderRadius.circular(_BORDER_RADIUS),
|
||||
),
|
||||
child: Center(child: Text(title[0])),
|
||||
),
|
||||
child: Center(child: Text(title[0])),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
widget = ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Image.file(File(path!), width: 45, height: 45),
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(_BORDER_RADIUS),
|
||||
child: Material(
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
radius: _BORDER_RADIUS,
|
||||
child: Ink.image(
|
||||
width: width,
|
||||
height: height,
|
||||
image: FileImage(File(path!)),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return InkWell(onTap: onTap, child: widget);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:okane/database/collections/transaction.dart';
|
||||
import 'package:okane/database/database.dart';
|
||||
import 'package:okane/ui/utils.dart';
|
||||
import 'package:okane/ui/widgets/image_wrapper.dart';
|
||||
|
||||
@@ -21,12 +20,12 @@ class TransactionCard extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: ListTile(
|
||||
onTap: onTap,
|
||||
leading: ImageWrapper(
|
||||
title: transaction.beneficiary.value!.name,
|
||||
path: transaction.beneficiary.value!.imagePath,
|
||||
onTap: () {},
|
||||
),
|
||||
trailing: Text(formatDateTime(transaction.date)),
|
||||
title: Text(transaction.beneficiary.value!.name),
|
||||
|
||||
Reference in New Issue
Block a user