diff --git a/aidedejeu_flutter/assets/Cinzel-Bold.otf b/aidedejeu_flutter/assets/Cinzel-Bold.otf
new file mode 100644
index 00000000..736fb115
Binary files /dev/null and b/aidedejeu_flutter/assets/Cinzel-Bold.otf differ
diff --git a/aidedejeu_flutter/assets/Cinzel-Regular.otf b/aidedejeu_flutter/assets/Cinzel-Regular.otf
new file mode 100644
index 00000000..2fa4b3ed
Binary files /dev/null and b/aidedejeu_flutter/assets/Cinzel-Regular.otf differ
diff --git a/aidedejeu_flutter/assets/LinLibertine_R.ttf b/aidedejeu_flutter/assets/LinLibertine_R.ttf
new file mode 100644
index 00000000..ab154440
Binary files /dev/null and b/aidedejeu_flutter/assets/LinLibertine_R.ttf differ
diff --git a/aidedejeu_flutter/assets/LinLibertine_RB.ttf b/aidedejeu_flutter/assets/LinLibertine_RB.ttf
new file mode 100644
index 00000000..049915e0
Binary files /dev/null and b/aidedejeu_flutter/assets/LinLibertine_RB.ttf differ
diff --git a/aidedejeu_flutter/assets/LinLibertine_RBI.ttf b/aidedejeu_flutter/assets/LinLibertine_RBI.ttf
new file mode 100644
index 00000000..82af9faa
Binary files /dev/null and b/aidedejeu_flutter/assets/LinLibertine_RBI.ttf differ
diff --git a/aidedejeu_flutter/assets/LinLibertine_RI.ttf b/aidedejeu_flutter/assets/LinLibertine_RI.ttf
new file mode 100644
index 00000000..a156230a
Binary files /dev/null and b/aidedejeu_flutter/assets/LinLibertine_RI.ttf differ
diff --git a/aidedejeu_flutter/assets/MarcellusSC-Regular.ttf b/aidedejeu_flutter/assets/MarcellusSC-Regular.ttf
new file mode 100644
index 00000000..7304b969
Binary files /dev/null and b/aidedejeu_flutter/assets/MarcellusSC-Regular.ttf differ
diff --git a/aidedejeu_flutter/assets/crystal-ball.svg b/aidedejeu_flutter/assets/crystal-ball.svg
new file mode 100644
index 00000000..7ae97f50
--- /dev/null
+++ b/aidedejeu_flutter/assets/crystal-ball.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/aidedejeu_flutter/assets/library.db b/aidedejeu_flutter/assets/library.db
new file mode 100644
index 00000000..97d74449
Binary files /dev/null and b/aidedejeu_flutter/assets/library.db differ
diff --git a/aidedejeu_flutter/lib/main.dart b/aidedejeu_flutter/lib/main.dart
index 5a7af455..9009edc6 100644
--- a/aidedejeu_flutter/lib/main.dart
+++ b/aidedejeu_flutter/lib/main.dart
@@ -1,111 +1,173 @@
+import 'dart:io';
+
import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_markdown/flutter_markdown.dart';
+import 'package:flutter_svg/flutter_svg.dart';
+import 'package:path/path.dart';
+import 'package:sqflite/sqflite.dart';
void main() => runApp(MyApp());
+class Item {
+ String Id;
+ String Markdown;
+
+ Item({this.Id, this.Markdown});
+
+ factory Item.fromMap(Map json) => new Item(
+ Id: json["Id"],
+ Markdown: json["Markdown"],
+ );
+
+ Map toMap() => {
+ "Id": Id,
+ "Markdown": Markdown,
+ };
+}
+
+Database _database;
+
+Future get database async {
+ if (_database != null) return _database;
+ _database = await getDatabaseInstance();
+ return _database;
+}
+
+Future getDatabaseInstance() async {
+ var databasesPath = await getDatabasesPath();
+ var path = join(databasesPath, "library.db");
+
+ var exists = await databaseExists(path);
+ if (!exists) {
+ print("Creating new copy from asset");
+
+ try {
+ await Directory(dirname(path)).create(recursive: true);
+ } catch (_) {}
+
+ ByteData data = await rootBundle.load(join("assets", "library.db"));
+ List bytes =
+ data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
+
+ await File(path).writeAsBytes(bytes, flush: true);
+ } else {
+ print("Opening existing database");
+ }
+
+ return await openDatabase(path, readOnly: true);
+}
+
+Future- getItemWithId(String id) async {
+ print("getItemWithId " + id);
+ final db = await database;
+ var response = await db
+ .query("Items", where: "Id = ? OR RootId = ?", whereArgs: [id, id]);
+ if (response.isEmpty) {
+ print("Id not found");
+ }
+ return response.isNotEmpty ? Item.fromMap(response.first) : null;
+}
+
class MyApp extends StatelessWidget {
- // This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
- // This is the theme of your application.
- //
- // Try running your application with "flutter run". You'll see the
- // application has a blue toolbar. Then, without quitting the app, try
- // changing the primarySwatch below to Colors.green and then invoke
- // "hot reload" (press "r" in the console where you ran "flutter run",
- // or simply save your changes to "hot reload" in a Flutter IDE).
- // Notice that the counter didn't reset back to zero; the application
- // is not restarted.
- primarySwatch: Colors.blue,
+ primarySwatch: Colors.red,
),
- home: MyHomePage(title: 'Flutter Demo Home Page'),
+ home: MyHomePage(id: 'index.md'),
);
}
}
class MyHomePage extends StatefulWidget {
- MyHomePage({Key key, this.title}) : super(key: key);
+ MyHomePage({Key key, @required this.id}) : super(key: key);
- // This widget is the home page of your application. It is stateful, meaning
- // that it has a State object (defined below) that contains fields that affect
- // how it looks.
-
- // This class is the configuration for the state. It holds the values (in this
- // case the title) provided by the parent (in this case the App widget) and
- // used by the build method of the State. Fields in a Widget subclass are
- // always marked "final".
-
- final String title;
+ final String id;
@override
- _MyHomePageState createState() => _MyHomePageState();
+ _MyHomePageState createState() => _MyHomePageState(id: this.id);
}
class _MyHomePageState extends State {
- int _counter = 0;
+ _MyHomePageState({@required this.id});
- void _incrementCounter() {
+ final String id;
+
+ void setMarkdown(String md) {
setState(() {
- // This call to setState tells the Flutter framework that something has
- // changed in this State, which causes it to rerun the build method below
- // so that the display can reflect the updated values. If we changed
- // _counter without calling setState(), then the build method would not be
- // called again, and so nothing would appear to happen.
- _counter++;
+ markdown = md.replaceAllMapped(RegExp(r''), (match) {
+ return '';
+ });
});
}
+ String markdown = "";
+ MarkdownStyleSheet styleSheet;
+
+ @override
+ void initState() {
+ super.initState();
+
+ ThemeData theme = ThemeData(
+ brightness: Brightness.light,
+ primaryColor: Colors.lightBlue[800],
+ accentColor: Colors.cyan[600],
+ fontFamily: 'LinuxLibertine',
+ textTheme: TextTheme(
+ headline: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),
+ title: TextStyle(fontSize: 18.0, fontStyle: FontStyle.italic),
+ body1: TextStyle(fontSize: 14.0, fontFamily: 'Hind'),
+ ),
+ );
+
+ //styleSheet = MarkdownStyleSheet.fromTheme(theme);
+ styleSheet = MarkdownStyleSheet(
+ tableColumnWidth: IntrinsicColumnWidth(),
+ tableCellsPadding: EdgeInsets.all(0.2));
+
+ getItemWithId(this.id)
+ .then((item) => setMarkdown(item.Markdown))
+ .catchError((error) => print(error));
+ }
+
+ final Widget svg = SvgPicture.asset("assets/crystal-ball.svg",
+ height: 20.0,
+ width: 20.0,
+ allowDrawingOutsideViewBox: true,
+ );
@override
Widget build(BuildContext context) {
- // This method is rerun every time setState is called, for instance as done
- // by the _incrementCounter method above.
- //
- // The Flutter framework has been optimized to make rerunning build methods
- // fast, so that you can just rebuild anything that needs updating rather
- // than having to individually change instances of widgets.
+
return Scaffold(
appBar: AppBar(
- // Here we take the value from the MyHomePage object that was created by
- // the App.build method, and use it to set our appbar title.
- title: Text(widget.title),
+ title: Text(widget.id),
),
- body: Center(
- // Center is a layout widget. It takes a single child and positions it
- // in the middle of the parent.
- child: Column(
- // Column is also a layout widget. It takes a list of children and
- // arranges them vertically. By default, it sizes itself to fit its
- // children horizontally, and tries to be as tall as its parent.
- //
- // Invoke "debug painting" (press "p" in the console, choose the
- // "Toggle Debug Paint" action from the Flutter Inspector in Android
- // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
- // to see the wireframe for each widget.
- //
- // Column has various properties to control how it sizes itself and
- // how it positions its children. Here we use mainAxisAlignment to
- // center the children vertically; the main axis here is the vertical
- // axis because Columns are vertical (the cross axis would be
- // horizontal).
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- 'You have pushed the button this many times:',
- ),
- Text(
- '$_counter',
- style: Theme.of(context).textTheme.display1,
- ),
- ],
- ),
+ body: Markdown(
+ data: markdown,
+ styleSheet: styleSheet,
+ onTapLink: (link) => Navigator.push(context,
+ MaterialPageRoute(builder: (context) => MyHomePage(id: link)))),
+ bottomNavigationBar: BottomNavigationBar(
+ items: const [
+ BottomNavigationBarItem(
+ icon: Icon(Icons.home),
+ title: Text('Home'),
+ ),
+ BottomNavigationBarItem(
+ icon: Icon(Icons.business),
+ title: Text('Business'),
+ ),
+ BottomNavigationBarItem(
+ icon: Icon(Icons.business),
+ //icon: svg,
+ title: Text('School'),
+ //activeIcon: Icon(Icons.category, color: Color(0xFFEF5123)),
+ ),
+ ],
),
- floatingActionButton: FloatingActionButton(
- onPressed: _incrementCounter,
- tooltip: 'Increment',
- child: Icon(Icons.add),
- ), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
diff --git a/aidedejeu_flutter/pubspec.lock b/aidedejeu_flutter/pubspec.lock
index fcf67635..6c1987fc 100644
--- a/aidedejeu_flutter/pubspec.lock
+++ b/aidedejeu_flutter/pubspec.lock
@@ -69,6 +69,20 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
+ flutter_markdown:
+ dependency: "direct main"
+ description:
+ name: flutter_markdown
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.3.3"
+ flutter_svg:
+ dependency: "direct main"
+ description:
+ name: flutter_svg
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.17.1"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -81,6 +95,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
+ markdown:
+ dependency: transitive
+ description:
+ name: markdown
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.1.3"
matcher:
dependency: transitive
description:
@@ -96,12 +117,26 @@ packages:
source: hosted
version: "1.1.8"
path:
- dependency: transitive
+ dependency: "direct main"
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
+ path_drawing:
+ dependency: transitive
+ description:
+ name: path_drawing
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.4.1"
+ path_parsing:
+ dependency: transitive
+ description:
+ name: path_parsing
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.1.4"
pedantic:
dependency: transitive
description:
@@ -135,6 +170,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.5"
+ sqflite:
+ dependency: "direct main"
+ description:
+ name: sqflite
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.2.0"
stack_trace:
dependency: transitive
description:
@@ -156,6 +198,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
+ synchronized:
+ dependency: transitive
+ description:
+ name: synchronized
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.2.0"
term_glyph:
dependency: transitive
description:
@@ -192,4 +241,5 @@ packages:
source: hosted
version: "3.5.0"
sdks:
- dart: ">=2.4.0 <3.0.0"
+ dart: ">=2.6.0 <3.0.0"
+ flutter: ">=1.10.7 <2.0.0"
diff --git a/aidedejeu_flutter/pubspec.yaml b/aidedejeu_flutter/pubspec.yaml
index 76af95c0..a5c5f30e 100644
--- a/aidedejeu_flutter/pubspec.yaml
+++ b/aidedejeu_flutter/pubspec.yaml
@@ -19,7 +19,10 @@ environment:
dependencies:
flutter:
sdk: flutter
-
+ flutter_markdown: ^0.3.3
+ sqflite:
+ path:
+ flutter_svg:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
@@ -41,7 +44,8 @@ flutter:
uses-material-design: true
# To add assets to your application, add an assets section, like this:
- # assets:
+ assets:
+ - assets/
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
@@ -70,3 +74,19 @@ flutter:
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
+ fonts:
+ - family: Cinzel
+ fonts:
+ - asset: assets/Cinzel-Bold.otf
+ weight: 700
+ - asset: assets/Cinzel-Regular.otf
+ - family: LinuxLibertine
+ fonts:
+ - asset: assets/LinLibertine_R.ttf
+ - asset: assets/LinLibertine_RB.ttf
+ weight: 700
+ - asset: assets/LinLibertine_RBI.ttf
+ style: italic
+ weight: 700
+ - asset: assets/LinLibertine_RI.ttf
+ style: italic