155 lines
5.1 KiB
Dart
155 lines
5.1 KiB
Dart
import 'package:fcs/model/pickup_model.dart';
|
|
import 'package:fcs/widget/label_widgets.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
import 'package:package_info/package_info.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
import 'package:fcs/model/main_model.dart';
|
|
import 'package:fcs/pages/util.dart';
|
|
import 'package:fcs/theme/theme.dart';
|
|
import 'package:fcs/widget/local_text.dart';
|
|
import 'package:fcs/widget/progress.dart';
|
|
|
|
class Contact extends StatefulWidget {
|
|
@override
|
|
_ContactState createState() => _ContactState();
|
|
}
|
|
|
|
class _ContactState extends State<Contact> {
|
|
bool _isLoading = false;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
var pickupModel = Provider.of<PickUpModel>(context, listen: false);
|
|
|
|
// MainModel mainModel = Provider.of<MainModel>(context);
|
|
// bool isOwner = mainModel.user != null && mainModel.user.isOwner();
|
|
// bool hasAdmin = mainModel.user != null && mainModel.user.hasAdmin();
|
|
return LocalProgress(
|
|
inAsyncCall: _isLoading,
|
|
child: Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: primaryColor,
|
|
elevation: 0,
|
|
centerTitle: true,
|
|
leading: new IconButton(
|
|
icon: new Icon(Icons.close),
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
),
|
|
title: LocalText(
|
|
context,
|
|
"contact",
|
|
fontSize: 25,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
body: ListView(
|
|
children: <Widget>[
|
|
link(pickupModel.profile.usaContactNumber, Icons.phone_forwarded,
|
|
onTap: () => _call(pickupModel.profile.usaContactNumber),
|
|
label: LocalText(
|
|
context,
|
|
"contact.usa.phone",
|
|
color: primaryColor,
|
|
)),
|
|
link(pickupModel.profile.mmContactNumber, Icons.phone_forwarded,
|
|
onTap: () => _call(
|
|
pickupModel.profile.mmContactNumber,
|
|
),
|
|
label: LocalText(
|
|
context,
|
|
"contact.mm.phone",
|
|
color: primaryColor,
|
|
)),
|
|
link(
|
|
pickupModel.profile.usaAddress,
|
|
Icons.location_on,
|
|
),
|
|
link(pickupModel.profile.mmAddress, Icons.location_on),
|
|
link(pickupModel.profile.mail, Icons.email,
|
|
onTap: () => _email(pickupModel.profile.mail)),
|
|
link(pickupModel.profile.facebook, FontAwesomeIcons.facebook,
|
|
onTap: () => _openLink(pickupModel.profile.facebook)),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget link(String text, IconData iconData,
|
|
{Function() onTap, Widget label}) {
|
|
return Padding(
|
|
padding: const EdgeInsets.only(left: 18.0, bottom: 5),
|
|
child: InkWell(
|
|
onTap: () => onTap != null ? onTap() : null,
|
|
child: SingleChildScrollView(
|
|
scrollDirection: Axis.horizontal,
|
|
child: Row(
|
|
children: <Widget>[
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Icon(
|
|
iconData,
|
|
),
|
|
),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
label == null
|
|
? Container()
|
|
: Padding(
|
|
padding: EdgeInsets.fromLTRB(10, 10, 10, 0),
|
|
child: label,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Text(
|
|
text == null ? "" : text,
|
|
overflow: TextOverflow.ellipsis,
|
|
maxLines: 5,
|
|
style: TextStyle(fontSize: 14.0),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(
|
|
width: 5,
|
|
),
|
|
onTap == null
|
|
? Container()
|
|
: Icon(
|
|
Icons.open_in_new,
|
|
color: Colors.grey,
|
|
size: 15,
|
|
)
|
|
],
|
|
),
|
|
)),
|
|
);
|
|
}
|
|
|
|
Future<String> getVersionNumber() async {
|
|
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
|
String version = packageInfo.version + "+" + packageInfo.buildNumber;
|
|
return version;
|
|
}
|
|
|
|
_call(String phone) {
|
|
showConfirmDialog(
|
|
context, "contact.phone.confim", () => launch("tel:$phone"),
|
|
translationVariables: ["$phone"]);
|
|
}
|
|
|
|
_email(String email) {
|
|
showConfirmDialog(
|
|
context, "contact.email.configm", () => launch("mailto:$email"),
|
|
translationVariables: ["$email"]);
|
|
}
|
|
|
|
_openLink(String link) {
|
|
showConfirmDialog(context, "contact.open.confrim", () => launch("$link"),
|
|
translationVariables: ["$link"]);
|
|
}
|
|
}
|