134 lines
5.4 KiB
Dart
134 lines
5.4 KiB
Dart
import 'package:SEFER/constant/colors.dart';
|
|
import 'package:SEFER/constant/style.dart';
|
|
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
|
import 'package:SEFER/views/widgets/my_textField.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../../../controller/auth/captin/invit_controller.dart';
|
|
|
|
class InviteDriverScreen extends StatelessWidget {
|
|
final InviteController controller = Get.put(InviteController());
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: Text('Invite a Driver'.tr)),
|
|
body: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
"Invite another driver and both get a gift after he completes 100 trips!"
|
|
.tr,
|
|
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
|
),
|
|
const SizedBox(height: 20),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: MyTextForm(
|
|
controller: controller.invitePhoneController,
|
|
label: 'Enter driver\'s phone'.tr,
|
|
hint: 'Enter driver\'s phone'.tr,
|
|
type: TextInputType.phone,
|
|
),
|
|
),
|
|
IconButton(
|
|
icon: Icon(Icons.contacts),
|
|
onPressed: () async {
|
|
await controller.pickContact();
|
|
},
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 20),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
MyElevatedButton(
|
|
title: 'Send Invite'.tr,
|
|
onPressed: controller.sendInvite,
|
|
),
|
|
MyElevatedButton(
|
|
title: 'Show Invitations'.tr,
|
|
onPressed: () async {
|
|
controller.fetchDriverStats();
|
|
},
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 20),
|
|
GetBuilder<InviteController>(builder: (controller) {
|
|
return SizedBox(
|
|
height: Get.height * .4,
|
|
child: controller.driverInvitationData.isEmpty
|
|
? Center(
|
|
child: Text(
|
|
"No invitation found yet!".tr,
|
|
style: AppStyle.title,
|
|
),
|
|
)
|
|
: ListView.builder(
|
|
itemCount: controller.driverInvitationData.length,
|
|
itemBuilder: (context, index) {
|
|
int countOfInvitDriver = 0;
|
|
if (controller.driverInvitationData[index]
|
|
.containsKey('countOfInvitDriver')) {
|
|
countOfInvitDriver = int.tryParse(controller
|
|
.driverInvitationData[index]
|
|
['countOfInvitDriver']
|
|
.toString()) ??
|
|
0;
|
|
}
|
|
|
|
double progressValue = countOfInvitDriver / 100.0;
|
|
if (progressValue > 1.0) progressValue = 1.0;
|
|
if (progressValue < 0.0) progressValue = 0.0;
|
|
|
|
return InkWell(
|
|
onTap: () async {
|
|
controller.onSelectDriverInvitation(index);
|
|
},
|
|
child: Container(
|
|
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
|
child: Stack(
|
|
alignment: AlignmentDirectional.center,
|
|
children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(12),
|
|
color:
|
|
AppColor.accentColor.withOpacity(.5),
|
|
),
|
|
width: Get.width * .85,
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(12),
|
|
child: LinearProgressIndicator(
|
|
value: progressValue,
|
|
color: AppColor.blueColor,
|
|
backgroundColor: AppColor.accentColor
|
|
.withOpacity(.3),
|
|
minHeight: 35,
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
'${controller.driverInvitationData[index]['invitorName']} ${controller.driverInvitationData[index]['countOfInvitDriver']} / 100 ${'Trip'.tr}',
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
})
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|