Skip to content

Commit

Permalink
Update contact us page to have any kind of link.
Browse files Browse the repository at this point in the history
  • Loading branch information
dewmal committed Apr 6, 2020
1 parent a7eb323 commit a28c9b6
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 71 deletions.
58 changes: 41 additions & 17 deletions assets/data/constant_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,65 @@
"contact_us_contacts": [
{
"id": 1,
"title": "medical_emergency",
"phone_number": "1990",
"address": ""
"title": "1990",
"sub_title": "medical_emergency",
"link": "tel:1990",
"address": "",
"title_translate": false,
"subtitle_translate": true
},
{
"id": 2,
"title": "medical_consultation_service_foc",
"phone_number": "medical_consultation_service_title",
"title": "pharmacy_list",
"sub_title": "",
"link": "https://pharmacy.health.gov.lk/",
"address": "",
"title_translate": true,
"subtitle_translate": false
},
{
"id": 3,
"sub_title": "medical_consultation_service_foc",
"title": "medical_consultation_service_title",
"address": "",
"title_translate": true,
"subtitle_translate": true,
"sub": [
{
"id": 1,
"title": "oDoc",
"phone_number": "https://play.google.com/store/apps/details?id=com.developer.odoc,https://apps.apple.com/lk/app/odoc/id1263423673",
"address": ""
"link": "https://play.google.com/store/apps/details?id=com.developer.odoc,https://apps.apple.com/lk/app/odoc/id1263423673",
"address": "",
"title_translate": false,
"subtitle_translate": true
},
{
"id": 2,
"title": "MyDoctor",
"phone_number": "https://play.google.com/store/apps/details?id=com.app.mydoctor,https://apps.apple.com/us/app/mydoctor-customer-app/id1242769715",
"address": ""
"link": "https://play.google.com/store/apps/details?id=com.app.mydoctor,https://apps.apple.com/us/app/mydoctor-customer-app/id1242769715",
"address": "",
"title_translate": false,
"subtitle_translate": true
}
]
},
{
"id": 3,
"title": "health_information",
"phone_number": "1999",
"address": ""
"id": 4,
"title": "1990",
"sub_title": "health_information",
"link": "tel:1999",
"address": "",
"title_translate": false,
"subtitle_translate": true
},
{
"id": 4,
"title": "covid_19_information",
"phone_number": "117",
"address": ""
"id": 5,
"title": "117",
"sub_title": "covid_19_information",
"link": "tel:117",
"address": "",
"title_translate": false,
"subtitle_translate": true
}
],
"privacy_policy": "We do not send locations to DHIS system unless you choose to share.All news and alerts comes from verified source"
Expand Down
3 changes: 2 additions & 1 deletion assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@

