75 lines
1.7 KiB
Dart
75 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'states/my_app_states.dart';
|
|
import 'widgets/big_card.dart';
|
|
import 'widgets/my_home_page.dart';
|
|
|
|
void main() {
|
|
runApp(MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ChangeNotifierProvider(
|
|
create: (context) => MyAppState(),
|
|
child: MaterialApp(
|
|
title: 'Namer App',
|
|
theme: ThemeData(
|
|
useMaterial3: true,
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepOrange),
|
|
),
|
|
home: MyHomePage(),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class GeneratorPage extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
var appState = context.watch<MyAppState>();
|
|
var pair = appState.current;
|
|
|
|
IconData icon;
|
|
if (appState.favourites.contains(pair)) {
|
|
icon = Icons.favorite;
|
|
} else {
|
|
icon = Icons.favorite_border;
|
|
}
|
|
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
BigCard(pair: pair),
|
|
SizedBox(height: 10),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
ElevatedButton.icon(
|
|
onPressed: () {
|
|
appState.toggleFavourites();
|
|
},
|
|
icon: Icon(icon),
|
|
label: Text('Like'),
|
|
),
|
|
SizedBox(width: 10),
|
|
ElevatedButton(
|
|
onPressed: () {
|
|
appState.getNext();
|
|
},
|
|
child: Text('Next'),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
// ...
|