Skip to content

Commit

Permalink
0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HumanBot000 committed Jun 18, 2024
1 parent 2c5e400 commit 4cff487
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
build/
# If you're building an application, you may want to check-in your pubspec.lock
pubspec.lock

.github
# Directory created by dartdoc
# If you don't generate documentation locally you can remove this line.
doc/api/
Expand Down
4 changes: 0 additions & 4 deletions lib/duolingoLogin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,13 @@ Future<dynamic> httpCacheManager(String cacheKey, String urlEndpoint,
if ((deletionProbability == 0 ||
Random().nextInt(deletionProbability) == 1) &&
await checkBackendConnection()) {
print("deleting $cacheKey");
await cacheManager.removeFile(cacheKey);
}

var fileInfo = await cacheManager.getFileFromCache(cacheKey);
print('File Info: $fileInfo');

if (fileInfo != null) {
final cachedData = await fileInfo.file.readAsString();
print('Returning cached data for $cacheKey');
if (returnResponseCode) {
return 200;
}
Expand Down Expand Up @@ -86,7 +83,6 @@ Future<dynamic> httpCacheManager(String cacheKey, String urlEndpoint,
eTag: DateTime.now().toIso8601String(),
);
} else {
print('Failed to fetch data: ${response.statusCode}');
}

if (formatAsJson) {
Expand Down
42 changes: 20 additions & 22 deletions lib/home.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'dart:convert';
import 'dart:ffi';
import 'dart:math';

import 'package:flutter/cupertino.dart';
import 'package:vocabulingo/learningSession.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:hive/hive.dart';
import 'package:provider/provider.dart';

import 'package:vocabulingo/main.dart';
import 'package:vocabulingo/src/configuration.dart';
import 'package:vocabulingo/src/icons/my_flutter_app_icons.dart' as CustomIcons;
Expand Down Expand Up @@ -62,9 +61,7 @@ void removeVocabulariesFromTopic(String topicName, List<String>? vocabularies) {

bool topicIsEmpty(String topicName) {
var box = Hive.box('topics');
return box
.get(topicName)
.isEmpty;
return box.get(topicName).isEmpty;
}

void deleteTopic(String topicName) {
Expand Down Expand Up @@ -103,7 +100,6 @@ void addVocabulariesToTopic(String topicName, List<String>? vocabularies) {
}
}


Future<List<Widget>> getOfficialTopicButtons() async {
var username = readHive("username");
var jwt = readHive("jwt");
Expand All @@ -124,7 +120,8 @@ Future<List<Widget>> getOfficialTopicButtons() async {
for (String topic in knownTopics) {
children.add(ElevatedButton(
onPressed: () {},
child: Text(topic, style: const TextStyle(color: Colors.black, fontSize: 20)),
child: Text(topic,
style: const TextStyle(color: Colors.black, fontSize: 20)),
style: ElevatedButton.styleFrom(backgroundColor: Colors.white),
));
}
Expand All @@ -137,9 +134,14 @@ class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
Future<Widget> _infoBar() async {
bool isConnected = await checkBackendConnection();
if (!isConnected) {
return const Row(children: [
Text("Offline, currently using cached data", style: TextStyle(color: Colors.red),),
],);
return const Row(
children: [
Text(
"Offline, currently using cached data",
style: TextStyle(color: Colors.red),
),
],
);
}
var request = await httpCacheManager(
"userInfo_${readHive("username")}", "get_user_info");
Expand Down Expand Up @@ -176,7 +178,8 @@ class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
Row(
children: [
Text("Streak: $streak"),
const Icon(Icons.local_fire_department_rounded, color: Colors.orange),
const Icon(Icons.local_fire_department_rounded,
color: Colors.orange),
],
),
Row(
Expand All @@ -190,7 +193,6 @@ class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
);
}


List<Widget> getTopicButtons(BuildContext context) {
List knownTopics = getAllTopics();
List<Widget> children = [];
Expand All @@ -207,12 +209,11 @@ class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
LearningSession(
topic: topic,
vocabularies: const [],
correctVocabularies: -1,
index: -1),
builder: (context) => LearningSession(
topic: topic,
vocabularies: const [],
correctVocabularies: -1,
index: -1),
));
});
},
Expand Down Expand Up @@ -279,7 +280,6 @@ class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
},
);
} else if (snapshot.hasError) {
print(snapshot.error.toString());
return Text(snapshot.error.toString());
} else {
return snapshot.data!;
Expand Down Expand Up @@ -372,7 +372,6 @@ class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
],
),
);

}
}

Expand Down Expand Up @@ -400,4 +399,3 @@ class Badge extends StatelessWidget {
);
}
}

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 0.1.0
version: 0.2.0

environment:
sdk: '>=3.2.0 <4.0.0'
Expand Down

0 comments on commit 4cff487

Please sign in to comment.