Files
fcs/lib/pages/contact/contact_page.dart

117 lines
3.6 KiB
Dart
Raw Normal View History

2020-10-07 02:33:06 +06:30
import 'package:fcs/domain/entities/setting.dart';
import 'package:fcs/domain/vo/contact.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/contact/contact_editor.dart';
import 'package:fcs/pages/main/model/main_model.dart';
2024-01-25 17:40:35 +06:30
import 'package:fcs/pages/widgets/local_app_bar.dart';
2020-09-07 16:05:28 +06:30
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
2024-12-27 22:36:48 +06:30
import 'package:package_info_plus/package_info_plus.dart';
2020-09-07 16:05:28 +06:30
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
import 'widgets.dart';
class ContactPage extends StatefulWidget {
@override
_ContactPageState createState() => _ContactPageState();
}
class _ContactPageState extends State<ContactPage> {
@override
Widget build(BuildContext context) {
2021-09-10 16:33:52 +06:30
Setting? setting = Provider.of<MainModel>(context).setting;
if (setting == null) return Container();
2020-09-11 16:14:36 +06:30
bool isEditable = context.select((MainModel m) => m.contactEditable());
2020-09-07 16:05:28 +06:30
return Scaffold(
2024-01-25 17:40:35 +06:30
appBar: LocalAppBar(
labelKey: "contact.title",
2020-09-18 04:04:21 +06:30
backgroundColor: Colors.white,
2024-01-25 17:40:35 +06:30
labelColor: primaryColor,
arrowColor: primaryColor,
2020-09-18 04:04:21 +06:30
actions: isEditable
? [
IconButton(
onPressed: () =>
Navigator.of(context).push<void>(CupertinoPageRoute(
builder: (context) => ContactEditor(
contact: Contact.fromSetting(setting)),
)),
icon: Icon(
2021-09-13 12:12:45 +06:30
Icons.edit,
2020-09-18 04:04:21 +06:30
color: primaryColor,
))
]
: [],
),
body: ListView(
children: [
2020-09-11 16:14:36 +06:30
itemTitle(context, "contact.callus"),
contactItem(context, setting.usaContactNumber, CupertinoIcons.phone,
2021-09-10 16:33:52 +06:30
onTap: () => _call(setting.usaContactNumber ?? ""),
2020-09-11 16:14:36 +06:30
labelKey: "contact.usa.phone"),
contactItem(
context,
setting.mmContactNumber,
CupertinoIcons.phone,
onTap: () => _call(
2021-09-10 16:33:52 +06:30
setting.mmContactNumber ?? "",
2020-09-07 16:05:28 +06:30
),
2020-09-11 16:14:36 +06:30
labelKey: "contact.mm.phone",
),
itemTitle(context, "contact.findus"),
contactItem(
context,
setting.usaAddress,
CupertinoIcons.location,
labelKey: "contact.usa.address",
),
contactItem(
context,
setting.mmAddress,
CupertinoIcons.location,
labelKey: "contact.mm.address",
),
itemTitle(context, "contact.emailus"),
contactItem(
context,
setting.emailAddress,
CupertinoIcons.mail,
2021-09-10 16:33:52 +06:30
onTap: () => _email(setting.emailAddress ?? ""),
2020-09-11 16:14:36 +06:30
labelKey: "contact.fcs.email",
),
itemTitle(context, "contact.visitus"),
contactItem(
context,
setting.facebookLink,
FontAwesomeIcons.facebook,
2021-09-10 16:33:52 +06:30
onTap: () => _opencontactItem(setting.facebookLink ?? ""),
2020-09-11 16:14:36 +06:30
labelKey: "contact.facebook",
),
2024-01-25 17:40:35 +06:30
const SizedBox(height: 30)
2020-09-18 04:04:21 +06:30
],
),
2020-09-07 16:05:28 +06:30
);
}
Future<String> getVersionNumber() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String version = packageInfo.version + "+" + packageInfo.buildNumber;
return version;
}
_call(String phone) {
2020-10-19 17:09:24 +06:30
launch("tel:${phone.trim().replaceAll(' ', '')}");
2020-09-07 16:05:28 +06:30
}
_email(String email) {
launch("mailto:$email");
}
_opencontactItem(String contactItem) {
launch("$contactItem");
}
}