You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.3 KiB
63 lines
2.3 KiB
7 months ago
|
import 'package:counters/address.dart';
|
||
|
import 'package:counters/datbase.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||
|
|
||
|
class UpdateAddressPage extends StatelessWidget {
|
||
|
final streetNameController = TextEditingController();
|
||
|
final commentsController = TextEditingController();
|
||
|
|
||
|
UpdateAddressPage({super.key, required this.address});
|
||
|
|
||
|
final Address address;
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
streetNameController.text = address.streetName;
|
||
|
commentsController.text = address.comments;
|
||
|
|
||
|
return Scaffold(
|
||
|
appBar: AppBar(
|
||
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||
|
title: Text(AppLocalizations.of(context)!.new_address_title),
|
||
|
),
|
||
|
body: Center(
|
||
|
child: Padding(
|
||
|
padding: const EdgeInsets.all(8.0),
|
||
|
child: Column(
|
||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||
|
children: [
|
||
|
TextField(
|
||
|
controller: streetNameController,
|
||
|
decoration: InputDecoration(
|
||
|
hintStyle: const TextStyle(color: Colors.blue),
|
||
|
hintText:
|
||
|
AppLocalizations.of(context)!.enter_your_address),
|
||
|
),
|
||
|
const SizedBox(height: 50),
|
||
|
TextField(
|
||
|
controller: commentsController,
|
||
|
decoration: InputDecoration(
|
||
|
hintStyle: const TextStyle(color: Colors.blue),
|
||
|
hintText: AppLocalizations.of(context)!
|
||
|
.enter_your_address_comments),
|
||
|
),
|
||
|
const SizedBox(height: 50),
|
||
|
TextButton(
|
||
|
onPressed: () {
|
||
|
DBProvider.db
|
||
|
.updateAddress(Address(
|
||
|
id: address.id,
|
||
|
streetName: streetNameController.text,
|
||
|
comments: commentsController.text))
|
||
|
.then((value) => Navigator.pop(context));
|
||
|
},
|
||
|
child: Text(AppLocalizations.of(context)!.edit))
|
||
|
]),
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|