"medical_emergency": "Medical Emergency",
"health_information": "Health Information",
"covid_19_information": "Covid-19 Related Complaints"
"covid_19_information": "Covid-19 Related Complaints",
"pharmacy_list": "Locate Nearest Pharmacy Delivery Service"

}
5 changes: 3 additions & 2 deletions assets/lang/si.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"popmenu_language": "භාෂාව",
"popmenu_faq": "නිතර අසන පැන",
"popmenu_ios_faq": "නිතර අසන පැන",
"popmenu_privpolicy": "රහස්‍යතා ප්‍රතිපත්තිය",
"popmenu_privpolicy": "රහස්\u200Dයතා ප්‍රතිපත්තිය",
"faq": {
"\"කොරෝනා වෛරසය යනු කුමක්ද?\"": "\"කොරෝනා වයිරස් යනු සතුන් හෝ මිනිසුන් තුළ රෝගාබාධ ඇති කළ හැකි විශාල වෛරස් පවුලකි. කොරෝනා පවුලට අයත් වෛරස කිහිපයක් මිනිසුන් තුළ, සාමාන්‍ය සෙම්ප්‍රතිශ්‍යාවේ සිට මැදපෙරදිග ශ්වසන සින්ඩ්‍රෝමය (MERS) සහ දරුණු උග්‍ර ශ්වසන සින්ඩ්‍රෝමය (SARS) වැනි දරුණු රෝග දක්වා ශ්වසන ආසාදන ඇති කරන බව දන්නා කරුණකි. මෑතකදී සොයාගත් කොරෝනා වයිරස් මගින් COVID-19කොරෝනා වයිරස් රෝගයට හේතු වේ.\"",
"\"COVID-19 රෝගය පැතිරෙන්නේ කෙසේද?\"": "\"මිනිසුන්ට වෛරසය ඇති අයගෙන් COVID-19 බෝවිය හැකිය. COVID-19 සහිත පුද්ගලයෙකු කැස්ස හෝ හුස්ම ගන්නා විට නාසයෙන් හෝ මුඛයෙන් පිටවන බිඳිති හරහා මෙම රෝගය පුද්ගලයාගෙන් පුද්ගලයාට පැතිර යා හැකිය. මෙම බිඳිති පුද්ගලයා වටා ඇති වස්තූන් හා පෘෂ්ටයන් මත තැන්පත්වේ. අනෙකුත් අයට COVID-19 වෛරසය ශරීර ගත වන්නේ මෙම වස්තූන් හෝ පෘෂ්ටයන් ස්පර්ශ කිරීමෙන් පසුව ඔවුන්ගේ ඇස්, නාසය හෝ මුඛය ස්පර්ශ කිරීමෙනි. COVID-19 සහිත පුද්ගලයෙකුගේ ගෙන් පිටවන බිඳිති ආශ්වාස කළහොත් මිනිසුන්ට COVID-19 බෝවිය හැක. අසනීපයෙන් පෙළෙන පුද්ගලයෙකුගෙන් මීටර 1 ක් (අඩි 3) වඩා දුරින් සිටීම වැදගත් වන්නේ මේ නිසා ය. COVID-19 ව්‍යාප්ත වී ඇති ආකාරය පිළිබඳ අඛණ්ඩ පර්යේෂණ ලෝක සෞඛ්‍ය සංවිධානය තක්සේරු කරමින් සිටින අතර යාවත්කාලීන කරන ලද සොයාගැනීම් දිගටම බෙදා ගනු ඇත.\"",
Expand Down Expand Up @@ -88,5 +88,6 @@
"medical_consultation_service_foc": "මුදල් අයකිරීමකින් තොරයි.",
"medical_emergency": "හදිසි සෞඛ්\u200Dය අවශ්\u200Dයතා",
"health_information": "සෞඛ්\u200Dය තොරතුරු",
"covid_19_information": "Covid-19 ආශ්\u200Dරිත පැමිණිලි"
"covid_19_information": "Covid-19 ආශ්\u200Dරිත පැමිණිලි",
"pharmacy_list": "ආසන්නයේ ඇති ෆාමසි සොයා ගැනීමට"
}
3 changes: 2 additions & 1 deletion assets/lang/ta.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,6 @@

"medical_emergency": "மருத்துவ அவசரநிலைமை",
"health_information": "சுகாதார தகவல்",
"covid_19_information": "கோவிட் -19 தொடர்புடைய புகார்கள்"
"covid_19_information": "கோவிட் -19 தொடர்புடைய புகார்கள்",
"pharmacy_list": "அருகிலுள்ள மருத்தக விநியோக சேவையைக் கண்டறிக"
}
2 changes: 1 addition & 1 deletion lib/constants.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
final bool debugRelease = false;
final bool debugRelease = true;
//final String testingServer = "https://test.covid-19.health.gov.lk/api";
final String testingServer = "https://test.covid-19.health.gov.lk/api";
45 changes: 13 additions & 32 deletions lib/models/contact_us_contact.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import 'dart:convert';

