Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sudo-which-qp committed Jan 2, 2024
1 parent 3497bd8 commit a70b835
Show file tree
Hide file tree
Showing 12 changed files with 165 additions and 265 deletions.
7 changes: 5 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if (keystorePropertiesFile.exists()) {
}

android {
compileSdkVersion 33
compileSdkVersion 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -51,7 +51,8 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.viewus.v_notes"
minSdkVersion 21
targetSdkVersion 33
targetSdkVersion 34
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down Expand Up @@ -84,5 +85,7 @@ flutter {
}

dependencies {
def multidex_version = "2.0.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.multidex:multidex:$multidex_version"
}
5 changes: 4 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ buildscript {
google()
mavenCentral()
jcenter()
maven { url 'https://plugins.gradle.org/m2/' }
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
// classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -17,6 +19,7 @@ allprojects {
google()
mavenCentral()
jcenter()
maven { url 'https://plugins.gradle.org/m2/' }
}
}

Expand Down
7 changes: 4 additions & 3 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Fri Jun 23 08:50:38 CEST 2017
#Mon Mar 07 11:00:26 WAT 2022
distributionBase=GRADLE_USER_HOME
#distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
zipStoreBase=GRADLE_USER_HOME
116 changes: 47 additions & 69 deletions lib/app/screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:new_version/new_version.dart';
import 'package:note_app/app/screens/local_notes/local_notes.dart';
import 'package:note_app/app/screens/notifications/notifications_view.dart';
import 'package:note_app/app/screens/settings_screen.dart';
Expand All @@ -15,7 +14,6 @@ import 'package:note_app/models/note_model.dart';
import 'package:note_app/providers/theme_provider.dart';
import 'package:note_app/utils/greetings.dart';
import 'package:note_app/utils/slide_transition.dart';
import 'package:onesignal_flutter/onesignal_flutter.dart';
import 'package:provider/provider.dart';

import 'local_notes/create_note_screen.dart';
Expand All @@ -34,30 +32,10 @@ class _HomeScreenState extends State<HomeScreen> {
void initState() {
super.initState();
storeData = Hive.box<NoteModel>(noteBox);
initPlatformState();
_checkVersion();
// initPlatformState();
}

void _checkVersion() async {
final newVersion = NewVersion(
androidId: androidID,
);
final status = await newVersion.getVersionStatus();
if (status!.canUpdate) {
if(mounted) {
newVersion.showUpdateDialog(
context: context,
versionStatus: status,
dialogTitle: dialogTitle,
dialogText: dialogText,
updateButtonText: 'Update now',
dismissButtonText: 'Maybe Later',
);
}
}
}

static const String oneSignalAppId = 'e41ee34c-a2e9-4345-aa95-078b223419b3';
// static const String oneSignalAppId = 'e41ee34c-a2e9-4345-aa95-078b223419b3';

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -216,50 +194,50 @@ class _HomeScreenState extends State<HomeScreen> {
);
}

