Fix InkWell on the beneficiary image
This commit is contained in:
parent
e261710eba
commit
5a2dbf8962
@ -3,6 +3,7 @@ import 'dart:io';
|
|||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:get_it/get_it.dart';
|
||||||
import 'package:okane/database/collections/beneficiary.dart';
|
import 'package:okane/database/collections/beneficiary.dart';
|
||||||
import 'package:okane/database/database.dart';
|
import 'package:okane/database/database.dart';
|
||||||
import 'package:okane/ui/state/core.dart';
|
import 'package:okane/ui/state/core.dart';
|
||||||
@ -89,13 +90,50 @@ class TransactionDetailsPage extends StatelessWidget {
|
|||||||
title: obj.name,
|
title: obj.name,
|
||||||
path: obj.imagePath,
|
path: obj.imagePath,
|
||||||
onTap: () => _updateBeneficiaryIcon(obj),
|
onTap: () => _updateBeneficiaryIcon(obj),
|
||||||
|
width: 90,
|
||||||
|
height: 90,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.arrow_forward_rounded),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(left: 8),
|
padding: EdgeInsets.only(left: 8),
|
||||||
child: Text(
|
child: Text(
|
||||||
state.activeTransaction!.beneficiary.value!.name,
|
state
|
||||||
|
.activeTransaction!
|
||||||
|
.beneficiary
|
||||||
|
.value!
|
||||||
|
.name,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.arrow_back_rounded),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(left: 8),
|
||||||
|
child: Text(
|
||||||
|
GetIt.I
|
||||||
|
.get<CoreCubit>()
|
||||||
|
.activeAccount!
|
||||||
|
.name!,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Spacer(),
|
Spacer(),
|
||||||
@ -107,6 +145,7 @@ class TransactionDetailsPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
Wrap(
|
Wrap(
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
children:
|
children:
|
||||||
@ -114,7 +153,34 @@ class TransactionDetailsPage extends StatelessWidget {
|
|||||||
.map((tag) => Chip(label: Text(tag)))
|
.map((tag) => Chip(label: Text(tag)))
|
||||||
.toList(),
|
.toList(),
|
||||||
),
|
),
|
||||||
Row(
|
|
||||||
|
if (state.activeTransaction!.expenseCategory.value !=
|
||||||
|
null)
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 8),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text("Expense category"),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(left: 16),
|
||||||
|
child: Chip(
|
||||||
|
label: Text(
|
||||||
|
state
|
||||||
|
.activeTransaction!
|
||||||
|
.expenseCategory
|
||||||
|
.value!
|
||||||
|
.name,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 8),
|
||||||
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
state.activeTransaction!.amount > 0
|
state.activeTransaction!.amount > 0
|
||||||
? Icon(Icons.add)
|
? Icon(Icons.add)
|
||||||
@ -122,6 +188,7 @@ class TransactionDetailsPage extends StatelessWidget {
|
|||||||
Text(formatCurrency(state.activeTransaction!.amount)),
|
Text(formatCurrency(state.activeTransaction!.amount)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -1,40 +1,57 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
const _BORDER_RADIUS = 8.0;
|
||||||
|
|
||||||
class ImageWrapper extends StatelessWidget {
|
class ImageWrapper extends StatelessWidget {
|
||||||
final String title;
|
final String title;
|
||||||
final String? path;
|
final String? path;
|
||||||
final VoidCallback onTap;
|
final VoidCallback? onTap;
|
||||||
|
final double width;
|
||||||
|
final double height;
|
||||||
|
|
||||||
const ImageWrapper({
|
const ImageWrapper({
|
||||||
super.key,
|
super.key,
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.onTap,
|
this.onTap,
|
||||||
this.path,
|
this.path,
|
||||||
|
this.width = 45,
|
||||||
|
this.height = 45,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Widget widget;
|
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
widget = SizedBox(
|
return InkWell(
|
||||||
width: 45,
|
onTap: onTap,
|
||||||
height: 45,
|
borderRadius: BorderRadius.circular(_BORDER_RADIUS),
|
||||||
|
child: SizedBox(
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(_BORDER_RADIUS),
|
||||||
),
|
),
|
||||||
child: Center(child: Text(title[0])),
|
child: Center(child: Text(title[0])),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
widget = ClipRRect(
|
return ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(_BORDER_RADIUS),
|
||||||
child: Image.file(File(path!), width: 45, height: 45),
|
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:flutter/material.dart';
|
||||||
import 'package:okane/database/collections/transaction.dart';
|
import 'package:okane/database/collections/transaction.dart';
|
||||||
import 'package:okane/database/database.dart';
|
|
||||||
import 'package:okane/ui/utils.dart';
|
import 'package:okane/ui/utils.dart';
|
||||||
import 'package:okane/ui/widgets/image_wrapper.dart';
|
import 'package:okane/ui/widgets/image_wrapper.dart';
|
||||||
|
|
||||||
@ -21,12 +20,12 @@ class TransactionCard extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Card(
|
return Card(
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
leading: ImageWrapper(
|
leading: ImageWrapper(
|
||||||
title: transaction.beneficiary.value!.name,
|
title: transaction.beneficiary.value!.name,
|
||||||
path: transaction.beneficiary.value!.imagePath,
|
path: transaction.beneficiary.value!.imagePath,
|
||||||
onTap: () {},
|
|
||||||
),
|
),
|
||||||
trailing: Text(formatDateTime(transaction.date)),
|
trailing: Text(formatDateTime(transaction.date)),
|
||||||
title: Text(transaction.beneficiary.value!.name),
|
title: Text(transaction.beneficiary.value!.name),
|
||||||
|
Loading…
Reference in New Issue
Block a user