upgrade mapbox
This commit is contained in:
170
covas_mobile_new/lib/pages/EditSettings.dart
Normal file
170
covas_mobile_new/lib/pages/EditSettings.dart
Normal file
@@ -0,0 +1,170 @@
|
||||
import 'package:covas_mobile/classes/MyDrawer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import '../classes/MyDrawer.dart';
|
||||
|
||||
import '../classes/alert.dart';
|
||||
import '../classes/eventAdded.dart';
|
||||
|
||||
import '../classes/ad_helper.dart';
|
||||
import 'package:google_mobile_ads/google_mobile_ads.dart';
|
||||
import '../classes/auth_service.dart';
|
||||
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../locale_provider.dart'; // Créé
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await MobileAds.instance.initialize();
|
||||
runApp(MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: EditSettings(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class EditSettings extends StatefulWidget {
|
||||
const EditSettings({super.key});
|
||||
|
||||
@override
|
||||
_EditProfileState createState() => _EditProfileState();
|
||||
}
|
||||
|
||||
class _EditProfileState extends State<EditSettings>
|
||||
with ShowAlertDialog, ShowEventDialog {
|
||||
BannerAd? _bannerAd;
|
||||
final AuthService _authService = AuthService();
|
||||
|
||||
TextEditingController inputUserName = TextEditingController();
|
||||
int? kilometer;
|
||||
|
||||
Future<void> getParameter() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
setState(() {
|
||||
var kilometer = prefs.getDouble("kilometer")?.toInt() ?? null;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> setParameter() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
if (kilometer != null) {
|
||||
prefs.setDouble("kilometer", kilometer?.toDouble() ?? 50);
|
||||
showAlertDialog(
|
||||
context,
|
||||
AppLocalizations.of(context)?.updated ?? "Updated",
|
||||
AppLocalizations.of(context)?.settings_updated ?? "Settings updated");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_authService.checkTokenStatus(context);
|
||||
|
||||
AdHelper.createBannerAd(() => setState(() {})).then((ad) {
|
||||
setState(() {
|
||||
_bannerAd = ad;
|
||||
});
|
||||
});
|
||||
getParameter();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: AppBar(
|
||||
title: Text(AppLocalizations.of(context)?.settings ?? "Settings"),
|
||||
backgroundColor: Colors.blue,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
drawer: MyDrawer(),
|
||||
body: Form(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
_bannerAd == null
|
||||
? SizedBox.shrink()
|
||||
: SizedBox(
|
||||
height: _bannerAd!.size.height.toDouble(),
|
||||
width: _bannerAd!.size.width.toDouble(),
|
||||
child: AdWidget(ad: _bannerAd!)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 15.0,
|
||||
right: 15.0,
|
||||
top: 15.0,
|
||||
bottom: 0.0,
|
||||
),
|
||||
child: DropdownButtonFormField<int>(
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText:
|
||||
AppLocalizations.of(context)?.define_kilometer ??
|
||||
'Define kilometer',
|
||||
),
|
||||
value:
|
||||
kilometer, // Set the initial selected value here, or leave as `null` if unselected.
|
||||
items: [
|
||||
DropdownMenuItem(
|
||||
value: 5,
|
||||
child: Text('5km'),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 25,
|
||||
child: Text('25km'),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 50,
|
||||
child: Text('50km'),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 75,
|
||||
child: Text('75km'),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 100,
|
||||
child: Text('100km'),
|
||||
),
|
||||
],
|
||||
onChanged: (int? newValue) {
|
||||
// Handle selection
|
||||
kilometer = newValue;
|
||||
},
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Container(
|
||||
height: 50,
|
||||
width: 250,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue,
|
||||
borderRadius: BorderRadius.circular(20)),
|
||||
child: TextButton(
|
||||
onPressed: () {},
|
||||
child: Text(
|
||||
AppLocalizations.of(context)?.update ?? "Update",
|
||||
style: TextStyle(color: Colors.white, fontSize: 25),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user