Future<void> initPlatformState() async {
if (!mounted) return;

OneSignal.shared.setAppId(oneSignalAppId);

OneSignal.shared
.setNotificationOpenedHandler((OSNotificationOpenedResult result) {
logger.i(result.notification.body);
Navigator.of(context).push(MaterialPageRoute(builder: (_) {
return NotificationView(
title: result.notification.title,
body: result.notification.body,
);
}));
// push to another screen.
});

OneSignal.shared.setNotificationWillShowInForegroundHandler(
(OSNotificationReceivedEvent event) {
logger.i(event.notification.body);
// push to another screen
Navigator.of(context).push(MaterialPageRoute(builder: (_) {
return NotificationView(
title: event.notification.title,
body: event.notification.body,
);
}));

/// Display Notification, send null to not display
event.complete(null);
});

if (Platform.isIOS) {
OneSignal.shared
.setPermissionObserver((OSPermissionStateChanges changes) {
logger.i("PERMISSION STATE CHANGED: ${changes.jsonRepresentation()}");
});

OneSignal.shared
.promptUserForPushNotificationPermission()
.then((accepted) {
logger.i("Accepted permission: $accepted");
});
}
}
// Future<void> initPlatformState() async {
// if (!mounted) return;
//
// OneSignal.shared.setAppId(oneSignalAppId);
//
// OneSignal.shared
// .setNotificationOpenedHandler((OSNotificationOpenedResult result) {
// logger.i(result.notification.body);
// Navigator.of(context).push(MaterialPageRoute(builder: (_) {
// return NotificationView(
// title: result.notification.title,
// body: result.notification.body,
// );
// }));
// // push to another screen.
// });
//
// OneSignal.shared.setNotificationWillShowInForegroundHandler(
// (OSNotificationReceivedEvent event) {
// logger.i(event.notification.body);
// // push to another screen
// Navigator.of(context).push(MaterialPageRoute(builder: (_) {
// return NotificationView(
// title: event.notification.title,
// body: event.notification.body,
// );
// }));
//
// /// Display Notification, send null to not display
// event.complete(null);
// });
//
// if (Platform.isIOS) {
// OneSignal.shared
// .setPermissionObserver((OSPermissionStateChanges changes) {
// logger.i("PERMISSION STATE CHANGED: ${changes.jsonRepresentation()}");
// });
//
// OneSignal.shared
// .promptUserForPushNotificationPermission()
// .then((accepted) {
// logger.i("Accepted permission: $accepted");
// });
// }
// }

}
20 changes: 12 additions & 8 deletions lib/app/screens/local_notes/create_note_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,24 @@ class _CreateNoteScreenState extends State<CreateNoteScreen> {
msg: 'Note Saved',
toastLength: Toast.LENGTH_SHORT,
);
Navigator.of(context).pop();
await Navigator.of(context).push(MaterialPageRoute(builder: (_) {
return const LocalNotesScreen();
}));
if(mounted) {
Navigator.of(context).pop();
await Navigator.of(context).push(MaterialPageRoute(builder: (_) {
return const LocalNotesScreen();
}));
}
_isNotEmpty = true;
} else {
await Fluttertoast.showToast(
msg: 'Note was empty, nothing was saved',
toastLength: Toast.LENGTH_SHORT,
);
Navigator.of(context).pop();
await Navigator.of(context).push(MaterialPageRoute(builder: (_) {
return const LocalNotesScreen();
}));
if(mounted) {
Navigator.of(context).pop();
await Navigator.of(context).push(MaterialPageRoute(builder: (_) {
return const LocalNotesScreen();
}));
}
_isNotEmpty = false;
}
return _isNotEmpty!;
Expand Down
9 changes: 4 additions & 5 deletions lib/app/screens/local_notes/local_notes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:flutter/services.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:new_version/new_version.dart';
import 'package:note_app/app/screens/local_notes/read_notes_screens.dart';
import 'package:note_app/const_values.dart';
import 'package:note_app/models/note_model.dart';
Expand Down Expand Up @@ -152,10 +151,10 @@ class _LocalNotesScreenState extends State<LocalNotesScreen> {
)
: null,
body: storeData!.isEmpty
? Center(
? const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
children: [
Text(
'No Notes Yet... \n(Tap on the Add Button below)',
style: TextStyle(
Expand Down Expand Up @@ -268,7 +267,7 @@ class _LocalNotesScreenState extends State<LocalNotesScreen> {
child: Column(
children: [
Text(
'${note.notes!.length >= 70 ? note.notes!.substring(0, 70) + '...' : note.notes}',
'${note.notes!.length >= 70 ? '${note.notes!.substring(0, 70)}...' : note.notes}',
style: const TextStyle(),
softWrap: true,
),
Expand Down Expand Up @@ -354,7 +353,7 @@ class _LocalNotesScreenState extends State<LocalNotesScreen> {
CrossAxisAlignment.start,
children: [
Text(
'${note.notes!.length >= 70 ? note.notes!.substring(0, 70) + '...' : note.notes}',
'${note.notes!.length >= 70 ? '${note.notes!.substring(0, 70)}...' : note.notes}',
style: const TextStyle(
fontSize: 18,
),
Expand Down
10 changes: 5 additions & 5 deletions lib/app/screens/local_notes/read_notes_screens.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class _ReadNotesScreenState extends State<ReadNotesScreen> {
dynamic languages;
String? language;
double? volume = 0.5;
double? pitch = 1.0;
double? pitch = 0.8;
double? rate = 0.9;

String? _newVoiceText;
Expand Down Expand Up @@ -235,16 +235,16 @@ class _ReadNotesScreenState extends State<ReadNotesScreen> {
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: checkButtonState.mPlayButton == false
? FloatingActionButton(
backgroundColor: Colors.white60,
onPressed: () {
ttsState == TtsState.stopped ? _speak() : _stop();
},
child: Icon(
ttsState == TtsState.stopped
? Icons.play_circle_outline
: Icons.stop_circle_outlined,
color: Colors.black45,
),
backgroundColor: Colors.white60,
onPressed: () {
ttsState == TtsState.stopped ? _speak() : _stop();
},
)
: null,
);
Expand Down
6 changes: 3 additions & 3 deletions lib/app/screens/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
import 'package:note_app/app/screens/trash_screen/trashed_notes.dart';
import 'package:note_app/providers/hide_play_button_provider.dart';
import 'package:note_app/providers/theme_provider.dart';
import 'package:package_info/package_info.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:provider/provider.dart';

class SettingsScreen extends StatefulWidget {
Expand Down Expand Up @@ -51,9 +51,9 @@ class _SettingsScreenState extends State<SettingsScreen> {
child: Column(
children: [
//Body here
SizedBox(
const SizedBox(
child: Column(
children: const [
children: [
Text(
'VNotes',
style: TextStyle(
Expand Down
7 changes: 3 additions & 4 deletions lib/const_values.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:logger/logger.dart';

var logger = Logger();

String apiUrl = dotenv.env['API_URL'].toString();
String payStackPubKey = dotenv.env['PAYSTACK_PUB_KEY'].toString();
String payStackSecKey = dotenv.env['PAYSTACK_SEC_KEY'].toString();
// String apiUrl = dotenv.env['API_URL'].toString();
// String payStackPubKey = dotenv.env['PAYSTACK_PUB_KEY'].toString();
// String payStackSecKey = dotenv.env['PAYSTACK_SEC_KEY'].toString();

const String androidID = 'com.viewus.v_notes';
const String dialogTitle = 'Update V Notes';
Expand Down
5 changes: 3 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import 'package:note_app/providers/hide_play_button_provider.dart';
import 'package:note_app/providers/theme_provider.dart';
import 'package:path_provider/path_provider.dart';
import 'package:provider/provider.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await dotenv.load(fileName: ".env");


// await dotenv.load(fileName: ".env");
Directory document = await getApplicationDocumentsDirectory();
Hive
..init(document.path)
Expand Down
Loading

0 comments on commit a70b835

Please sign in to comment.