2025-09-05 16:53:06 +00:00
|
|
|
import 'package:d4rt_formulas/formula_models.dart';
|
2025-08-27 09:10:22 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
2025-09-10 15:17:28 +00:00
|
|
|
import 'package:resource_portable/resource.dart' show Resource;
|
2025-09-08 18:27:42 +00:00
|
|
|
import 'dart:convert';
|
|
|
|
|
|
2025-09-21 14:35:54 +00:00
|
|
|
import 'ai/formula_screen.dart';
|
2025-09-10 15:17:28 +00:00
|
|
|
import 'corpus.dart';
|
2025-09-20 14:46:21 +00:00
|
|
|
import 'defaults/default_corpus.dart';
|
2025-09-10 15:17:28 +00:00
|
|
|
|
2025-08-27 09:10:22 +00:00
|
|
|
void main() {
|
2025-09-08 18:27:42 +00:00
|
|
|
runApp(MaterialApp(
|
2025-09-20 14:46:21 +00:00
|
|
|
home: FutureBuilder<Corpus>(
|
|
|
|
|
future: createDefaultCorpus(),
|
2025-09-08 18:27:42 +00:00
|
|
|
builder: (context, snapshot) {
|
|
|
|
|
if (snapshot.connectionState == ConnectionState.done) {
|
|
|
|
|
if (snapshot.hasError) {
|
|
|
|
|
return Center(child: Text('Error loading units: ${snapshot.error}'));
|
|
|
|
|
}
|
2025-09-21 14:35:54 +00:00
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBar(title: const Text('Formulas')),
|
|
|
|
|
body: ListView.builder(
|
|
|
|
|
itemCount: snapshot.data!.getFormulas().length,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
final formula = snapshot.data!.getFormulas()[index];
|
|
|
|
|
return ListTile(
|
|
|
|
|
title: Text(formula.name),
|
|
|
|
|
subtitle: Text(formula.description ?? ''),
|
|
|
|
|
onTap: () {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => FormulaScreen(
|
|
|
|
|
formula: formula,
|
|
|
|
|
corpus: snapshot.data!,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
2025-09-08 18:27:42 +00:00
|
|
|
}
|
|
|
|
|
return const Center(child: CircularProgressIndicator());
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
));
|
2025-09-05 16:53:06 +00:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 09:10:22 +00:00
|
|
|
|