121 lines
4.8 KiB
Dart
121 lines
4.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:geolocator/geolocator.dart';
|
|
import 'package:lba/gen/assets.gen.dart';
|
|
import 'package:lba/res/colors.dart';
|
|
|
|
|
|
Future<void> showGPSDialog(BuildContext context) async {
|
|
bool isLocationEnabled = await Geolocator.isLocationServiceEnabled();
|
|
if (!isLocationEnabled) {
|
|
showDialog(
|
|
context: context,
|
|
barrierDismissible: false,
|
|
builder: (BuildContext context) {
|
|
return Dialog(
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
|
|
elevation: 10,
|
|
backgroundColor: Colors.white,
|
|
child: Stack(
|
|
clipBehavior: Clip.none,
|
|
alignment: Alignment.topCenter,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 40, left: 20, right: 20, bottom: 20),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
SizedBox(height: 10),
|
|
Padding(
|
|
padding: const EdgeInsets.all(15.0),
|
|
child: const Text(
|
|
"Enable Location",
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 5),
|
|
const Text(
|
|
"To show nearby deals, events, and shops tailored to your location, we need access to your device's GPS.",
|
|
style: TextStyle(
|
|
color: LightAppColors.popupText,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 16,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
const SizedBox(height: 20),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
elevation: 6,
|
|
shadowColor: Colors.black.withOpacity(0.4),
|
|
backgroundColor: Colors.white,
|
|
foregroundColor: Colors.black,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(8),
|
|
side: BorderSide(color: Colors.grey),
|
|
),
|
|
),
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
child: Text("Not now"),
|
|
),
|
|
ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: LightAppColors.confirmPopup,
|
|
foregroundColor: Colors.black,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(8),
|
|
side: BorderSide(color: LightAppColors.inputBorder),
|
|
),
|
|
padding: const EdgeInsets.symmetric(horizontal: 35, vertical: 7),
|
|
),
|
|
onPressed: () async {
|
|
await Geolocator.openLocationSettings();
|
|
Navigator.of(context).pop();
|
|
},
|
|
child: const Text(
|
|
"Turn on GPS",
|
|
style: TextStyle(color: Colors.white),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Positioned(
|
|
top: -40,
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.3),
|
|
blurRadius: 8,
|
|
offset: Offset(0, 4),
|
|
),
|
|
],
|
|
),
|
|
child: CircleAvatar(
|
|
backgroundColor: Colors.white,
|
|
radius: 40,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(12.0),
|
|
child: SvgPicture.asset(Assets.icons.fluentColorLocationRipple16.path),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|