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