2023-08-24 08:28:28 +00:00
|
|
|
import 'package:english_words/english_words.dart';
|
2023-08-23 05:12:23 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2023-08-24 08:28:28 +00:00
|
|
|
import 'package:provider/provider.dart';
|
2023-10-01 09:11:57 +00:00
|
|
|
import 'package:flutter/services.dart';
|
2023-10-01 08:52:24 +00:00
|
|
|
import 'navbar/navbar.dart';
|
2023-08-23 05:12:23 +00:00
|
|
|
|
|
|
|
void main() {
|
2023-09-30 21:35:15 +00:00
|
|
|
runApp(const MyApp());
|
2023-08-23 05:12:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-08-24 08:28:28 +00:00
|
|
|
return ChangeNotifierProvider(
|
|
|
|
create: (context) => MyAppState(),
|
|
|
|
child: MaterialApp(
|
|
|
|
title: 'Namer App',
|
|
|
|
theme: ThemeData(
|
|
|
|
useMaterial3: true,
|
|
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepOrange),
|
|
|
|
),
|
|
|
|
home: MyHomePage(),
|
2023-08-23 05:12:23 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-24 08:28:28 +00:00
|
|
|
class MyAppState extends ChangeNotifier {
|
2023-08-26 22:36:50 +00:00
|
|
|
var rows = 3;
|
|
|
|
var dance = {
|
|
|
|
"instructions": [
|
|
|
|
["call"],
|
|
|
|
["call2"]
|
|
|
|
]
|
|
|
|
};
|
|
|
|
void addCall(call) {
|
|
|
|
dance["instructions"]?[0].add(call);
|
|
|
|
notifyListeners();
|
|
|
|
}
|
2023-08-23 05:12:23 +00:00
|
|
|
}
|
|
|
|
|
2023-08-24 08:28:28 +00:00
|
|
|
class MyHomePage extends StatelessWidget {
|
2023-08-23 05:12:23 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-08-24 08:28:28 +00:00
|
|
|
var appState = context.watch<MyAppState>();
|
2023-08-26 22:36:50 +00:00
|
|
|
var rowElements = [];
|
|
|
|
var instructions = appState.dance["instructions"];
|
|
|
|
if (instructions != null) {
|
|
|
|
for (var row in instructions) {
|
|
|
|
rowElements.add(Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: row.map((e) => Text(e)).toList()));
|
|
|
|
}
|
|
|
|
}
|
2023-08-24 08:28:28 +00:00
|
|
|
|
2023-08-23 05:12:23 +00:00
|
|
|
return Scaffold(
|
2023-08-24 08:28:28 +00:00
|
|
|
body: Column(
|
2023-10-01 08:52:24 +00:00
|
|
|
children: [...rowElements, AddCall(appState: appState), Navbar()],
|
2023-08-23 05:12:23 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2023-08-26 22:36:50 +00:00
|
|
|
|
|
|
|
class AddCall extends StatelessWidget {
|
|
|
|
const AddCall({
|
|
|
|
super.key,
|
|
|
|
required this.appState,
|
|
|
|
});
|
|
|
|
|
|
|
|
final MyAppState appState;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ElevatedButton(
|
|
|
|
onPressed: () => appState.addCall("hello world"),
|
2023-09-30 21:35:15 +00:00
|
|
|
child: const Text("buttonText"),
|
2023-08-26 22:36:50 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|