proxibuy/lib/presentation/ui/screens/home/home_page.dart

81 lines
2.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:proxibuy/core/routes/app_router.dart';
import 'package:proxibuy/core/services/permisions_services.dart';
import 'package:proxibuy/core/utils/empty_space.dart';
import 'package:proxibuy/presentation/providers/cubit/them_mode_cubit.dart';
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
static const platform = MethodChannel('custom_notification');
Future<void> showCustomNotification() async {
try {
final notifPer = await requestNotificationPermission();
if (notifPer) {
await platform.invokeMethod('showCustomNotification', {
'title': 'Handbags & Wallets | White Elm',
'content': 'Leander, Texas (8.7 Km away)',
'imageUrl':
'https://s3-alpha-sig.figma.com/img/652b/471b/a8059768c434c7abf4cfdc3c879e9293?Expires=1740355200&Key-Pair-Id=APKAQ4GOSFWCW27IBOMQ&Signature=EVePXMyyhpSNgasV3uH1d5qMrPSkjn5KzpSxFoySpBs9uzU1aNHQoab9G9iOliFDRRSZ62RggnoomQ52og0UTPnMBUG6c-5GKT~f-C~sGnqppDoNf9UhhCBXpbE-BJYvkdXyuc7YmcdVyljgcWfChHANQL~nz5egKp-nyoL6mRfa6z1AH5IVaD-hMcA~cgcM2iRiJxddCciGyRNyr0cS8XWilO55sA1blB-q2Bp9sKZJCezw5Nhn2S8SLSVnDrNjBAJv3ph4ArsCxHH5DhCNmPiDA~AT3LOz~lQwVVJZhkIEAK6zS1TpvrsPPfNp7gAgr4MG3GM2CGl19AwrSoxDdw__',
});
}
} on PlatformException catch (e) {
print("Failed to show notification: '${e.message}'.");
}
}
@override
void initState() {
super.initState();
platform.setMethodCallHandler(_handleMethod);
}
Future<void> _handleMethod(MethodCall call) async {
print(' method ${call.method}');
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Proxibuy"),
actions: [
IconButton(
icon: Icon(Icons.brightness_6),
onPressed: () {
context.read<ThemModeCubit>().changeTheme();
},
),
],
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: () async {
await showCustomNotification();
},
child: Text('Show Notification')),
18.h,
ElevatedButton(
onPressed: () async {
context.go(AppRouter.details);
},
child: Text('Navigate to Details')),
],
),
),
);
}
}