class ContactUsContact {
int _id;
String _title;
String _phoneNumber;
String _address;
List<ContactUsContact> _subs;
int id;
String title;
String subTitle;
String address;
String link;
bool titleTranslate;
bool subtitleTranslate;
List<ContactUsContact> subContacts;

ContactUsContact._();

Expand All @@ -14,42 +17,20 @@ class ContactUsContact {
ContactUsContact contact = ContactUsContact._();
contact.id = jsonData['id'];
contact.title = jsonData['title'];
contact.phoneNumber = jsonData['phone_number'];
contact.subTitle = jsonData['sub_title'];
contact.link = jsonData['link'];
contact.address = jsonData['address'];
contact.titleTranslate = jsonData['title_translate'];
contact.subtitleTranslate = jsonData['subtitle_translate'];

if (jsonData["sub"] != null) {
List<ContactUsContact> subContacts = List();
for (var subContact in jsonData["sub"]) {
subContacts.add(ContactUsContact.fromJSON(subContact));
}
contact._subs = subContacts;
contact.subContacts = subContacts;
}

return contact;
}

int get id => _id;

set id(int id) {
_id = id;
}

String get address => _address;

set address(String address) {
_address = address;
}

String get phoneNumber => _phoneNumber;

set phoneNumber(String phoneNumber) {
_phoneNumber = phoneNumber;
}

String get title => _title;
List<ContactUsContact> get subContacts => _subs;

set title(String title) {
_title = title;
}
}
46 changes: 30 additions & 16 deletions lib/page/screen/contact_us_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,15 @@ class _ContactUsScreenState extends State<ContactUsScreen> {
itemBuilder: (context, index) {
print(_contacts[index]);
return _contactCard(
contextOriginal,
_contacts[index].title,
_contacts[index].phoneNumber,
_contacts[index].address,
_contacts[index].subContacts);
contextOriginal,
_contacts[index].title,
_contacts[index].subTitle,
_contacts[index].link,
_contacts[index].address,
_contacts[index].subContacts,
_contacts[index].subtitleTranslate,
_contacts[index].titleTranslate,
);
},
itemCount: _contacts.length,
);
Expand All @@ -115,8 +119,15 @@ class _ContactUsScreenState extends State<ContactUsScreen> {
));
}

Widget _contactCard(BuildContext contextParent, String title,
String phoneNumber, String address, List<ContactUsContact> subContacts) {
Widget _contactCard(
BuildContext contextParent,
String title,
String subTitle,
String link,
String address,
List<ContactUsContact> subContacts,
bool subtitleTranslate,
bool titleTranslate) {
return Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0))),
Expand All @@ -138,9 +149,9 @@ class _ContactUsScreenState extends State<ContactUsScreen> {
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text(
subContacts == null
? phoneNumber
: AppLocalizations.of(context).translate(phoneNumber),
!titleTranslate
? title
: AppLocalizations.of(context).translate(title),
style: TextStyle(
fontSize: 20.0,
color: Colors.black,
Expand All @@ -149,7 +160,9 @@ class _ContactUsScreenState extends State<ContactUsScreen> {
textAlign: TextAlign.start,
),
Text(
AppLocalizations.of(context).translate(title),
!subtitleTranslate
? subTitle
: AppLocalizations.of(context).translate(subTitle),
style: TextStyle(
fontSize: 17.0,
color: Colors.black.withOpacity(0.5),
Expand Down Expand Up @@ -181,9 +194,8 @@ class _ContactUsScreenState extends State<ContactUsScreen> {
Container(
child: GestureDetector(
onTap: () async {
if (subContacts == null &&
await canLaunch("tel:$phoneNumber")) {
await launch("tel:$phoneNumber");
if (subContacts == null && await canLaunch(link)) {
await launch(link);
} else if (subContacts != null) {
await showDialog(
barrierDismissible: true,
Expand Down Expand Up @@ -236,7 +248,7 @@ class _ContactUsScreenState extends State<ContactUsScreen> {
color: TrackerColors.primaryColor,
onPressed: () async {
await launch(subContacts[index]
.phoneNumber
.link
.split(",")[Platform.isIOS ? 1 : 0]);
},
child: Padding(
Expand Down Expand Up @@ -288,7 +300,9 @@ class _ContactUsScreenState extends State<ContactUsScreen> {
),
padding: EdgeInsets.all(15.0),
child: subContacts == null
? Icon(Icons.phone, color: Colors.white)
? (link.startsWith("tel:")
? Icon(Icons.phone, color: Colors.white)
: Icon(Icons.web, color: Colors.white))
: Image.asset(
"assets/images/medical_consultion.png",
height: 24,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: Self tracking app
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.8.0+23
version: 1.10.0+25

environment:
sdk: ">=2.1.0 <3.0.0"
Expand Down

0 comments on commit a28c9b6

Please sign in to comment.