Skip to content

Commit

Permalink
change project name. Revamp favourites list
Browse files Browse the repository at this point in the history
  • Loading branch information
ya27hw committed May 12, 2024
1 parent f797d8d commit e45c06b
Show file tree
Hide file tree
Showing 35 changed files with 238 additions and 1,173 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ app.*.map.json
/android/app/profile
/android/app/release
pubspec.lock
/android/app/keystore.jks
10 changes: 5 additions & 5 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ android {
}
signingConfigs {
release {
// keyAlias keystoreProperties['keyAlias']
// keyPassword keystoreProperties['keyPassword']
// storeFile = file('keystore.jks')
// storePassword keystoreProperties['storePassword']
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile = file('keystore.jks')
storePassword keystoreProperties['storePassword']
}
}

buildTypes {
release {
signingConfig null
signingConfig signingConfigs.release
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.emushaf;
PRODUCT_BUNDLE_IDENTIFIER = com.example.eQuran;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand All @@ -384,7 +384,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.emushaf.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.example.eQuran.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -401,7 +401,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.emushaf.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.example.eQuran.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
Expand All @@ -416,7 +416,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.emushaf.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.example.eQuran.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
Expand Down Expand Up @@ -547,7 +547,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.emushaf;
PRODUCT_BUNDLE_IDENTIFIER = com.example.eQuran;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -569,7 +569,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.emushaf;
PRODUCT_BUNDLE_IDENTIFIER = com.example.eQuran;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down
4 changes: 2 additions & 2 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Emushaf</string>
<string>eQuran</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>emushaf</string>
<string>eQuran</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
Expand Down
2 changes: 1 addition & 1 deletion lib/backend/bookmark_db.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:collection/collection.dart' show minBy;
import 'package:emushaf/backend/reading_model.dart';
import 'package:eQuran/backend/reading_model.dart';

import 'base_db.dart';

Expand Down
2 changes: 1 addition & 1 deletion lib/backend/favourites_db.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:emushaf/backend/base_db.dart';
import 'package:eQuran/backend/base_db.dart';

class FavouritesDB extends BaseDB {
FavouritesDB._privateConstructor() : super("favourites");
Expand Down
2 changes: 1 addition & 1 deletion lib/backend/surah_db.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:emushaf/backend/base_db.dart';
import 'package:eQuran/backend/base_db.dart';

class SurahDB extends BaseDB {
SurahDB._privateConstructor() : super("surahs");
Expand Down
6 changes: 3 additions & 3 deletions lib/home/home.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:emushaf/home/main_page.dart';
import 'package:emushaf/home/settings.dart';
import 'package:eQuran/home/main_page.dart';
import 'package:eQuran/home/settings.dart';
import 'package:flutter/material.dart';

class Destinations {
Expand Down Expand Up @@ -86,4 +86,4 @@ class _HomePageState extends State<HomePage> {
_selectedIndex = index;
});
}
}
}
6 changes: 3 additions & 3 deletions lib/home/main_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:emushaf/backend/library.dart';
import 'package:emushaf/utils/debouncer.dart';
import 'package:emushaf/widgets/library.dart';
import 'package:eQuran/backend/library.dart';
import 'package:eQuran/utils/debouncer.dart';
import 'package:eQuran/widgets/library.dart';
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';

Expand Down
6 changes: 3 additions & 3 deletions lib/home/read.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:emushaf/backend/bookmark_db.dart';
import 'package:emushaf/backend/library.dart' show SettingsDB;
import 'package:emushaf/widgets/library.dart' show ReadQuranCard;
import 'package:eQuran/backend/bookmark_db.dart';
import 'package:eQuran/backend/library.dart' show SettingsDB;
import 'package:eQuran/widgets/library.dart' show ReadQuranCard;
import 'package:flutter/material.dart';
import 'package:numberpicker/numberpicker.dart';
import 'package:percent_indicator/linear_percent_indicator.dart';
Expand Down
4 changes: 2 additions & 2 deletions lib/home/settings.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:emushaf/backend/library.dart'
import 'package:eQuran/backend/library.dart'
show BookmarkDB, FavouritesDB, SettingsDB;
import 'package:emushaf/widgets/library.dart'
import 'package:eQuran/widgets/library.dart'
show FontSlider, PlayBackSlider, SettingsSwitch;
import 'package:flutter/material.dart';
import 'package:quran/quran.dart' show Translation;
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:emushaf/home/library.dart' show HomePage;
import 'package:eQuran/home/library.dart' show HomePage;
import 'package:flutter/material.dart';
import 'package:hive_flutter/hive_flutter.dart';

Expand Down
198 changes: 156 additions & 42 deletions lib/widgets/favourites_list.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import 'package:emushaf/backend/favourites_db.dart';
import 'package:emushaf/home/read.dart';
import 'package:eQuran/backend/library.dart';
import 'package:eQuran/home/library.dart';
import 'package:expansion_tile_group/expansion_tile_group.dart';
import 'package:flutter/material.dart';
import 'package:quran/quran.dart' as quran;

class Item {
Item(
{required this.panelTitle,
required this.children,
this.isExpanded = false});

String panelTitle;
List<String> children;
bool isExpanded = false;
}

class FavouritesList extends StatefulWidget {
const FavouritesList({super.key});

Expand All @@ -11,50 +23,152 @@ class FavouritesList extends StatefulWidget {
}

class _FavouritesListState extends State<FavouritesList> {
TextEditingController _controller = TextEditingController();

@override
void dispose() {
_controller.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
List<dynamic> allKeys = FavouritesDB().getKeys().toList();

return ListView.builder(
itemCount: allKeys.length,
itemBuilder: (BuildContext context, int index) {
final String key = allKeys[index];
dynamic value = FavouritesDB().get(key);
if (value is bool) {
value = "";
}

final List<String> surahAndVerse = key.split("-");
final surah = int.parse(surahAndVerse.first);
final verse = int.parse(surahAndVerse.last);

return Card(
elevation: 3,
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
child: InkWell(
final List<Item> _data = generateItems();

return Wrap(direction: Axis.horizontal, children: [
ExpansionTileGroup(
spaceBetweenItem: 4,
toggleType: ToggleType.expandOnlyCurrent,
children: _data.asMap().entries.map((e) {
final item = e.value;
final surah = int.parse(item.panelTitle);

return ExpansionTileWithoutBorderItem(
title: Text(quran.getSurahName(surah)),
children: item.children.asMap().entries.map((ee) {
final key = "${item.panelTitle}-${ee.value}";
final verse = int.parse(ee.value);
final String subtitle =
FavouritesDB().get(key, defaultValue: "");
return Card(
elevation: 2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20)),
child: InkWell(
borderRadius: BorderRadius.circular(20),
onTap: () async {
await Future.delayed(const Duration(milliseconds: 270));
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => ReadPage(
chapter: surah,
startVerse: verse,
)));
},
child: ListTile(
title: Text("Ayah $verse"),
trailing: IconButton(
icon: const Icon(Icons.more_vert_rounded),
onPressed: () {
_showBottomSheetWithOptions(
context, key, _controller);
},
),
subtitle: subtitle.isNotEmpty
? Text(
subtitle,
)
: null,
),
),
);
}).toList());
}).toList())
]);
}
}

List<Item> generateItems() {
List<dynamic> data = FavouritesDB().getKeys().toList();
Map<String, List<String>> favouritesMap = {};

for (var item in data) {
var parts = item.split('-');
favouritesMap.putIfAbsent(parts[0], () => []).add(parts[1]);
}

return favouritesMap.entries
.map((entry) => Item(panelTitle: entry.key, children: entry.value))
.toList();
}

void _showBottomSheetWithOptions(
BuildContext context, String key, TextEditingController _controller) {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
return Wrap(
children: <Widget>[
InkWell(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(30), topRight: Radius.circular(30)),
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => ReadPage(
chapter: surah,
startVerse: verse,
)));
_showEditNoteDialog(
context,
key,
FavouritesDB().get(key, defaultValue: ""),
_controller); // Close the bottom sheet
// Implement your edit logic here
},
borderRadius: BorderRadius.circular(30),
child: Padding(
padding: const EdgeInsets.all(4.0),
child: ListTile(
title: Text(quran.getSurahName(surah)),
subtitle: Text("Verse $verse $value"),
trailing: Text(
quran.getSurahNameArabic(surah),
style: Theme.of(context).textTheme.bodyLarge,
)),
child: const ListTile(
leading: Icon(Icons.edit),
title: Text('Edit'),
),
),
);
},
);
}
ListTile(
leading: const Icon(Icons.delete),
title: const Text('Delete'),
onTap: () {
Navigator.pop(context);
FavouritesDB().delete(key);
},
),
],
);
},
);
}

