Skip to content

Commit

Permalink
Merge pull request #4 from xpavle00/dev
Browse files Browse the repository at this point in the history
Code reorganized
  • Loading branch information
xpavle00 authored Sep 30, 2021
2 parents e4e79d5 + d73ce17 commit 4b0ae6d
Show file tree
Hide file tree
Showing 36 changed files with 1,854 additions and 1,343 deletions.
17 changes: 9 additions & 8 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ if (localPropertiesFile.exists()) {
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
Expand All @@ -32,7 +29,7 @@ if (keystorePropertiesFile.exists()) {
}

android {
compileSdkVersion 28
compileSdkVersion 30

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -42,11 +39,15 @@ android {
disable 'InvalidPackage'
}

dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.pavlenko.Habo"
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 30
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -78,6 +79,6 @@ flutter {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
18 changes: 13 additions & 5 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Habo"
android:icon="@mipmap/ic_launcher">
<activity
Expand All @@ -19,23 +18,32 @@
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />

<!-- Theme to apply as soon as Flutter begins rendering frames -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"></action>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
</application>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</manifest>
7 changes: 7 additions & 0 deletions android/app/src/main/kotlin/com/example/Habo/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.Habo

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {

}
13 changes: 0 additions & 13 deletions android/app/src/main/kotlin/com/example/habit_easy/MainActivity.kt

This file was deleted.

4 changes: 4 additions & 0 deletions android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- You can name this style whatever you'd like -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
</resources>
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.3.10'
ext.kotlin_version = '1.5.31'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.android.tools.build:gradle:7.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
Binary file added assets/sounds/check.wav
Binary file not shown.
Binary file added assets/sounds/click.wav
Binary file not shown.
35 changes: 35 additions & 0 deletions lib/habit_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import 'dart:collection';

import 'package:flutter/material.dart';
import 'package:table_calendar/table_calendar.dart';

class HabitData {
HabitData(
{this.id,
this.position,
this.title,
this.twoDayRule,
this.cue,
this.routine,
this.reward,
this.showReward,
this.advanced,
this.notification,
this.notTime,
this.events});

SplayTreeMap<DateTime, List> events;
int streak = 0;
CalendarController calendarController = new CalendarController();
int id;
int position;
String title;
bool twoDayRule;
String cue;
String routine;
String reward;
bool showReward;
bool advanced;
bool notification;
TimeOfDay notTime;
}
11 changes: 7 additions & 4 deletions lib/helpers.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'package:Habo/widgets/create_page.dart';
import 'package:Habo/widgets/settings_page.dart';
import 'package:Habo/screens/create_habit_screen.dart';
import 'package:Habo/screens/settings_screen.dart';
import 'package:flutter/material.dart';

Future navigateToSettingsPage(context) async {
Navigator.push(context, MaterialPageRoute(builder: (context) => Settings()));
Navigator.push(
context, MaterialPageRoute(builder: (context) => SettingsScreen()));
}

Future navigateToCreatePage(context) async {
Navigator.push(
context, MaterialPageRoute(builder: (context) => CreateHabitPage()));
context, MaterialPageRoute(builder: (context) => CreateHabitScreen()));
}

TimeOfDay parseTimeOfDay(String value) {
Expand All @@ -20,3 +21,5 @@ TimeOfDay parseTimeOfDay(String value) {

return TimeOfDay(hour: 12, minute: 0);
}

enum DayType { Clear, Check, Fail, Skip }
56 changes: 9 additions & 47 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:Habo/helpers.dart';
import 'package:Habo/provider.dart';
import 'package:Habo/widgets/calendar_column.dart';
import 'package:Habo/widgets/loading.dart';
import 'package:Habo/screens/home_screen.dart';
import 'package:Habo/screens/loading_screen.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand All @@ -21,57 +20,20 @@ class Habo extends StatelessWidget {
DeviceOrientation.portraitUp,
]);
return MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => Bloc()),
],
child: Consumer<Bloc>(builder: (context, counter, _) {
providers: [
ChangeNotifierProvider(create: (_) => Bloc()),
],
child: Consumer<Bloc>(
builder: (context, counter, _) {
final bloc = Provider.of<Bloc>(context);
return MaterialApp(
scaffoldMessengerKey: Provider.of<Bloc>(context).getScaffoldKey,
theme: Provider.of<Bloc>(context).getSettings.getLight,
darkTheme: Provider.of<Bloc>(context).getSettings.getDark,
home: !bloc.getDataLoaded ? LoadingScreen() : HomeScreen(),
);
}));
}
}

class HomeScreen extends StatelessWidget {
const HomeScreen({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
child: Scaffold(
key: Provider.of<Bloc>(context).getScafoldKey,
appBar: AppBar(
title: Text(
"Habo",
style: Theme.of(context).textTheme.headline5,
),
backgroundColor: Colors.transparent,
actions: <Widget>[
IconButton(
icon: const Icon(Icons.settings),
color: Colors.grey[400],
tooltip: 'Settings',
onPressed: () {
Provider.of<Bloc>(context, listen: false).hideSnackBar();
navigateToSettingsPage(context);
},
),
]),
body: CalendarColumn(),
floatingActionButton: FloatingActionButton(
onPressed: () {
Provider.of<Bloc>(context, listen: false).hideSnackBar();
navigateToCreatePage(context);
},
child: Icon(
Icons.add,
color: Colors.white,
size: 35.0,
),
),
));
);
}
}
Loading

0 comments on commit 4b0ae6d

Please sign in to comment.