Alphons Jaimon
Created May 12, 2020

Mood Hacker - Hacking Mood Swings using a Smartphone App

A quick app to track and help you come out of various Menopause symptoms. Mainly focusing on meditation, concentration and music.

BeginnerWork in progress4 hours23
Mood Hacker - Hacking Mood Swings using a Smartphone App

Things used in this project

Software apps and online services

Android Studio
Android Studio
Google Flutter SDK

Story

Read more

Schematics

Project Structure (current)

Current project structure.

Project Structure (proposed)

The proposed project structure.

Code

Pubspec.yaml

YAML
the pubspec.yml file for project depensencies.
name: menomoodhack
description: Control menopause mood swings. Based on meditation and music techniques.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+6
environment:
  sdk: ">=2.7.0 <3.0.0"
dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^0.1.3
  curved_navigation_bar: ^0.3.2
  dio: ^3.0.9
  flutter_web_browser: ^0.11.0
  path_provider: ^1.6.7
  youtube_player_flutter: ^6.1.1
  barbarian: ^0.2.26+6
  flutter_input: ^1.3.0

dev_dependencies:
  flutter_test:
    sdk: flutter
flutter:
  uses-material-design: true
  assets:
    - asset/images/
    - asset/
  fonts:
    - family: Lobster
      fonts:
        - asset: asset/fonts/Lobster-Regular.ttf
    - family: Righteous
      fonts:
        - asset: asset/fonts/Righteous-Regular.ttf

main.dart

Dart
The main dart file of the project!
import 'package:flutter/material.dart';
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'content.dart';

Content cont = new Content();
void main() => runApp(MaterialApp( home: MenoMood(),  title: 'MenoHack', ), );
class MenoMood extends StatefulWidget { @override _MenoMoodState createState() { cont.makeList(); return _MenoMoodState(); } }
class _MenoMoodState extends State<MenoMood> {
  int _page = 0; 
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: Text('Menopause Mood Hack!',
          style: TextStyle(fontFamily: 'Lobster', fontSize: 30),),
          backgroundColor: Colors.pink,),
        bottomNavigationBar: CurvedNavigationBar( index: 0, height: 50.0, items: cont.menuIcons,
          color: Colors.yellow.shade200, buttonBackgroundColor: Colors.white, backgroundColor: Colors.teal.shade700,
          animationCurve: Curves.easeInOut, animationDuration: Duration(milliseconds: 300),
          onTap: (index) { setState(() { _page = index; }); },
        ),
        body: Container(
          decoration: BoxDecoration(image: DecorationImage(image: AssetImage('asset/images/splash.png'), fit: BoxFit.cover)),
          child: Center( child: ListView(children: cont.changePage(_page) ), ),
        ),
    );
  }
}

content.dart

Dart
Another file which is called by main,dart This file (content.dart) contains all the IMP code for the project.
import 'dart:io';
import 'dart:io' show File;
import 'dart:convert' show json;
import 'package:flutter/material.dart';
import 'package:dio/dio.dart';
import 'package:flutter_web_browser/flutter_web_browser.dart';
import 'package:path_provider/path_provider.dart';
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
import 'package:barbarian/barbarian.dart';

class Content {
  // ----------------------------
  static double _widSize = 25;
  // bottom bar icons
  List<Widget> menuIcons = [
    Icon(Icons.assessment, size: _widSize),
    Icon(Icons.art_track, size: _widSize),
    Icon(Icons.assignment_turned_in, size: _widSize),
    Icon(Icons.library_music, size: _widSize),
    Icon(Icons.record_voice_over, size: _widSize),
    Icon(Icons.help_outline, size: _widSize), ];
  // widget lists
  List<Widget> insightsWid = [head("Insights"),];
  List<Widget> blogWid = [head("Blogs"),];
  List<Widget> activityWid = [head("Activity"),];
  List<Widget> aboutWid = [head("About"),];
  List<Widget> audWid = [head("Listen"),];
  List<Widget> voiceWid = [head("Speakup"),];
  // change page code
  changePage(int index){
    if (index == 0) return insightsWid;
    else if (index == 1) return blogWid;
    else if (index == 2) return activityWid;
    else if (index == 3) return audWid;
    else if (index == 4) return voiceWid;
    else if (index == 5) return aboutWid;
  }
  // in-app browser
  static openBrowserTab(String url) async { await FlutterWebBrowser.openWebPage(url: url, androidToolbarColor: Colors.pink.shade100); }
  // head of every page
  static Widget head(String txt){
    return Padding(
      padding: const EdgeInsets.all(3.0),
      child: SizedBox( width: double.infinity,
        child: MaterialButton( disabledColor: Colors.yellow.shade300,
          child: Text(txt, style: TextStyle(fontSize: 40.0, fontFamily: 'Righteous', color: Colors.blue.shade400,), ),
        ),
      ),
    );
  }
  // health data
  List water = [];
  List period = [];
  List sleep = [];
  // damn call everything I know of!
  makeList(){
    insights();
    blogify();
    activify();
    musicify();
    speakfy();
    theAbout();
  }
  // ------------------------ TODO: Insights
  insights() async {
    insightsWid.add(blogsnip("Nothing to show, prototype Stage", "https://github.com/AJV009/meno_mood_hack"));
  }
  // ----------------------------
  // blogsnipmaker downloader
  blogify() async {
    String jsonfile = "https://raw.githubusercontent.com/AJV009/meno_mood_hack/master/netData/blog.json";
    Directory appDirectory = await getApplicationDocumentsDirectory();
    String savePath = appDirectory.path+"/blog.json";
    try {await Dio().download(jsonfile,savePath);}
    catch(e){}
    Map jsondata = json.decode(await new File(savePath).readAsString());
    jsondata.forEach((key, value) {
      blogWid.add(blogsnip(key, value));
    });
  }
  // create blogsnip widgets
  static Widget blogsnip(String desc, String url) {
    return Padding(
      padding: const EdgeInsets.all(3.0),
      child: SizedBox(
        width: double.infinity,
        child: FlatButton(
            color: Colors.pink.shade50,
            onPressed: () => openBrowserTab(url),
            child: Text(desc, style: TextStyle(fontSize: 20.0,),),
            shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
        ),
      ),
    );
  }
  // --------------------- TODO: Activity
  activify() async {
    barbaDataCheck();
    final myController = TextEditingController();
    @override
    void dispose() {
      myController.dispose();
      super.dispose();
    }
    activityWid.add(Padding(
      padding: const EdgeInsets.all(3.0),
      child: SizedBox(
        width: double.infinity,
        child: InputChip(label: Text("Water Intake"))
      ),
    ),
    );
  }
  barbaDataCheck() async {
    await Barbarian.init();
    try {
      water = Barbarian.read('water');
      period = Barbarian.read('period');
      sleep = Barbarian.read('sleep');
    }
    catch(e){}
    Barbarian.write('water', water);
    Barbarian.write('period', period);
    Barbarian.write('sleep', sleep);
  }
  // ----------------------------
  musicify() async {
    String jsonfile = "https://raw.githubusercontent.com/AJV009/meno_mood_hack/master/netData/music.json";
    Directory appDirectory = await getApplicationDocumentsDirectory();
    String savePath = appDirectory.path+"/music.json";
    try {await Dio().download(jsonfile,savePath);}
    catch(e){}
    Map jsondata = json.decode(await new File(savePath).readAsString());
    jsondata.forEach((key, value) {
      YoutubePlayerController controller = YoutubePlayerController(
          initialVideoId: YoutubePlayer.convertUrlToId(value),
          flags: YoutubePlayerFlags( autoPlay: false, loop: true) );
      audWid.add(YoutubePlayer( controller: controller, showVideoProgressIndicator: false, ));
    });
  }
  // ----------------- TODO: voice assistant
  speakfy(){
    voiceWid.add(blogsnip("Click here to search doctors nearby", "https://www.google.com/maps/search/doctors+nearby"));
  }
  // ---------------- TODO: About
  theAbout() async {
    String introstring = "This is an Open Source project developed for the Hackster.io Hacking "
        "menopause competition. We are aiming to combine blogs, AI assistant, VR/AR visuals, AI, "
        "quick diagnosis, emergency contacts anf fourm to a single free app";
    aboutWid.add(
        Padding(
          padding: const EdgeInsets.all(3.0),
          child: SizedBox(
            width: double.infinity,
            child: MaterialButton( disabledColor: Colors.yellow.shade300,
              child: Text(introstring, style: TextStyle(fontSize: 20.0, color: Colors.blue,), ),
            ),
          ),
        ),
    );
    String contrib = "You cantribute to meno_mood_hack repo by ajv009 in GitHub";
    aboutWid.add(blogsnip(contrib, "https://github.com/AJV009/meno_mood_hack"));
  }
  // ----------------------------
}

Github

Meno Mood Hack whole repo

Credits

Alphons Jaimon

Alphons Jaimon

3 projects • 9 followers
A CS student. I have been developing for less than 1 yr. I learned about IoT in 2012 with a book -> FastTrack to Raspberry Pi by Digit.

Comments