void _showEditNoteDialog(BuildContext context, String key, String initialNote,
TextEditingController _controller) {
_controller.text = initialNote;
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Edit Note'),
content: TextField(
controller: _controller,
maxLines: null, // Allows multiple lines
),
actions: [
TextButton(
child: Text('Cancel'),
onPressed: () {
Navigator.of(context).pop();
},
),
TextButton(
child: Text('OK'),
onPressed: () {
String editedNote = _controller.text;
// Save the edited note (e.g., update in a database)
FavouritesDB().put(key, editedNote);
Navigator.of(context).pop();
Navigator.of(context).pop();
},
),
],
);
},
);
}
4 changes: 2 additions & 2 deletions lib/widgets/font_slider.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:emushaf/backend/library.dart' show SettingsDB;
import 'package:emushaf/widgets/library.dart' show ReadQuranCard;
import 'package:eQuran/backend/library.dart' show SettingsDB;
import 'package:eQuran/widgets/library.dart' show ReadQuranCard;
import 'package:flutter/material.dart';
import 'package:quran/quran.dart' as quran;

Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/juz_card.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:emushaf/home/read.dart';
import 'package:eQuran/home/read.dart';
import 'package:flutter/material.dart';

class QuranJuzTile extends StatelessWidget {
Expand Down
Loading

0 comments on commit e45c06b

Please sign in to comment.