Browse Source

Implemented mood checkup forms

main
root 4 months ago
parent
commit
76043e0513
  1. 2
      .flutter-plugins-dependencies
  2. 7
      .packages
  3. 2
      android/app/src/main/AndroidManifest.xml
  4. 2
      lib/data/db.dart
  5. 8
      lib/helpers/human-readable.dart
  6. 10
      lib/main.dart
  7. 121
      lib/pages/MoodForm.dart
  8. 5
      lib/providers/db.dart
  9. 3
      pubspec.yaml

2
.flutter-plugins-dependencies

@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"sqflite","path":"/home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/","dependencies":[]}],"android":[{"name":"sqflite","path":"/home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/","dependencies":[]}],"macos":[{"name":"sqflite","path":"/home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/","dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"sqflite","dependencies":[]}],"date_created":"2021-08-12 21:43:21.552824","version":"2.2.3"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"sqflite","path":"/home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/","dependencies":[]}],"android":[{"name":"sqflite","path":"/home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/","dependencies":[]}],"macos":[{"name":"sqflite","path":"/home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/","dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"sqflite","dependencies":[]}],"date_created":"2021-08-12 23:48:58.581824","version":"2.2.3"}

7
.packages

@ -3,7 +3,7 @@
#
# For more info see: https://dart.dev/go/dot-packages-deprecation
#
# Generated by pub on 2021-08-12 21:43:21.396263.
# Generated by pub on 2021-08-12 22:07:47.580095.
_fe_analyzer_shared:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-22.0.0/lib/
analyzer:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-1.7.1/lib/
args:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/args-2.2.0/lib/
@ -27,6 +27,7 @@ collection:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartla
convert:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/convert-3.0.1/lib/
crypto:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/crypto-3.0.1/lib/
dart_style:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/dart_style-2.0.3/lib/
equatable:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/equatable-2.0.3/lib/
fake_async:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/fake_async-1.2.0/lib/
ffi:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/ffi-1.1.2/lib/
file:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/file-6.1.2/lib/
@ -35,7 +36,9 @@ floor:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.or
floor_annotation:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/floor_annotation-1.0.0/lib/
floor_generator:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/floor_generator-1.1.0/lib/
flutter:file:///home/diane/dev/softwares/flutter/packages/flutter/lib/
flutter_riverpod:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_riverpod-0.14.0+3/lib/
flutter_test:file:///home/diane/dev/softwares/flutter/packages/flutter_test/lib/
freezed_annotation:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/freezed_annotation-0.14.2/lib/
frontend_server_client:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/frontend_server_client-2.1.0/lib/
glob:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/glob-2.0.1/lib/
graphs:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/graphs-2.0.0/lib/
@ -54,6 +57,7 @@ pedantic:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang
pool:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/pool-1.5.0/lib/
pub_semver:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/pub_semver-2.0.0/lib/
pubspec_parse:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/pubspec_parse-1.0.0/lib/
riverpod:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/riverpod-0.14.0+3/lib/
shelf:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/shelf-1.2.0/lib/
shelf_web_socket:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/shelf_web_socket-1.0.1/lib/
sky_engine:file:///home/diane/dev/softwares/flutter/bin/cache/pkg/sky_engine/lib/
@ -64,6 +68,7 @@ sqflite_common:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.da
sqflite_common_ffi:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite_common_ffi-2.0.0+1/lib/
sqlite3:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/sqlite3-1.1.2/lib/
stack_trace:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.10.0/lib/
state_notifier:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/state_notifier-0.7.0/lib/
stream_channel:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.1.0/lib/
stream_transform:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/stream_transform-2.0.0/lib/
string_scanner:file:///home/diane/dev/softwares/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.1.0/lib/

2
android/app/src/main/AndroidManifest.xml

@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.artemix.mooddroid">
<application
android:label="mooddroid"
android:label="MoodDroid"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"

2
lib/data/db.dart

@ -25,5 +25,3 @@ abstract class AppDatabase extends FloorDatabase {
MoodDao get moodDao;
}
Future<AppDatabase> createDb() async =>
await $FloorAppDatabase.databaseBuilder('app_database.db').build();

8
lib/helpers/human-readable.dart

@ -7,3 +7,11 @@ String readableMood(MoodLevel l) => {
MoodLevel.low: "Feeling down",
MoodLevel.depressive: "Bad.",
}[l]!;
String tellMoreLabel(MoodLevel l) => {
MoodLevel.manic: "That's cool!",
MoodLevel.high: "Good :3",
MoodLevel.neutral: "Any plans?",
MoodLevel.low: "Please rest a bit",
MoodLevel.depressive: "Take some time, dear",
}[l]!;

10
lib/main.dart

@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:mood_droid/constants.dart';
import 'package:mood_droid/pages/MoodDump.dart';
import 'package:mood_droid/pages/MoodForm.dart';
Future<void> main() async {
main() async {
runApp(MoodDroid());
}
@ -12,7 +12,11 @@ class MoodDroid extends StatelessWidget {
return MaterialApp(
title: AppTitle,
theme: AppTheme,
home: MoodDump(),
initialRoute: '/enter-mood/1',
routes: {
'/enter-mood/1': (context) => MoodPicker(),
'/enter-mood/2': (context) => MoodWriter(),
},
);
}
}

121
lib/pages/MoodForm.dart

@ -0,0 +1,121 @@
import 'package:flutter/material.dart';
import 'package:mood_droid/constants.dart';
import 'package:mood_droid/data/mood.dart';
import 'package:mood_droid/helpers/human-readable.dart';
class MoodPicker extends StatefulWidget {
@override
State<StatefulWidget> createState() => MoodPickerState();
}
class MoodPickerState extends State<MoodPicker> {
MoodLevel _mood = MoodLevel.neutral;
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: Text(AppTitle),
),
body: Column(
children: [
Padding(
padding: EdgeInsets.only(top: 16, bottom: 16),
child: Text(
'How are you feeling?',
style: Theme.of(context).textTheme.headline5,
),
),
...MoodLevel.values.map(
(e) => RadioListTile<MoodLevel>(
title: Text(readableMood(e)),
value: e,
groupValue: _mood,
onChanged: (v) {
setState(() {
if (v != null) {
_mood = v;
}
});
},
),
),
Padding(
padding: EdgeInsets.all(16),
child: SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () {
Navigator.popAndPushNamed(
context,
'/enter-mood/2',
arguments: _mood,
);
},
child: const Text('Okay'),
),
),
)
],
),
);
}
class MoodWriter extends StatefulWidget {
@override
State<StatefulWidget> createState() => MoodWriterState();
}
class MoodWriterState extends State<MoodWriter> {
String _talk = '';
@override
Widget build(BuildContext context) {
final MoodLevel mood =
ModalRoute.of(context)!.settings.arguments as MoodLevel;
return Scaffold(
appBar: AppBar(title: Text(AppTitle)),
body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
children: [
Padding(
padding: EdgeInsets.only(bottom: 16),
child: Text(
tellMoreLabel(mood),
style: Theme.of(context).textTheme.headline5,
),
),
TextFormField(
decoration: const InputDecoration(
labelText: 'Do you want to tell me more?',
),
keyboardType: TextInputType.multiline,
maxLines: null,
onChanged: (v) {
setState(() {
_talk = v;
});
},
),
Padding(
padding: EdgeInsets.only(top: 16),
child: SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () {
// TODO
},
child:
Text(_talk.length > 0 ? 'This is it' : 'No, thanks.'),
),
),
),
],
),
),
),
);
}
}

5
lib/providers/db.dart

@ -0,0 +1,5 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:mood_droid/data/db.dart';
final $db = FutureProvider<AppDatabase>(
(ref) => $FloorAppDatabase.databaseBuilder('app_database.db').build());

3
pubspec.yaml

@ -10,6 +10,9 @@ dependencies:
flutter:
sdk: flutter
floor: ^1.1.0
equatable: ^2.0.0
flutter_riverpod: ^0.14.0+3
riverpod: ^0.14.0+3
dev_dependencies:
flutter_test: