update
This commit is contained in:
169
neowallet_mobile/lib/Home/all_menu.dart
Normal file
169
neowallet_mobile/lib/Home/all_menu.dart
Normal file
@@ -0,0 +1,169 @@
|
||||
import 'package:cathaypay_mobile/Home/HomePage.dart';
|
||||
import 'package:cathaypay_mobile/Home/home_bottom_menu_widget.dart';
|
||||
import 'package:cathaypay_mobile/model/menu_icon_model.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../GetPaid/GetPaid.dart';
|
||||
import '../Pay/PayPage.dart';
|
||||
import '../TopUp/TopUpMenuPage.dart';
|
||||
import '../TransferMoney/TransferMoneyMenu.dart';
|
||||
import '../api/api.dart';
|
||||
|
||||
class AllMenuPage extends StatefulWidget {
|
||||
const AllMenuPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AllMenuPage> createState() => _PolicyPageState();
|
||||
}
|
||||
|
||||
class _PolicyPageState extends State<AllMenuPage> {
|
||||
var controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
if (context.locale.toString() == "th") {
|
||||
listMenu.add(MenuIconModel(fileUrl: "images/menu/27.png", localID: 0));
|
||||
listMenu.add(MenuIconModel(fileUrl: "images/menu/26.png", localID: 1));
|
||||
listMenu.add(MenuIconModel(fileUrl: "images/menu/25.png", localID: 2));
|
||||
listMenu.add(MenuIconModel(fileUrl: "images/menu/31.png", localID: 3));
|
||||
} else {
|
||||
listMenu.add(MenuIconModel(fileUrl: "images/menu/22.png", localID: 0));
|
||||
listMenu.add(MenuIconModel(fileUrl: "images/menu/23.png", localID: 1));
|
||||
listMenu.add(MenuIconModel(fileUrl: "images/menu/24.png", localID: 2));
|
||||
listMenu.add(MenuIconModel(fileUrl: "images/menu/32.png", localID: 3));
|
||||
}
|
||||
|
||||
getMenu();
|
||||
});
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
List<MenuIconModel> listMenu = [];
|
||||
|
||||
getMenu() {
|
||||
Api.get(context, Api.menuIcons).then((value) => {
|
||||
if (value != null)
|
||||
{
|
||||
setState(() {
|
||||
value.forEach((v) {
|
||||
listMenu.add(MenuIconModel.fromJson(v));
|
||||
});
|
||||
})
|
||||
}
|
||||
else
|
||||
{}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _launchUrl(String url) async {
|
||||
if (!await launchUrl(Uri.parse(url))) {
|
||||
throw Exception('Could not launch $url');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
// extendBodyBehindAppBar: true,
|
||||
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
leading: CupertinoButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Icon(
|
||||
Icons.arrow_back,
|
||||
color: Colors.black54,
|
||||
),
|
||||
),
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
title: Text(
|
||||
"แอปพลิเคชันทั้งหมด".tr(),
|
||||
textAlign: TextAlign.center,
|
||||
style: GoogleFonts.kanit(
|
||||
color: Colors.black,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: GridView.count(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
crossAxisCount: 4,
|
||||
childAspectRatio: 1 / 1,
|
||||
mainAxisSpacing: 5.0,
|
||||
crossAxisSpacing: 5.0,
|
||||
children: listMenu.map((MenuIconModel promo) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
switch (promo.localID) {
|
||||
case 0:
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
builder: (BuildContext context) {
|
||||
return GetPaidPage();
|
||||
});
|
||||
break;
|
||||
case 1:
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
builder: (BuildContext context) {
|
||||
return TransferMoneyMenuPage();
|
||||
});
|
||||
break;
|
||||
case 2:
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
builder: (BuildContext context) {
|
||||
return PayPage();
|
||||
});
|
||||
break;
|
||||
case 3:
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
builder: (BuildContext context) {
|
||||
return SafeArea(child: TopUpMenuPage());
|
||||
});
|
||||
break;
|
||||
}
|
||||
String url = "${promo.link}?token=${promo.token}&id=${profile?.id}&mobile=${profile?.phoneNumber}&email=${profile?.email}";
|
||||
print(url);
|
||||
_launchUrl( url);
|
||||
},
|
||||
child: promo.fileUrl != null
|
||||
? promo.fileUrl!.startsWith("http")
|
||||
? Image.network(promo.fileUrl ?? "")
|
||||
: Image.asset(promo.fileUrl ?? "")
|
||||
: Container(),
|
||||
);
|
||||
}).toList()),
|
||||
),
|
||||
),
|
||||
HomeBottomMenuWidget()
|
||||
],
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user