null safety conversation complete
parent
fe8ac14e46
commit
be4c8d7653
@ -1,48 +1,47 @@
|
|||||||
import 'package:another_flushbar/flushbar.dart';
|
// import 'package:another_flushbar/flushbar.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
// import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
// import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/material.dart';
|
// import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
// todo delete
|
||||||
|
// class GeneralUtils {
|
||||||
class GeneralUtils{
|
// static Duration parseTimeString(String timeString) {
|
||||||
|
// try {
|
||||||
static Duration parseTimeString(String timeString) {
|
// print('time string i got is ${timeString}');
|
||||||
try {
|
// List<String> timeParts = timeString.split(':');
|
||||||
print('time string i got is ${timeString}');
|
//
|
||||||
List<String> timeParts = timeString.split(':');
|
// int hours = int.parse(timeParts[0]);
|
||||||
|
// int minutes = int.parse(timeParts[1]);
|
||||||
int hours = int.parse(timeParts[0]);
|
// int seconds = int.parse(timeParts[2]);
|
||||||
int minutes = int.parse(timeParts[1]);
|
//
|
||||||
int seconds = int.parse(timeParts[2]);
|
// print('');
|
||||||
|
//
|
||||||
print('');
|
// return Duration(hours: hours, minutes: minutes, seconds: seconds);
|
||||||
|
// } catch (e) {
|
||||||
return Duration(hours: hours, minutes: minutes, seconds: seconds);
|
// if (kDebugMode) {
|
||||||
} catch (e) {
|
// print("Error parsing time string: $e");
|
||||||
if (kDebugMode) {
|
// }
|
||||||
print("Error parsing time string: $e");
|
// return Duration.zero; // Return zero duration in case of an error
|
||||||
}
|
// }
|
||||||
return Duration.zero; // Return zero duration in case of an error
|
// }
|
||||||
}
|
//
|
||||||
}
|
// static Widget showFlushBar({required BuildContext context, String? title, String? message, double? duration}) {
|
||||||
static Widget showFlushBar({required BuildContext context,String title,String message,double duration}){
|
// return Flushbar(
|
||||||
return Flushbar(
|
// flushbarPosition: FlushbarPosition.TOP,
|
||||||
flushbarPosition: FlushbarPosition.TOP,
|
// backgroundColor: AppColor.green70,
|
||||||
backgroundColor: AppColor.green70,
|
// title: title ?? "Hey Ninja",
|
||||||
title:title?? "Hey Ninja",
|
// message: message ?? "Lorem Ipsum is simply dummy text of the printing and typesetting industry",
|
||||||
message:message?? "Lorem Ipsum is simply dummy text of the printing and typesetting industry",
|
// duration: Duration(seconds: duration?.toInt() ?? 3),
|
||||||
duration: Duration(seconds:duration?? 3),
|
// flushbarStyle: FlushbarStyle.GROUNDED,
|
||||||
flushbarStyle: FlushbarStyle.GROUNDED,
|
// reverseAnimationCurve: Curves.easeInOut,
|
||||||
reverseAnimationCurve: Curves.easeInOut,
|
// mainButton: IconButton(
|
||||||
mainButton: IconButton(
|
// onPressed: () {
|
||||||
onPressed: () {
|
// Navigator.pop(context);
|
||||||
Navigator.pop(context);
|
// },
|
||||||
},
|
// icon: const Icon(
|
||||||
icon: const Icon(
|
// Icons.close,
|
||||||
Icons.close,
|
// color: AppColor.white20,
|
||||||
color: AppColor.white20,
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// )..show(context);
|
||||||
)..show(context);
|
// }
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
|
|||||||
@ -1,181 +1,177 @@
|
|||||||
import 'package:flutter/material.dart';
|
// import 'package:flutter/material.dart';
|
||||||
import 'package:fluttertoast/fluttertoast.dart';
|
// import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:provider/provider.dart';
|
// import 'package:provider/provider.dart';
|
||||||
import 'package:test_sa/controllers/providers/api/service_requests_provider.dart';
|
// import 'package:test_sa/controllers/providers/api/service_requests_provider.dart';
|
||||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||||
import 'package:test_sa/controllers/validator/validator.dart';
|
// import 'package:test_sa/controllers/validator/validator.dart';
|
||||||
import 'package:test_sa/extensions/context_extension.dart';
|
// import 'package:test_sa/extensions/context_extension.dart';
|
||||||
import 'package:test_sa/models/issue.dart';
|
// import 'package:test_sa/models/issue.dart';
|
||||||
import 'package:test_sa/models/service_request/service_request.dart';
|
// import 'package:test_sa/models/service_request/service_request.dart';
|
||||||
import 'package:test_sa/views/app_style/sizing.dart';
|
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||||
import 'package:test_sa/views/widgets/app_text_form_field.dart';
|
// import 'package:test_sa/views/widgets/app_text_form_field.dart';
|
||||||
import 'package:test_sa/views/widgets/buttons/app_back_button.dart';
|
// import 'package:test_sa/views/widgets/buttons/app_back_button.dart';
|
||||||
import 'package:test_sa/views/widgets/buttons/app_button.dart';
|
// import 'package:test_sa/views/widgets/buttons/app_button.dart';
|
||||||
import 'package:test_sa/views/widgets/issues/report_issue_item.dart';
|
// import 'package:test_sa/views/widgets/issues/report_issue_item.dart';
|
||||||
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
// import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||||
|
//
|
||||||
class ReportIssuesPage extends StatefulWidget {
|
// class ReportIssuesPage extends StatefulWidget {
|
||||||
static final String id = "/report-issue";
|
// static final String id = "/report-issue";
|
||||||
final ServiceRequest serviceRequest;
|
// final ServiceRequest serviceRequest;
|
||||||
|
// todo delete
|
||||||
const ReportIssuesPage({Key? key, this.serviceRequest}) : super(key: key);
|
// const ReportIssuesPage({Key? key, required this.serviceRequest}) : super(key: key);
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
_ReportIssuesPageState createState() => _ReportIssuesPageState();
|
// _ReportIssuesPageState createState() => _ReportIssuesPageState();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
class _ReportIssuesPageState extends State<ReportIssuesPage> {
|
// class _ReportIssuesPageState extends State<ReportIssuesPage> {
|
||||||
List<String> _issues = [];
|
// List<String> _issues = [];
|
||||||
Issue _issue = Issue(reports: []);
|
// Issue _issue = Issue(reports: []);
|
||||||
double _height;
|
// late double _height;
|
||||||
bool _isLoading = false;
|
// bool _isLoading = false;
|
||||||
ServiceRequestsProvider _serviceRequestsProvider;
|
// late ServiceRequestsProvider _serviceRequestsProvider;
|
||||||
UserProvider _userProvider;
|
// late UserProvider _userProvider;
|
||||||
SettingProvider _settingProvider;
|
// late SettingProvider _settingProvider;
|
||||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
// final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
Widget build(BuildContext context) {
|
// Widget build(BuildContext context) {
|
||||||
_serviceRequestsProvider = Provider.of<ServiceRequestsProvider>(context);
|
// _serviceRequestsProvider = Provider.of<ServiceRequestsProvider>(context);
|
||||||
_userProvider = Provider.of<UserProvider>(context);
|
// _userProvider = Provider.of<UserProvider>(context);
|
||||||
_settingProvider = Provider.of<SettingProvider>(context);
|
// _settingProvider = Provider.of<SettingProvider>(context);
|
||||||
_height = MediaQuery.of(context).size.height;
|
// _height = MediaQuery.of(context).size.height;
|
||||||
|
//
|
||||||
return Scaffold(
|
// return Scaffold(
|
||||||
body: SafeArea(
|
// body: SafeArea(
|
||||||
child: Form(
|
// child: Form(
|
||||||
key: _formKey,
|
// key: _formKey,
|
||||||
child: LoadingManager(
|
// child: LoadingManager(
|
||||||
onRefresh: () async {},
|
// onRefresh: () async {},
|
||||||
stateCode: 200,
|
// stateCode: 200,
|
||||||
isFailedLoading: false,
|
// isFailedLoading: false,
|
||||||
isLoading: _isLoading,
|
// isLoading: _isLoading,
|
||||||
child: Stack(
|
// child: Stack(
|
||||||
children: [
|
// children: [
|
||||||
SingleChildScrollView(
|
// SingleChildScrollView(
|
||||||
child: Column(
|
// child: Column(
|
||||||
children: [
|
// children: [
|
||||||
Center(
|
// Center(
|
||||||
child: Padding(
|
// child: Padding(
|
||||||
padding: EdgeInsets.symmetric(
|
// padding: EdgeInsets.symmetric(
|
||||||
horizontal: 16 * AppStyle.getScaleFactor(context),
|
// horizontal: 16 * AppStyle.getScaleFactor(context),
|
||||||
vertical: 24 * AppStyle.getScaleFactor(context),
|
// vertical: 24 * AppStyle.getScaleFactor(context),
|
||||||
),
|
// ),
|
||||||
child: Text(
|
// child: Text(
|
||||||
context.translation.reportIssue,
|
// context.translation.reportIssue,
|
||||||
// style: Theme.of(context).textTheme.headline5.copyWith(color: AColors.cyan, fontWeight: FontWeight.bold),
|
// // style: Theme.of(context).textTheme.headline5.copyWith(color: AColors.cyan, fontWeight: FontWeight.bold),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
Image(
|
// Image(
|
||||||
height: _height / 8,
|
// height: _height / 8,
|
||||||
image: AssetImage("assets/images/logo.png"),
|
// image: AssetImage("assets/images/logo.png"),
|
||||||
),
|
// ),
|
||||||
Container(
|
// Container(
|
||||||
padding: EdgeInsets.symmetric(
|
// padding: EdgeInsets.symmetric(
|
||||||
horizontal: 16,
|
// horizontal: 16,
|
||||||
vertical: 16,
|
// vertical: 16,
|
||||||
),
|
// ),
|
||||||
decoration: BoxDecoration(
|
// decoration: BoxDecoration(
|
||||||
// color: AColors.grey,
|
// // color: AColors.grey,
|
||||||
borderRadius: BorderRadius.only(
|
// borderRadius: BorderRadius.only(
|
||||||
topLeft: Radius.circular(AppStyle.getBorderRadius(context)),
|
// topLeft: Radius.circular(AppStyle.getBorderRadius(context)),
|
||||||
topRight: Radius.circular(AppStyle.getBorderRadius(context)),
|
// topRight: Radius.circular(AppStyle.getBorderRadius(context)),
|
||||||
),
|
// ),
|
||||||
boxShadow: [
|
// boxShadow: [
|
||||||
BoxShadow(
|
// BoxShadow(
|
||||||
// color: AColors.grey,
|
// // color: AColors.grey,
|
||||||
offset: Offset(0, -1),
|
// offset: Offset(0, -1),
|
||||||
)
|
// )
|
||||||
]),
|
// ]),
|
||||||
child: Column(
|
// child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
// children: [
|
||||||
ATextFormField(
|
// ATextFormField(
|
||||||
initialValue: _issue?.title,
|
// initialValue: _issue?.title,
|
||||||
hintText: context.translation.title,
|
// hintText: context.translation.title,
|
||||||
textAlign: TextAlign.center,
|
// textAlign: TextAlign.center,
|
||||||
style: Theme.of(context).textTheme.headline6,
|
// style: Theme.of(context).textTheme.titleLarge,
|
||||||
validator: (value) => Validator.hasValue(value) ? null : context.translation.titleValidateMessage,
|
// validator: (value) => Validator.hasValue(value ?? "") ? null : context.translation.titleValidateMessage,
|
||||||
textInputType: TextInputType.name,
|
// textInputType: TextInputType.name,
|
||||||
onSaved: (value) {
|
// onSaved: (value) {
|
||||||
_issue.title = value;
|
// _issue.title = value;
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
SizedBox(
|
// SizedBox(
|
||||||
height: 8,
|
// height: 8,
|
||||||
),
|
// ),
|
||||||
Column(
|
// Column(
|
||||||
children: List.generate(
|
// children: List.generate(
|
||||||
_issues.length,
|
// _issues.length,
|
||||||
(index) => ReportIssueItem(
|
// (index) => ReportIssueItem(
|
||||||
isSelected: _issue.reports.contains(index),
|
// isSelected: _issue.reports!.contains(index) ?? false,
|
||||||
issueInfo: _issues[index],
|
// issueInfo: _issues[index],
|
||||||
onChange: (info, value) {
|
// onChange: (info, value) {
|
||||||
if (value) {
|
// if (value) {
|
||||||
_issue.reports.add(index);
|
// _issue.reports!.add(index);
|
||||||
} else {
|
// } else {
|
||||||
_issue.reports.remove(index);
|
// _issue.reports!.remove(index);
|
||||||
}
|
// }
|
||||||
setState(() {});
|
// setState(() {});
|
||||||
},
|
// },
|
||||||
))),
|
// ))),
|
||||||
Padding(
|
// Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
// padding: const EdgeInsets.all(8.0),
|
||||||
child: Text(
|
// child: Text(
|
||||||
"${context.translation.shareAntherIssue} :",
|
// "${context.translation.shareAntherIssue} :",
|
||||||
style: Theme.of(context).textTheme.headline6,
|
// style: Theme.of(context).textTheme.titleLarge,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
ATextFormField(
|
// ATextFormField(
|
||||||
hintText: context.translation.description,
|
// hintText: context.translation.description,
|
||||||
style: Theme.of(context).textTheme.subtitle1,
|
// style: Theme.of(context).textTheme.titleMedium,
|
||||||
textInputType: TextInputType.multiline,
|
// textInputType: TextInputType.multiline,
|
||||||
onSaved: (value) {
|
// onSaved: (value) {
|
||||||
_issue.description = value;
|
// _issue.description = value;
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
Padding(
|
// Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
// padding: const EdgeInsets.all(8.0),
|
||||||
child: AButton(
|
// child: AButton(
|
||||||
text: context.translation.submit,
|
// text: context.translation.submit,
|
||||||
onPressed: () async {
|
// onPressed: () async {
|
||||||
if (!_formKey.currentState.validate()) return;
|
// if (!_formKey.currentState!.validate()) return;
|
||||||
_formKey.currentState.save();
|
// _formKey.currentState!.save();
|
||||||
_issue.serviceRequestId = widget.serviceRequest.id;
|
// _issue.serviceRequestId = widget.serviceRequest.id;
|
||||||
_isLoading = true;
|
// _isLoading = true;
|
||||||
setState(() {});
|
// setState(() {});
|
||||||
int status = await _serviceRequestsProvider.createIssueReport(
|
// int status = await _serviceRequestsProvider.createIssueReport(user: _userProvider.user!, host: _settingProvider.host!, issue: _issue);
|
||||||
user: _userProvider.user,
|
// _isLoading = false;
|
||||||
host: _settingProvider.host,
|
// setState(() {});
|
||||||
issue: _issue,
|
// if (status >= 200 && status < 300) {
|
||||||
);
|
// Fluttertoast.showToast(
|
||||||
_isLoading = false;
|
// msg: context.translation.successfulRequestMessage,
|
||||||
setState(() {});
|
// );
|
||||||
if (status >= 200 && status < 300) {
|
// Navigator.of(context).pop();
|
||||||
Fluttertoast.showToast(
|
// }
|
||||||
msg: context.translation.successfulRequestMessage,
|
// _isLoading = false;
|
||||||
);
|
// setState(() {});
|
||||||
Navigator.of(context).pop();
|
// },
|
||||||
}
|
// ),
|
||||||
_isLoading = false;
|
// ),
|
||||||
setState(() {});
|
// ],
|
||||||
},
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ],
|
||||||
],
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ABackButton(),
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
ABackButton(),
|
// ),
|
||||||
],
|
// ),
|
||||||
),
|
// );
|
||||||
),
|
// }
|
||||||
),
|
// }
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,51 +1,51 @@
|
|||||||
import 'package:flutter/material.dart';
|
// import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
// import 'package:provider/provider.dart';
|
||||||
import 'package:test_sa/controllers/providers/api/service_requests_provider.dart';
|
// import 'package:test_sa/controllers/providers/api/service_requests_provider.dart';
|
||||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||||
import 'package:test_sa/extensions/context_extension.dart';
|
// import 'package:test_sa/extensions/context_extension.dart';
|
||||||
import 'package:test_sa/models/service_request/service_request.dart';
|
// import 'package:test_sa/models/service_request/service_request.dart';
|
||||||
import 'package:test_sa/views/pages/user/requests/service_request_details.dart';
|
// import 'package:test_sa/views/pages/user/requests/service_request_details.dart';
|
||||||
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
|
// import 'package:test_sa/views/widgets/loaders/app_loading.dart';
|
||||||
import 'package:test_sa/views/widgets/loaders/failed_loading.dart';
|
// import 'package:test_sa/views/widgets/loaders/failed_loading.dart';
|
||||||
|
//
|
||||||
class FutureRequestServiceDetails extends StatefulWidget {
|
// class FutureRequestServiceDetails extends StatefulWidget {
|
||||||
static final String id = "/service-request-details";
|
// static final String id = "/service-request-details";
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
_FutureRequestServiceDetailsState createState() => _FutureRequestServiceDetailsState();
|
// _FutureRequestServiceDetailsState createState() => _FutureRequestServiceDetailsState();
|
||||||
}
|
// }
|
||||||
|
// todo delete
|
||||||
class _FutureRequestServiceDetailsState extends State<FutureRequestServiceDetails> {
|
// class _FutureRequestServiceDetailsState extends State<FutureRequestServiceDetails> {
|
||||||
UserProvider _userProvider;
|
// UserProvider _userProvider;
|
||||||
SettingProvider _settingProvider;
|
// SettingProvider _settingProvider;
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
Widget build(BuildContext context) {
|
// Widget build(BuildContext context) {
|
||||||
_userProvider = Provider.of<UserProvider>(context);
|
// _userProvider = Provider.of<UserProvider>(context);
|
||||||
_settingProvider = Provider.of<SettingProvider>(context);
|
// _settingProvider = Provider.of<SettingProvider>(context);
|
||||||
String requestId = ModalRoute.of(context).settings.arguments;
|
// String requestId = ModalRoute.of(context).settings.arguments;
|
||||||
|
//
|
||||||
return Scaffold(
|
// return Scaffold(
|
||||||
body: FutureBuilder<ServiceRequest>(
|
// body: FutureBuilder<ServiceRequest>(
|
||||||
future: ServiceRequestsProvider().getSingleServiceRequest(requestId: requestId, user: _userProvider.user, host: _settingProvider.host, subtitle: context.translation),
|
// future: ServiceRequestsProvider().getSingleServiceRequest(requestId: requestId, user: _userProvider.user, host: _settingProvider.host, subtitle: context.translation),
|
||||||
builder: (BuildContext context, AsyncSnapshot<ServiceRequest> snapshot) {
|
// builder: (BuildContext context, AsyncSnapshot<ServiceRequest> snapshot) {
|
||||||
if (snapshot.hasError) {
|
// if (snapshot.hasError) {
|
||||||
return FailedLoading(
|
// return FailedLoading(
|
||||||
message: snapshot.error.toString(),
|
// message: snapshot.error.toString(),
|
||||||
onReload: () {
|
// onReload: () {
|
||||||
setState(() {});
|
// setState(() {});
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
if (snapshot.hasData) {
|
// if (snapshot.hasData) {
|
||||||
return ServiceRequestDetailsPage(
|
// return ServiceRequestDetailsPage(
|
||||||
serviceRequest: snapshot.data,
|
// serviceRequest: snapshot.data,
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
return Center(child: ALoading());
|
// return Center(child: ALoading());
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|||||||
@ -1,32 +1,32 @@
|
|||||||
import 'package:flutter/material.dart';
|
// import 'package:flutter/material.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
// import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:test_sa/views/app_style/sizing.dart';
|
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||||
|
//
|
||||||
class AIconButton2 extends StatelessWidget {
|
// class AIconButton2 extends StatelessWidget {
|
||||||
final IconData iconData;
|
// final IconData iconData;
|
||||||
final Color color;
|
// final Color color;
|
||||||
final VoidCallback onPressed;
|
// final VoidCallback onPressed;
|
||||||
|
//
|
||||||
const AIconButton2({
|
// const AIconButton2({todo delete
|
||||||
Key? key,
|
// Key? key,
|
||||||
this.iconData,
|
// this.iconData,
|
||||||
this.onPressed,
|
// this.onPressed,
|
||||||
this.color,
|
// this.color,
|
||||||
}) : super(key: key);
|
// }) : super(key: key);
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
Widget build(BuildContext context) {
|
// Widget build(BuildContext context) {
|
||||||
return Material(
|
// return Material(
|
||||||
color: Colors.transparent,
|
// color: Colors.transparent,
|
||||||
child: IconButton(
|
// child: IconButton(
|
||||||
highlightColor: color?.withOpacity(.5) ?? Theme.of(context).colorScheme.secondary.withOpacity(.5),
|
// highlightColor: color?.withOpacity(.5) ?? Theme.of(context).colorScheme.secondary.withOpacity(.5),
|
||||||
color: color ?? Theme.of(context).colorScheme.secondary,
|
// color: color ?? Theme.of(context).colorScheme.secondary,
|
||||||
icon: FaIcon(
|
// icon: FaIcon(
|
||||||
iconData,
|
// iconData,
|
||||||
size: 24 * AppStyle.getScaleFactor(context),
|
// size: 24 * AppStyle.getScaleFactor(context),
|
||||||
),
|
// ),
|
||||||
onPressed: onPressed,
|
// onPressed: onPressed,
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|||||||
@ -1,29 +1,29 @@
|
|||||||
import 'package:flutter/material.dart';
|
// import 'package:flutter/material.dart';
|
||||||
|
//
|
||||||
class RoundedBackButton extends StatelessWidget {
|
// class RoundedBackButton extends StatelessWidget {
|
||||||
final VoidCallback onPressed;
|
// final VoidCallback onPressed;
|
||||||
final IconData icon;
|
// final IconData icon;
|
||||||
final Color backgroundColor;
|
// final Color backgroundColor;
|
||||||
final Color iconColor;
|
// final Color iconColor; todo delete
|
||||||
|
//
|
||||||
const RoundedBackButton({Key? key, this.onPressed,required this.icon,this.backgroundColor,this.iconColor}) : super(key: key);
|
// const RoundedBackButton({Key? key, this.onPressed,required this.icon,this.backgroundColor,this.iconColor}) : super(key: key);
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
Widget build(BuildContext context) {
|
// Widget build(BuildContext context) {
|
||||||
return Container(
|
// return Container(
|
||||||
padding: const EdgeInsets.only(left: 8),
|
// padding: const EdgeInsets.only(left: 8),
|
||||||
decoration: BoxDecoration(
|
// decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
// shape: BoxShape.circle,
|
||||||
color: backgroundColor??Colors.blue, // Background color of the circle
|
// color: backgroundColor??Colors.blue, // Background color of the circle
|
||||||
),
|
// ),
|
||||||
child: Padding(
|
// child: Padding(
|
||||||
padding: const EdgeInsets.all(8),
|
// padding: const EdgeInsets.all(8),
|
||||||
child: Icon(
|
// child: Icon(
|
||||||
icon,
|
// icon,
|
||||||
color: iconColor??Colors.white,
|
// color: iconColor??Colors.white,
|
||||||
size: 22, // Adjust the icon size as needed
|
// size: 22, // Adjust the icon size as needed
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|||||||
@ -1,90 +1,90 @@
|
|||||||
import 'package:flutter/material.dart';
|
// import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
// import 'package:provider/provider.dart';
|
||||||
import 'package:test_sa/controllers/providers/api/hospitals_provider.dart';
|
// import 'package:test_sa/controllers/providers/api/hospitals_provider.dart';
|
||||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||||
import 'package:test_sa/extensions/context_extension.dart';
|
// import 'package:test_sa/extensions/context_extension.dart';
|
||||||
import 'package:test_sa/models/hospital.dart';
|
// import 'package:test_sa/models/hospital.dart';
|
||||||
import 'package:test_sa/views/widgets/hospitals/hospital_item.dart';
|
// import 'package:test_sa/views/widgets/hospitals/hospital_item.dart';
|
||||||
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
// import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||||
import 'package:test_sa/views/widgets/loaders/no_item_found.dart';
|
// import 'package:test_sa/views/widgets/loaders/no_item_found.dart';
|
||||||
|
//
|
||||||
import '../app_text_form_field.dart';
|
// import '../app_text_form_field.dart';
|
||||||
|
//
|
||||||
class SingleHospitalPicker extends StatefulWidget {
|
// class SingleHospitalPicker extends StatefulWidget {
|
||||||
static final String id = "/single-Hospital-Picker";
|
// static final String id = "/single-Hospital-Picker";
|
||||||
final bool sandraChoice = true;
|
// final bool sandraChoice = true;
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
_SingleHospitalPickerState createState() => _SingleHospitalPickerState();
|
// _SingleHospitalPickerState createState() => _SingleHospitalPickerState();
|
||||||
}
|
// }
|
||||||
|
// todo delete
|
||||||
class _SingleHospitalPickerState extends State<SingleHospitalPicker> {
|
// class _SingleHospitalPickerState extends State<SingleHospitalPicker> {
|
||||||
HospitalsProvider _hospitalsProvider;
|
// late HospitalsProvider _hospitalsProvider;
|
||||||
SettingProvider _settingProvider;
|
// SettingProvider _settingProvider;
|
||||||
List<Hospital> _searchableList = [];
|
// List<Hospital> _searchableList = [];
|
||||||
bool _firstTime = true;
|
// bool _firstTime = true;
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
Widget build(BuildContext context) {
|
// Widget build(BuildContext context) {
|
||||||
_hospitalsProvider = Provider.of<HospitalsProvider>(context);
|
// _hospitalsProvider = Provider.of<HospitalsProvider>(context);
|
||||||
_settingProvider = Provider.of<SettingProvider>(context);
|
// _settingProvider = Provider.of<SettingProvider>(context);
|
||||||
if (_firstTime && _hospitalsProvider.hospitals != null) {
|
// if (_firstTime && _hospitalsProvider.hospitals != null) {
|
||||||
_searchableList.addAll(_hospitalsProvider.hospitals);
|
// _searchableList.addAll(_hospitalsProvider.hospitals);
|
||||||
_firstTime = false;
|
// _firstTime = false;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return Scaffold(
|
// return Scaffold(
|
||||||
resizeToAvoidBottomInset: false,
|
// resizeToAvoidBottomInset: false,
|
||||||
body: LoadingManager(
|
// body: LoadingManager(
|
||||||
isLoading: _hospitalsProvider.isLoading,
|
// isLoading: _hospitalsProvider.isLoading,
|
||||||
stateCode: _hospitalsProvider.stateCode,
|
// stateCode: _hospitalsProvider.stateCode,
|
||||||
isFailedLoading: _hospitalsProvider.hospitals == null,
|
// isFailedLoading: _hospitalsProvider.hospitals == null,
|
||||||
onRefresh: () async {
|
// onRefresh: () async {
|
||||||
_hospitalsProvider.reset();
|
// _hospitalsProvider.reset();
|
||||||
await _hospitalsProvider.getHospitals(
|
// await _hospitalsProvider.getHospitals(
|
||||||
host: _settingProvider.host,
|
// host: _settingProvider.host,
|
||||||
);
|
// );
|
||||||
},
|
// },
|
||||||
child: Column(
|
// child: Column(
|
||||||
children: [
|
// children: [
|
||||||
SizedBox(
|
// SizedBox(
|
||||||
height: 48,
|
// height: 48,
|
||||||
),
|
// ),
|
||||||
Padding(
|
// Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
// padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||||
child: ATextFormField(
|
// child: ATextFormField(
|
||||||
hintText: context.translation.searchByName,
|
// hintText: context.translation.searchByName,
|
||||||
style: Theme.of(context).textTheme.headline6,
|
// style: Theme.of(context).textTheme.titleLarge,
|
||||||
suffixIcon: Icon(Icons.search_rounded),
|
// suffixIcon: Icon(Icons.search_rounded),
|
||||||
onChange: (value) {
|
// onChange: (value) {
|
||||||
_searchableList.clear();
|
// _searchableList.clear();
|
||||||
_searchableList.addAll(_hospitalsProvider.hospitals.where((element) => element.name.toLowerCase().contains(value.toLowerCase())).toList());
|
// _searchableList.addAll(_hospitalsProvider.hospitals.where((element) => element.name.toLowerCase().contains(value.toLowerCase())).toList());
|
||||||
setState(() {});
|
// setState(() {});
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
Expanded(
|
// Expanded(
|
||||||
child: _searchableList.isEmpty
|
// child: _searchableList.isEmpty
|
||||||
? NoItemFound(
|
// ? NoItemFound(
|
||||||
message: context.translation.noHospitalFound,
|
// message: context.translation.noHospitalFound,
|
||||||
)
|
// )
|
||||||
: ListView.builder(
|
// : ListView.builder(
|
||||||
padding: EdgeInsets.zero,
|
// padding: EdgeInsets.zero,
|
||||||
shrinkWrap: true,
|
// shrinkWrap: true,
|
||||||
itemCount: _searchableList.length,
|
// itemCount: _searchableList.length,
|
||||||
itemBuilder: (listContext, itemIndex) {
|
// itemBuilder: (listContext, itemIndex) {
|
||||||
return HospitalItem(
|
// return HospitalItem(
|
||||||
hospital: _searchableList[itemIndex],
|
// hospital: _searchableList[itemIndex],
|
||||||
onPressed: (hospital) {
|
// onPressed: (hospital) {
|
||||||
Navigator.of(context).pop(hospital);
|
// Navigator.of(context).pop(hospital);
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|||||||
@ -1,61 +1,56 @@
|
|||||||
import 'package:flutter/material.dart';
|
// import 'package:flutter/material.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
// import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:test_sa/views/app_style/sizing.dart';
|
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||||
import 'package:test_sa/views/widgets/loaders/image_loader.dart';
|
// import 'package:test_sa/views/widgets/loaders/image_loader.dart';
|
||||||
|
//
|
||||||
class ImageItem extends StatelessWidget {
|
// class ImageItem extends StatelessWidget {
|
||||||
final String url;
|
// final String url;
|
||||||
final bool isVideo;
|
// final bool isVideo;
|
||||||
final VoidCallback onPressed;
|
// final VoidCallback onPressed;
|
||||||
|
// todo delete
|
||||||
const ImageItem({Key? key, this.url, this.isVideo = false, this.onPressed}) : super(key: key);
|
// const ImageItem({Key? key,required this.url, this.isVideo = false, this.onPressed}) : super(key: key);
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
Widget build(BuildContext context) {
|
// Widget build(BuildContext context) {
|
||||||
return Container(
|
// return Container(
|
||||||
width: 80 * AppStyle.getScaleFactor(context),
|
// width: 80 * AppStyle.getScaleFactor(context),
|
||||||
height: 40 * AppStyle.getScaleFactor(context),
|
// height: 40 * AppStyle.getScaleFactor(context),
|
||||||
margin: EdgeInsets.symmetric(
|
// margin: EdgeInsets.symmetric(
|
||||||
horizontal: 4 * AppStyle.getScaleFactor(context),
|
// horizontal: 4 * AppStyle.getScaleFactor(context),
|
||||||
),
|
// ),
|
||||||
decoration: BoxDecoration(
|
// decoration: BoxDecoration(
|
||||||
border: Border.all(
|
// border: Border.all(
|
||||||
color: Theme.of(context).dividerColor,
|
// color: Theme.of(context).dividerColor,
|
||||||
width: 2 * AppStyle.getScaleFactor(context),
|
// width: 2 * AppStyle.getScaleFactor(context),
|
||||||
),
|
// ),
|
||||||
borderRadius: BorderRadius.circular(8 * AppStyle.getScaleFactor(context)),
|
// borderRadius: BorderRadius.circular(8 * AppStyle.getScaleFactor(context)),
|
||||||
),
|
// ),
|
||||||
child: ClipRRect(
|
// child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(6 * AppStyle.getScaleFactor(context)),
|
// borderRadius: BorderRadius.circular(6 * AppStyle.getScaleFactor(context)),
|
||||||
child: Stack(
|
// child: Stack(
|
||||||
fit: StackFit.expand,
|
// fit: StackFit.expand,
|
||||||
alignment: Alignment.center,
|
// alignment: Alignment.center,
|
||||||
children: [
|
// children: [
|
||||||
ImageLoader(
|
// ImageLoader(url: url),
|
||||||
url: url,
|
// MaterialButton(
|
||||||
),
|
// onPressed: onPressed,
|
||||||
MaterialButton(
|
// padding: EdgeInsets.zero,
|
||||||
onPressed: onPressed,
|
// child: Visibility(
|
||||||
padding: EdgeInsets.zero,
|
// visible: isVideo,
|
||||||
child: Visibility(
|
// child: Center(
|
||||||
visible: isVideo,
|
// child: Container(
|
||||||
child: Center(
|
// decoration: BoxDecoration(color: Colors.black45, shape: BoxShape.circle),
|
||||||
child: Container(
|
// child: FaIcon(
|
||||||
decoration: BoxDecoration(
|
// FontAwesomeIcons.playCircle,
|
||||||
color: Colors.black45,
|
// size: 32 * AppStyle.getScaleFactor(context),
|
||||||
shape: BoxShape.circle,
|
// // color: AColors.orange,
|
||||||
),
|
// ),
|
||||||
child: FaIcon(
|
// ),
|
||||||
FontAwesomeIcons.playCircle,
|
// )),
|
||||||
size: 32 * AppStyle.getScaleFactor(context),
|
// ),
|
||||||
// color: AColors.orange,
|
// ],
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
)),
|
// );
|
||||||
),
|
// }
|
||||||
],
|
// }
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue