142 lines
4.1 KiB
Dart
142 lines
4.1 KiB
Dart
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
class CustomLongPressContainer extends StatelessWidget {
|
||
|
final bool? switchValue;
|
||
|
final List<String>? selectedIndices;
|
||
|
final List<int>? selectedRemoveIndices;
|
||
|
final void Function()? onAddToContacts;
|
||
|
final void Function()? onRemoveFromContacts;
|
||
|
final void Function()? onDownload;
|
||
|
final void Function()? onCancel;
|
||
|
final void Function()? onSaveOffline;
|
||
|
|
||
|
CustomLongPressContainer({
|
||
|
this.switchValue,
|
||
|
this.selectedIndices,
|
||
|
this.selectedRemoveIndices,
|
||
|
this.onAddToContacts,
|
||
|
this.onRemoveFromContacts,
|
||
|
this.onDownload,
|
||
|
this.onCancel,
|
||
|
this.onSaveOffline,
|
||
|
});
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Container(
|
||
|
color: Colors.grey[200], // Example color, you can change it
|
||
|
width: MediaQuery.of(context).size.width,
|
||
|
height: 220.0,
|
||
|
child: Column(
|
||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
children: [
|
||
|
// Add to Contacts Section
|
||
|
switchValue!
|
||
|
? GestureDetector(
|
||
|
onTap: onRemoveFromContacts,
|
||
|
child: Row(
|
||
|
children: [
|
||
|
const Padding(
|
||
|
padding: EdgeInsets.all(15.0),
|
||
|
child: Icon(
|
||
|
Icons.remove,
|
||
|
color: Colors.green,
|
||
|
),
|
||
|
),
|
||
|
Text(
|
||
|
'Remove from My Contacts',
|
||
|
style: TextStyle(color: Colors.black),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
)
|
||
|
: GestureDetector(
|
||
|
onTap: onAddToContacts,
|
||
|
child: Row(
|
||
|
children: [
|
||
|
const Padding(
|
||
|
padding: EdgeInsets.all(15.0),
|
||
|
child: Icon(
|
||
|
Icons.add,
|
||
|
color: Colors.green,
|
||
|
),
|
||
|
),
|
||
|
Text(
|
||
|
'Add to My Contacts',
|
||
|
style: TextStyle(color: Colors.black),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
|
||
|
// Download Section
|
||
|
GestureDetector(
|
||
|
onTap: onDownload,
|
||
|
child: Row(
|
||
|
children: [
|
||
|
const Padding(
|
||
|
padding: EdgeInsets.all(15.0),
|
||
|
child: Icon(
|
||
|
Icons.download,
|
||
|
color: Colors.blue,
|
||
|
),
|
||
|
),
|
||
|
Text(
|
||
|
'Download',
|
||
|
style: TextStyle(color: Colors.black),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
|
||
|
// Cancel Section
|
||
|
GestureDetector(
|
||
|
onTap: onCancel,
|
||
|
child: Row(
|
||
|
children: [
|
||
|
const Padding(
|
||
|
padding: EdgeInsets.all(15.0),
|
||
|
child: Icon(
|
||
|
Icons.close,
|
||
|
color: Colors.red,
|
||
|
),
|
||
|
),
|
||
|
Text(
|
||
|
'Cancel',
|
||
|
style: TextStyle(color: Colors.black),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
|
||
|
// Save Offline Section (Only if switchValue is false)
|
||
|
Visibility(
|
||
|
visible: !switchValue!,
|
||
|
child: GestureDetector(
|
||
|
onTap: onSaveOffline,
|
||
|
child: Row(
|
||
|
children: [
|
||
|
const Padding(
|
||
|
padding: EdgeInsets.all(15.0),
|
||
|
child: Icon(
|
||
|
Icons.save,
|
||
|
color: Colors.deepOrange,
|
||
|
),
|
||
|
),
|
||
|
Padding(
|
||
|
padding: EdgeInsets.only(top: 5.0),
|
||
|
child: Text(
|
||
|
'Save Offline',
|
||
|
style: TextStyle(color: Colors.black),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|