add fcs shipment in processing,update cargo types for carton
This commit is contained in:
160
lib/pages/customer/customer_detail.dart
Normal file
160
lib/pages/customer/customer_detail.dart
Normal file
@@ -0,0 +1,160 @@
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/customer/model/customer_model.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../domain/entities/user.dart';
|
||||
import '../main/util.dart';
|
||||
import '../widgets/display_text.dart';
|
||||
import '../widgets/fcs_id_icon.dart';
|
||||
|
||||
class CustomerDetail extends StatefulWidget {
|
||||
final String fcsId;
|
||||
const CustomerDetail({super.key, required this.fcsId});
|
||||
|
||||
@override
|
||||
State<CustomerDetail> createState() => _CustomerDetailState();
|
||||
}
|
||||
|
||||
class _CustomerDetailState extends State<CustomerDetail> {
|
||||
GlobalKey<ScaffoldMessengerState> key = GlobalKey<ScaffoldMessengerState>();
|
||||
User? user;
|
||||
bool _isLoading = false;
|
||||
@override
|
||||
void initState() {
|
||||
_loadUser();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
_loadUser() async {
|
||||
try {
|
||||
_isLoading = true;
|
||||
user = await context.read<CustomerModel>().getUserByFCSId(widget.fcsId);
|
||||
} finally {
|
||||
_isLoading = false;
|
||||
}
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final nameBox = DisplayText(
|
||||
text: user?.name ?? '',
|
||||
labelTextKey: "profile.name",
|
||||
iconData: Icons.person,
|
||||
);
|
||||
|
||||
final fcsIDBox = Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: DisplayText(
|
||||
text: user?.fcsID ?? "",
|
||||
labelTextKey: "customer.fcs.id",
|
||||
icon: FcsIDIcon(),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.content_copy, color: Colors.grey),
|
||||
onPressed: () => _copy(
|
||||
getLocalString(context, "customer.fcs.id"), user?.fcsID ?? ""),
|
||||
)
|
||||
],
|
||||
);
|
||||
|
||||
final phoneBox = Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: DisplayText(
|
||||
text: user?.phoneNumber ?? "",
|
||||
labelTextKey: "contact.phone",
|
||||
iconData: FontAwesome.phone),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(MaterialIcons.open_in_new, color: Colors.grey),
|
||||
onPressed: () {
|
||||
if (user == null) return;
|
||||
if (user!.phoneNumber != null && user!.phoneNumber != "") {
|
||||
launch(
|
||||
"tel:${user!.phoneNumber ?? "".trim().replaceAll(' ', '')}");
|
||||
}
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
|
||||
final emailBox = Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: DisplayText(
|
||||
text: user?.recoveryEmail ?? "",
|
||||
labelTextKey: "profile.recovery.email",
|
||||
iconData: Icons.email_outlined),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(MaterialIcons.open_in_new, color: Colors.grey),
|
||||
onPressed: () {
|
||||
if (user == null) return;
|
||||
if (user!.recoveryEmail != null && user!.recoveryEmail != "") {
|
||||
launch("mailto:${user?.recoveryEmail ?? ""}");
|
||||
}
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
key: key,
|
||||
appBar: LocalAppBar(
|
||||
backgroundColor: Colors.white,
|
||||
arrowColor: primaryColor,
|
||||
labelColor: primaryColor,
|
||||
labelKey: 'customer.detail.title'),
|
||||
body: ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10),
|
||||
children: [
|
||||
nameBox,
|
||||
const SizedBox(height: 8),
|
||||
fcsIDBox,
|
||||
const SizedBox(height: 8),
|
||||
phoneBox,
|
||||
(user != null && user!.recoveryEmail != null && user!.recoveryEmail != "")
|
||||
? emailBox
|
||||
: const SizedBox()
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_copy(String title, String data) {
|
||||
Clipboard.setData(ClipboardData(text: data));
|
||||
// showToast(key, 'copied "$title" data to clipboard');
|
||||
_showToast(title);
|
||||
}
|
||||
|
||||
_showToast(String title) {
|
||||
ScaffoldMessengerState? scaffold = key.currentState;
|
||||
|
||||
scaffold ??= ScaffoldMessenger.of(context);
|
||||
|
||||
scaffold.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('copied "$title" data to clipboard'),
|
||||
backgroundColor: secondaryColor,
|
||||
duration: Duration(seconds: 1),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user