From c127a273ab0ff0a358eb1fe22ae7fa2b0c34f68b Mon Sep 17 00:00:00 2001 From: FIRST_NAME LAST_NAME Date: Fri, 4 Oct 2024 09:20:24 +0300 Subject: [PATCH 1/5] fix: bugs on starred topics --- lib/tools/anki/pages/create_topic_form.dart | 10 ++++- .../pages/populated_anki_home_screen.dart | 41 ++++++++++--------- lib/tools/anki/widgets/grid_topics.dart | 8 ++-- lib/tools/anki/widgets/starred_topic.dart | 1 + 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/lib/tools/anki/pages/create_topic_form.dart b/lib/tools/anki/pages/create_topic_form.dart index b7c3a28..ab7bb6e 100644 --- a/lib/tools/anki/pages/create_topic_form.dart +++ b/lib/tools/anki/pages/create_topic_form.dart @@ -36,6 +36,7 @@ class CreateTopicForm extends StatelessWidget { const SizedBox(height: 8), TextFormField( controller: descController, + maxLength: 50, maxLines: 10, decoration: InputDecoration( hintText: "Write a description for your topic", @@ -55,7 +56,7 @@ class CreateTopicForm extends StatelessWidget { duration: Duration(seconds: 1), ), ); - } else if (titleController.text.trim().length <= 3) { + } else if (titleController.text.trim().length < 3) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text( @@ -90,6 +91,13 @@ class CreateTopicForm extends StatelessWidget { // updating topic list and favorites topicController.getAllTopics(); topicController.getAllFavourites(); + // informing user successful creation + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text("Topic successfully created!!"), + duration: Duration(seconds: 1), + ), + ); Navigator.of(context).pop(); } }, diff --git a/lib/tools/anki/pages/populated_anki_home_screen.dart b/lib/tools/anki/pages/populated_anki_home_screen.dart index 39da42f..ff56833 100644 --- a/lib/tools/anki/pages/populated_anki_home_screen.dart +++ b/lib/tools/anki/pages/populated_anki_home_screen.dart @@ -16,25 +16,28 @@ class PopulatedAnkiHomeScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - Visibility( - visible: topicController.allFavourites.isNotEmpty, - child: Align( - alignment: Alignment.center, - child: Container( - padding: const EdgeInsets.symmetric(vertical: 8), - height: MediaQuery.of(context).size.height * 0.27, - width: MediaQuery.of(context).size.width * 0.87, - child: ListView.builder( - scrollDirection: Axis.horizontal, - itemBuilder: (context, idx) { - return StarredTopics( - idx: topicController.allFavourites[idx].id!, - topic: topicController.allFavourites[idx].name, - desc: topicController.allFavourites[idx].desc, - topicController: topicController, - ); - }, - itemCount: topicController.allFavourites.length, + // displays favourite topics + Obx( + () => Visibility( + visible: topicController.allFavourites.isNotEmpty, + child: Align( + alignment: Alignment.center, + child: Container( + padding: const EdgeInsets.symmetric(vertical: 8), + height: MediaQuery.of(context).size.height * 0.27, + width: MediaQuery.of(context).size.width * 0.87, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemBuilder: (context, idx) { + return StarredTopics( + idx: topicController.allFavourites[idx].id!, + topic: topicController.allFavourites[idx].name, + desc: topicController.allFavourites[idx].desc, + topicController: topicController, + ); + }, + itemCount: topicController.allFavourites.length, + ), ), ), ), diff --git a/lib/tools/anki/widgets/grid_topics.dart b/lib/tools/anki/widgets/grid_topics.dart index faa9e3a..7846029 100644 --- a/lib/tools/anki/widgets/grid_topics.dart +++ b/lib/tools/anki/widgets/grid_topics.dart @@ -36,12 +36,12 @@ class GridViewTopic extends StatelessWidget { child: Container( decoration: BoxDecoration( color: colorDet == 0 - ? const Color(0xff8999aa) + ? Theme.of(context).colorScheme.primaryContainer : colorDet == 1 - ? const Color(0xffffcdfe) + ? Theme.of(context).colorScheme.secondaryContainer : colorDet == 2 - ? const Color(0xffffe7cd) - : const Color(0xffcdffce), + ? Theme.of(context).colorScheme.tertiaryContainer + : Theme.of(context).colorScheme.errorContainer, borderRadius: const BorderRadius.all( Radius.circular(8), ), diff --git a/lib/tools/anki/widgets/starred_topic.dart b/lib/tools/anki/widgets/starred_topic.dart index 2f0383a..10188d1 100644 --- a/lib/tools/anki/widgets/starred_topic.dart +++ b/lib/tools/anki/widgets/starred_topic.dart @@ -100,6 +100,7 @@ class StarredTopics extends StatelessWidget { right: 0, child: Row( children: [ + // unfavourite a topic from favourited topics IconButton( onPressed: () async { AnkiTopic topic = AnkiTopic( From 734cb763520f565c56603a92f555691d1cd61c4a Mon Sep 17 00:00:00 2001 From: FIRST_NAME LAST_NAME Date: Fri, 4 Oct 2024 09:41:24 +0300 Subject: [PATCH 2/5] fix: fixed broken functionalities in grid view topics --- .../pages/populated_anki_home_screen.dart | 2 +- lib/tools/anki/widgets/grid_topics.dart | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/tools/anki/pages/populated_anki_home_screen.dart b/lib/tools/anki/pages/populated_anki_home_screen.dart index ff56833..ea52233 100644 --- a/lib/tools/anki/pages/populated_anki_home_screen.dart +++ b/lib/tools/anki/pages/populated_anki_home_screen.dart @@ -60,7 +60,7 @@ class PopulatedAnkiHomeScreen extends StatelessWidget { topic: topicController.allTopics[idx].name, topicDesc: topicController.allTopics[idx].desc, isFavourite: topicController.allTopics[idx].isFavourite, - controller: topicController, + // controller: topicController, ); }, itemCount: topicController.allTopics.length, diff --git a/lib/tools/anki/widgets/grid_topics.dart b/lib/tools/anki/widgets/grid_topics.dart index 7846029..feee50c 100644 --- a/lib/tools/anki/widgets/grid_topics.dart +++ b/lib/tools/anki/widgets/grid_topics.dart @@ -2,6 +2,7 @@ import 'package:academia/exports/barrel.dart'; import 'package:academia/tools/anki/controllers/controllers.dart'; import 'package:academia/tools/anki/models/models.dart'; import 'package:academia/tools/anki/pages/flashcards.dart'; +import 'package:get/get.dart'; class GridViewTopic extends StatelessWidget { const GridViewTopic({ @@ -11,7 +12,6 @@ class GridViewTopic extends StatelessWidget { required this.topic, required this.topicDesc, required this.isFavourite, - this.controller, }); final int idx; @@ -19,11 +19,12 @@ class GridViewTopic extends StatelessWidget { final String topic; final String topicDesc; final bool isFavourite; - final TopicController? controller; @override Widget build(BuildContext context) { var colorDet = idx % 4; + final TopicController controller = Get.find(); + return GestureDetector( onTap: () => Navigator.push( context, @@ -67,15 +68,15 @@ class GridViewTopic extends StatelessWidget { onPressed: () async { // create a topic object AnkiTopic topic = AnkiTopic( - id: idx, + id: topicId, name: this.topic, desc: topicDesc, isFavourite: isFavourite, ); - await controller?.favouriteTopic(topic); + await controller.favouriteTopic(topic); // update favourites and all topics - await controller?.getAllFavourites(); - await controller?.getAllTopics(); + await controller.getAllFavourites(); + await controller.getAllTopics(); // ignore: use_build_context_synchronously ScaffoldMessenger.of(context).showSnackBar( SnackBar( @@ -103,16 +104,15 @@ class GridViewTopic extends StatelessWidget { OutlinedButton( onPressed: () async { AnkiTopic topic = AnkiTopic( - id: idx, + id: topicId, name: this.topic, desc: topicDesc, ); - bool? deleted = - await controller?.deleteTopic(topic); + bool deleted = await controller.deleteTopic(topic); // ignore: use_build_context_synchronously ScaffoldMessenger.of(context).showSnackBar( SnackBar( - content: (deleted != null && deleted) + content: (deleted) ? const Text("Topic Successfully Deleted") : const Text( "Something happened! Kindly Retry!!"), @@ -120,8 +120,8 @@ class GridViewTopic extends StatelessWidget { ), ); // update favourites and all topics - await controller?.getAllFavourites(); - await controller?.getAllTopics(); + await controller.getAllFavourites(); + await controller.getAllTopics(); // ignore: use_build_context_synchronously Navigator.of(context).pop(); }, From dac385fd4a9836c7dcbaaf3137acb4569743fd47 Mon Sep 17 00:00:00 2001 From: FIRST_NAME LAST_NAME Date: Fri, 4 Oct 2024 11:27:59 +0300 Subject: [PATCH 3/5] fix: fixed anki cards related to topics not loading --- .../anki/controllers/ankicard_controller.dart | 18 ++--------- lib/tools/anki/pages/anki_home.dart | 2 ++ lib/tools/anki/pages/create_ankicard.dart | 21 ++++++++----- lib/tools/anki/pages/edit_anki_card.dart | 3 +- lib/tools/anki/pages/flashcards.dart | 13 ++++---- .../pages/populated_anki_home_screen.dart | 4 +-- lib/tools/anki/widgets/grid_topics.dart | 21 ++++++++----- lib/tools/anki/widgets/starred_topic.dart | 31 +++++++++---------- lib/tools/anki/widgets/topic_flashcard.dart | 2 +- 9 files changed, 56 insertions(+), 59 deletions(-) diff --git a/lib/tools/anki/controllers/ankicard_controller.dart b/lib/tools/anki/controllers/ankicard_controller.dart index 2efe9b5..74ef13c 100644 --- a/lib/tools/anki/controllers/ankicard_controller.dart +++ b/lib/tools/anki/controllers/ankicard_controller.dart @@ -1,22 +1,8 @@ -import 'package:academia/exports/barrel.dart'; import 'package:academia/tools/anki/models/models.dart'; import 'package:get/get.dart'; class AnkiCardController extends GetxController { - AnkiCardController({ - required this.topicId, - }); - final RxList allCards = [].obs; - final int topicId; - - @override - void onInit() { - super.onInit(); - getAllTopicCards().then((value) { - debugPrint("[+] Anki Topic Cards Loaded"); - }); - } // returns the number of topics int numAnkiCards() { @@ -33,7 +19,7 @@ class AnkiCardController extends GetxController { return value == 0 ? false : true; } - Future> getAllTopicCards() async { + Future> getAllTopicCards(int topicId) async { AnkiCardModelHelper().queryAnkiCardsByTopic(topicId).then((values) { allCards.clear(); values = values.reversed.toList(); @@ -46,7 +32,7 @@ class AnkiCardController extends GetxController { Future deleteCard(AnkiCard ankiCard) async { int value = await AnkiCardModelHelper().delete(ankiCard.toJson()); - getAllTopicCards(); + getAllTopicCards(ankiCard.topicId); return value == 0 ? false : true; } } diff --git a/lib/tools/anki/pages/anki_home.dart b/lib/tools/anki/pages/anki_home.dart index e690ee8..ab59604 100644 --- a/lib/tools/anki/pages/anki_home.dart +++ b/lib/tools/anki/pages/anki_home.dart @@ -12,6 +12,8 @@ class AnkiHomePage extends StatelessWidget { Widget build(BuildContext context) { // topic controller final TopicController topicController = Get.put(TopicController()); + // putting ankicard controller + Get.put(AnkiCardController()); return Scaffold( resizeToAvoidBottomInset: false, diff --git a/lib/tools/anki/pages/create_ankicard.dart b/lib/tools/anki/pages/create_ankicard.dart index c613e62..39ecfd0 100644 --- a/lib/tools/anki/pages/create_ankicard.dart +++ b/lib/tools/anki/pages/create_ankicard.dart @@ -4,7 +4,12 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; class CreateAnkicard extends StatelessWidget { - const CreateAnkicard({super.key}); + const CreateAnkicard({ + super.key, + required this.topicId, + }); + + final int topicId; @override Widget build(BuildContext context) { @@ -59,7 +64,7 @@ class CreateAnkicard extends StatelessWidget { ), ), Obx( - () => ansCardController.ansSwitch.value + () => !ansCardController.ansSwitch.value // TextField for Showing Highlighted Answer ? Padding( padding: const EdgeInsets.all(8.0), @@ -104,7 +109,7 @@ class CreateAnkicard extends StatelessWidget { }, child: Obx( () => Text( - "Switch To ${ansCardController.ansSwitch.value ? "Writing" : "Highlight"}", + "Switch To ${!ansCardController.ansSwitch.value ? "Writing" : "Highlight"}", ), ), ), @@ -123,9 +128,9 @@ class CreateAnkicard extends StatelessWidget { ); } // user chose to write the answer - else if (!ansCardController.ansSwitch.value) { + else if (ansCardController.ansSwitch.value) { AnkiCard ankiCard = AnkiCard( - topicId: ankiCardController.topicId, + topicId: topicId, question: cardInfo.text.trim(), answer: cardAns.text.trim()); await ankiCardController.addAnkiCard(ankiCard); @@ -134,7 +139,7 @@ class CreateAnkicard extends StatelessWidget { cardAns.clear(); ansCardController.ansCard.value = ""; // reload the anki cards - await ankiCardController.getAllTopicCards(); + await ankiCardController.getAllTopicCards(topicId); // ignore: use_build_context_synchronously ScaffoldMessenger.of(context).showSnackBar( const SnackBar( @@ -147,7 +152,7 @@ class CreateAnkicard extends StatelessWidget { String question = cardInfo.text.trim(); question = question.replaceAll(cardAns.text.trim(), "_"); AnkiCard ankiCard = AnkiCard( - topicId: ankiCardController.topicId, + topicId: topicId, question: question, answer: cardAns.text.trim()); await ankiCardController.addAnkiCard(ankiCard); @@ -156,7 +161,7 @@ class CreateAnkicard extends StatelessWidget { cardAns.clear(); ansCardController.ansCard.value = ""; // reload the anki cards - await ankiCardController.getAllTopicCards(); + await ankiCardController.getAllTopicCards(topicId); // ignore: use_build_context_synchronously ScaffoldMessenger.of(context).showSnackBar( diff --git a/lib/tools/anki/pages/edit_anki_card.dart b/lib/tools/anki/pages/edit_anki_card.dart index e573813..89ad3e5 100644 --- a/lib/tools/anki/pages/edit_anki_card.dart +++ b/lib/tools/anki/pages/edit_anki_card.dart @@ -194,7 +194,8 @@ class _EditAnkiCardState extends State { onPressed: () async { // updating anki card await ankiCardController.updateAnkiCard(widget.ankiCard); - await ankiCardController.getAllTopicCards(); + await ankiCardController + .getAllTopicCards(widget.ankiCard.topicId); if (!mounted) return; // ignore: use_build_context_synchronously ScaffoldMessenger.of(context).showSnackBar( diff --git a/lib/tools/anki/pages/flashcards.dart b/lib/tools/anki/pages/flashcards.dart index 5d32d5b..48050d9 100644 --- a/lib/tools/anki/pages/flashcards.dart +++ b/lib/tools/anki/pages/flashcards.dart @@ -16,12 +16,9 @@ class TopicFlashCards extends StatelessWidget { @override Widget build(BuildContext context) { - // adding AnkiCardController - AnkiCardController ankiCardController = Get.put( - AnkiCardController( - topicId: topicId, - ), - ); + // finding AnkiCardController + AnkiCardController ankiCardController = Get.find(); + return Scaffold( resizeToAvoidBottomInset: false, appBar: AppBar( @@ -39,7 +36,9 @@ class TopicFlashCards extends StatelessWidget { Navigator.push( context, MaterialPageRoute( - builder: (context) => const CreateAnkicard(), + builder: (context) => CreateAnkicard( + topicId: topicId, + ), ), ); }, diff --git a/lib/tools/anki/pages/populated_anki_home_screen.dart b/lib/tools/anki/pages/populated_anki_home_screen.dart index ea52233..1087e57 100644 --- a/lib/tools/anki/pages/populated_anki_home_screen.dart +++ b/lib/tools/anki/pages/populated_anki_home_screen.dart @@ -30,10 +30,9 @@ class PopulatedAnkiHomeScreen extends StatelessWidget { scrollDirection: Axis.horizontal, itemBuilder: (context, idx) { return StarredTopics( - idx: topicController.allFavourites[idx].id!, + topicId: topicController.allFavourites[idx].id!, topic: topicController.allFavourites[idx].name, desc: topicController.allFavourites[idx].desc, - topicController: topicController, ); }, itemCount: topicController.allFavourites.length, @@ -60,7 +59,6 @@ class PopulatedAnkiHomeScreen extends StatelessWidget { topic: topicController.allTopics[idx].name, topicDesc: topicController.allTopics[idx].desc, isFavourite: topicController.allTopics[idx].isFavourite, - // controller: topicController, ); }, itemCount: topicController.allTopics.length, diff --git a/lib/tools/anki/widgets/grid_topics.dart b/lib/tools/anki/widgets/grid_topics.dart index feee50c..f2bff40 100644 --- a/lib/tools/anki/widgets/grid_topics.dart +++ b/lib/tools/anki/widgets/grid_topics.dart @@ -24,16 +24,23 @@ class GridViewTopic extends StatelessWidget { Widget build(BuildContext context) { var colorDet = idx % 4; final TopicController controller = Get.find(); + final AnkiCardController ankiCardController = + Get.find(); return GestureDetector( - onTap: () => Navigator.push( - context, - MaterialPageRoute( - builder: (builder) => TopicFlashCards( - topicId: idx, + onTap: () async { + // getting all topic cards before opening flashcard page + await ankiCardController.getAllTopicCards(topicId); + Navigator.push( + // ignore: use_build_context_synchronously + context, + MaterialPageRoute( + builder: (builder) => TopicFlashCards( + topicId: topicId, + ), ), - ), - ), + ); + }, child: Container( decoration: BoxDecoration( color: colorDet == 0 diff --git a/lib/tools/anki/widgets/starred_topic.dart b/lib/tools/anki/widgets/starred_topic.dart index 10188d1..5a848b5 100644 --- a/lib/tools/anki/widgets/starred_topic.dart +++ b/lib/tools/anki/widgets/starred_topic.dart @@ -2,32 +2,31 @@ import 'package:academia/exports/barrel.dart'; import 'package:academia/tools/anki/controllers/controllers.dart'; import 'package:academia/tools/anki/pages/flashcards.dart'; import 'package:academia/tools/anki/widgets/widgets.dart'; +import 'package:get/get.dart'; import '../models/models.dart'; -// TODO: Make this widget just require a topic instance and maybe index -// TODO: Find the controller don't pass it! class StarredTopics extends StatelessWidget { const StarredTopics({ super.key, - required this.idx, + required this.topicId, required this.topic, required this.desc, - this.topicController, }); - final int idx; + final int topicId; final String topic; final String desc; - final TopicController? topicController; @override Widget build(BuildContext context) { + TopicController topicController = Get.find(); + return GestureDetector( onTap: () => Navigator.push( context, MaterialPageRoute( builder: (builder) => TopicFlashCards( - topicId: idx, + topicId: topicId, ), ), ), @@ -104,15 +103,15 @@ class StarredTopics extends StatelessWidget { IconButton( onPressed: () async { AnkiTopic topic = AnkiTopic( - id: idx, + id: topicId, name: this.topic, desc: desc, isFavourite: true, ); - await topicController?.favouriteTopic(topic); + await topicController.favouriteTopic(topic); // update favourites and all topics - await topicController?.getAllFavourites(); - await topicController?.getAllTopics(); + await topicController.getAllFavourites(); + await topicController.getAllTopics(); }, icon: const Icon(Ionicons.star), ), @@ -128,18 +127,18 @@ class StarredTopics extends StatelessWidget { OutlinedButton( onPressed: () async { AnkiTopic topic = AnkiTopic( - id: idx, + id: topicId, name: this.topic, desc: desc, ); bool? deleted = - await topicController?.deleteTopic(topic); + await topicController.deleteTopic(topic); HapticFeedback.heavyImpact().then((val) { if (!context.mounted) return; ScaffoldMessenger.of(context).showSnackBar( SnackBar( - content: (deleted != null && deleted) + content: (deleted) ? const Text( "Topic Successfully Deleted") : const Text( @@ -148,8 +147,8 @@ class StarredTopics extends StatelessWidget { ); }); // update favourites and all topics - await topicController?.getAllFavourites(); - await topicController?.getAllTopics(); + await topicController.getAllFavourites(); + await topicController.getAllTopics(); // ignore: use_build_context_synchronously Navigator.of(context).pop(); }, diff --git a/lib/tools/anki/widgets/topic_flashcard.dart b/lib/tools/anki/widgets/topic_flashcard.dart index e17f0b5..0857889 100644 --- a/lib/tools/anki/widgets/topic_flashcard.dart +++ b/lib/tools/anki/widgets/topic_flashcard.dart @@ -51,7 +51,7 @@ class FlashCardTile extends StatelessWidget { ), ); // update favourites and all topics - await ankiCardController.getAllTopicCards(); + await ankiCardController.getAllTopicCards(ankiCard.topicId); // ignore: use_build_context_synchronously Navigator.of(context).pop(); }, From 4b7c2501753fa096eaa346439433e59e9fbb4ed9 Mon Sep 17 00:00:00 2001 From: FIRST_NAME LAST_NAME Date: Fri, 4 Oct 2024 11:56:06 +0300 Subject: [PATCH 4/5] chore: UI enhancements --- lib/tools/anki/pages/anki_swap.dart | 14 ++-- .../pages/populated_anki_home_screen.dart | 3 +- lib/tools/anki/widgets/eclipses.dart | 71 +++++++++---------- 3 files changed, 45 insertions(+), 43 deletions(-) diff --git a/lib/tools/anki/pages/anki_swap.dart b/lib/tools/anki/pages/anki_swap.dart index ddb6361..d5b5692 100644 --- a/lib/tools/anki/pages/anki_swap.dart +++ b/lib/tools/anki/pages/anki_swap.dart @@ -75,12 +75,18 @@ class _AnkiSwapState extends State { height: MediaQuery.of(context).size.height * 0.45, decoration: BoxDecoration( color: colorDet == 0 - ? const Color(0xff8999aa) + ? Theme.of(context).colorScheme.primaryContainer : colorDet == 1 - ? const Color(0xffffcdfe) + ? Theme.of(context) + .colorScheme + .secondaryContainer : colorDet == 2 - ? const Color(0xffffe7cd) - : const Color(0xffcdffce), + ? Theme.of(context) + .colorScheme + .tertiaryContainer + : Theme.of(context) + .colorScheme + .errorContainer, borderRadius: const BorderRadius.all( Radius.circular(12), ), diff --git a/lib/tools/anki/pages/populated_anki_home_screen.dart b/lib/tools/anki/pages/populated_anki_home_screen.dart index 1087e57..4601b9d 100644 --- a/lib/tools/anki/pages/populated_anki_home_screen.dart +++ b/lib/tools/anki/pages/populated_anki_home_screen.dart @@ -43,7 +43,8 @@ class PopulatedAnkiHomeScreen extends StatelessWidget { ), // displays topicics Container( - height: MediaQuery.of(context).size.height * 0.6, + height: MediaQuery.of(context).size.height * + (topicController.allFavourites.isNotEmpty ? 0.6 : 1), padding: const EdgeInsets.all(12), child: Obx( () => GridView.builder( diff --git a/lib/tools/anki/widgets/eclipses.dart b/lib/tools/anki/widgets/eclipses.dart index 0cc6504..ac86929 100644 --- a/lib/tools/anki/widgets/eclipses.dart +++ b/lib/tools/anki/widgets/eclipses.dart @@ -12,41 +12,6 @@ Widget blackcircle = Padding( ), ); -Widget bluecircle = Padding( - padding: const EdgeInsets.all(1.0), - child: Container( - width: 15, - height: 15, - decoration: const BoxDecoration( - shape: BoxShape.circle, - ), - ), -); - -Widget redcircle = Padding( - padding: const EdgeInsets.all(1.0), - child: Container( - width: 15, - height: 15, - decoration: const BoxDecoration( - shape: BoxShape.circle, - color: Color(0xffffcde5), - ), - ), -); - -Widget greencircle = Padding( - padding: const EdgeInsets.all(1.0), - child: Container( - width: 15, - height: 15, - decoration: const BoxDecoration( - shape: BoxShape.circle, - color: Color(0xffe5ffcd), - ), - ), -); - class CustomEclipse extends StatelessWidget { const CustomEclipse({super.key}); @@ -76,9 +41,39 @@ class CustomMixEclipse extends StatelessWidget { height: MediaQuery.of(context).size.height * 0.05, child: Row( children: [ - bluecircle, - redcircle, - greencircle, + Padding( + padding: const EdgeInsets.all(1.0), + child: Container( + width: 15, + height: 15, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Theme.of(context).colorScheme.secondaryContainer, + ), + ), + ), + Padding( + padding: const EdgeInsets.all(1.0), + child: Container( + width: 15, + height: 15, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Theme.of(context).colorScheme.tertiaryContainer, + ), + ), + ), + Padding( + padding: const EdgeInsets.all(1.0), + child: Container( + width: 15, + height: 15, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Theme.of(context).colorScheme.primaryContainer, + ), + ), + ), ], ), ); From 606ecc937a39f8d806df32c05f7d8780df64f1e2 Mon Sep 17 00:00:00 2001 From: FIRST_NAME LAST_NAME Date: Fri, 4 Oct 2024 12:23:08 +0300 Subject: [PATCH 5/5] feat: added all help dialogs to all necessary pages --- lib/tools/anki/pages/anki_home.dart | 13 ++++++ lib/tools/anki/pages/create_ankicard.dart | 45 ++++++++++++++------- lib/tools/anki/pages/create_topic_form.dart | 2 +- lib/tools/anki/pages/flashcards.dart | 13 ++++++ 4 files changed, 57 insertions(+), 16 deletions(-) diff --git a/lib/tools/anki/pages/anki_home.dart b/lib/tools/anki/pages/anki_home.dart index ab59604..37254f4 100644 --- a/lib/tools/anki/pages/anki_home.dart +++ b/lib/tools/anki/pages/anki_home.dart @@ -28,6 +28,19 @@ class AnkiHomePage extends StatelessWidget { flexibleSpace: const FlexibleSpaceBar( title: Text("Anki"), ), + actions: [ + IconButton( + onPressed: () { + Get.defaultDialog( + title: "Academia Help", + content: const Text( + "Mark a topic as your favorite for easy access by tapping the star icon.\nTap on the cards to view their corresponding Anki cards.", + ), + ); + }, + icon: const Icon(Ionicons.help), + ), + ], ), SliverFillRemaining( child: Obx( diff --git a/lib/tools/anki/pages/create_ankicard.dart b/lib/tools/anki/pages/create_ankicard.dart index 39ecfd0..d6a3a56 100644 --- a/lib/tools/anki/pages/create_ankicard.dart +++ b/lib/tools/anki/pages/create_ankicard.dart @@ -1,6 +1,6 @@ +import 'package:academia/exports/barrel.dart'; import 'package:academia/tools/anki/controllers/controllers.dart'; import 'package:academia/tools/anki/models/models.dart'; -import 'package:flutter/material.dart'; import 'package:get/get.dart'; class CreateAnkicard extends StatelessWidget { @@ -20,29 +20,44 @@ class CreateAnkicard extends StatelessWidget { return Scaffold( appBar: AppBar( - automaticallyImplyLeading: true, title: const Text("Create Card"), - centerTitle: true, + actions: [ + IconButton( + onPressed: () { + Get.defaultDialog( + title: "Academia Help", + content: const Text( + "To create an Anki card, you can either type a question and its answer, then tap \"Create Card\" to save it, or type a statement, highlight the portion you want to hide, tap outside the text box to preview the hidden answer, and then tap \"Create Card\" to save. Both options let you quickly generate flashcards for efficient studying.", + ), + ); + }, + icon: const Icon(Ionicons.help), + ), + ], ), body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.all(8.0), - child: TextField( - controller: cardInfo, - maxLines: 5, - decoration: InputDecoration( - hintText: "Some question you want to remember", - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(12), + child: Obx( + () => TextField( + controller: cardInfo, + maxLines: 5, + decoration: InputDecoration( + hintText: ansCardController.ansSwitch.value + ? "Some question you want to remember" + : "A stetement to highlight a section that you want to remember", + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + ), ), + onTapOutside: (event) { + ansCardController.ansCard.value = + cardInfo.selection.textInside(cardInfo.text); + cardAns.text = ansCardController.ansCard.value; + }, ), - onTapOutside: (event) { - ansCardController.ansCard.value = - cardInfo.selection.textInside(cardInfo.text); - cardAns.text = ansCardController.ansCard.value; - }, ), ), Obx( diff --git a/lib/tools/anki/pages/create_topic_form.dart b/lib/tools/anki/pages/create_topic_form.dart index ab7bb6e..532066c 100644 --- a/lib/tools/anki/pages/create_topic_form.dart +++ b/lib/tools/anki/pages/create_topic_form.dart @@ -1,5 +1,5 @@ +import 'package:academia/exports/barrel.dart'; import 'package:academia/tools/anki/controllers/controllers.dart'; -import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../models/models.dart'; diff --git a/lib/tools/anki/pages/flashcards.dart b/lib/tools/anki/pages/flashcards.dart index 48050d9..e551216 100644 --- a/lib/tools/anki/pages/flashcards.dart +++ b/lib/tools/anki/pages/flashcards.dart @@ -23,6 +23,19 @@ class TopicFlashCards extends StatelessWidget { resizeToAvoidBottomInset: false, appBar: AppBar( title: const Text("Topic flash cards"), + actions: [ + IconButton( + onPressed: () { + Get.defaultDialog( + title: "Academia Help", + content: const Text( + "Double Tap On AnkiCard To Delete\nTap On AnkiCard To Preview", + ), + ); + }, + icon: const Icon(Ionicons.help), + ), + ], ), floatingActionButton: SizedBox( height: MediaQuery.of(context).size.height * 0.18,