Skip to content

Commit

Permalink
Merge pull request #60 from OpenPecha/develop
Browse files Browse the repository at this point in the history
updated events
  • Loading branch information
CodingWithTashi authored Nov 30, 2024
2 parents e7bfe4b + 5de68e9 commit f97d231
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 58 deletions.
Binary file modified assets/db/gonpa.db
Binary file not shown.
70 changes: 37 additions & 33 deletions lib/models/festival_model.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class Festival {
final int id;
final int uid;
final String? tbTitle;
final String? enTitle;
final String? eventTbName;
final String? eventEnName;
final DateTime? startDate;
final DateTime? endDate;
final String? tbContent;
final String? enContent;
final String categories;
final String? tbDescription;
final String? enDescription;
final String? categories;
final String? location;
final String pic;
final String status;
Expand All @@ -18,13 +18,13 @@ class Festival {
Festival({
required this.id,
required this.uid,
this.tbTitle,
this.enTitle,
this.eventTbName,
this.eventEnName,
this.startDate,
this.endDate,
this.tbContent,
this.enContent,
required this.categories,
this.tbDescription,
this.enDescription,
this.categories,
this.location,
required this.pic,
required this.status,
Expand All @@ -37,13 +37,17 @@ class Festival {
return Festival(
id: map['id'] as int,
uid: map['uid'] as int,
tbTitle: map['tbtitle'] as String?,
enTitle: map['entitle'] as String?,
startDate: DateTime.parse(map['start_date'] as String),
endDate: DateTime.parse(map['end_date'] as String),
tbContent: map['tbcontent'] as String?,
enContent: map['encontent'] as String?,
categories: map['categories'] as String,
eventTbName: map['event_tbname'] as String?,
eventEnName: map['event_enname'] as String?,
startDate: map['start_date'] != null
? DateTime.parse(map['start_date'] as String)
: null,
endDate: map['end_date'] != null
? DateTime.parse(map['end_date'] as String)
: null,
tbDescription: map['tb_description'] as String?,
enDescription: map['en_description'] as String?,
categories: map['categories'] as String?,
location: map['location'] as String?,
pic: map['pic'] as String,
status: map['status'] as String,
Expand All @@ -57,31 +61,31 @@ class Festival {
return {
'id': id,
'uid': uid,
'tbtitle': tbTitle,
'entitle': enTitle,
'start_date': startDate.toString(),
'end_date': endDate.toString(),
'tbcontent': tbContent,
'encontent': enContent,
'event_tbname': eventTbName,
'event_enname': eventEnName,
'start_date': startDate?.toIso8601String(),
'end_date': endDate?.toIso8601String(),
'tb_description': tbDescription,
'en_description': enDescription,
'categories': categories,
'location': location,
'pic': pic,
'status': status,
'slug': slug,
'created': created.toString(),
'updated': updated.toString(),
'created': created.toIso8601String(),
'updated': updated.toIso8601String(),
};
}

Festival copyWith({
int? id,
int? uid,
String? tbTitle,
String? enTitle,
String? eventTbName,
String? eventEnName,
DateTime? startDate,
DateTime? endDate,
String? tbContent,
String? enContent,
String? tbDescription,
String? enDescription,
String? categories,
String? location,
String? pic,
Expand All @@ -93,12 +97,12 @@ class Festival {
return Festival(
id: id ?? this.id,
uid: uid ?? this.uid,
tbTitle: tbTitle ?? this.tbTitle,
enTitle: enTitle ?? this.enTitle,
eventTbName: eventTbName ?? this.eventTbName,
eventEnName: eventEnName ?? this.eventEnName,
startDate: startDate ?? this.startDate,
endDate: endDate ?? this.endDate,
tbContent: tbContent ?? this.tbContent,
enContent: enContent ?? this.enContent,
tbDescription: tbDescription ?? this.tbDescription,
enDescription: enDescription ?? this.enDescription,
categories: categories ?? this.categories,
location: location ?? this.location,
pic: pic ?? this.pic,
Expand Down
8 changes: 4 additions & 4 deletions lib/repo/database_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ class SearchRepository {
final festivalQuery = '''
SELECT *,
CASE
WHEN LOWER(enTitle) LIKE LOWER('%$escapedQuery%') THEN 1
WHEN LOWER(enContent) LIKE LOWER('%$escapedQuery%') THEN 2
WHEN LOWER(event_tbname) LIKE LOWER('%$escapedQuery%') THEN 1
WHEN LOWER(event_enname) LIKE LOWER('%$escapedQuery%') THEN 2
ELSE 3
END as match_score
FROM events
WHERE LOWER(enTitle) LIKE LOWER('%$escapedQuery%')
OR LOWER(enContent) LIKE LOWER('%$escapedQuery%')
WHERE LOWER(event_tbname) LIKE LOWER('%$escapedQuery%')
OR LOWER(event_enname) LIKE LOWER('%$escapedQuery%')
''';

final db = await dbHelper.database;
Expand Down
12 changes: 6 additions & 6 deletions lib/ui/screen/festival_detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class FestivalDetailScreen extends ConsumerWidget {
return Scaffold(
appBar: GonpaAppBar(
title: context.localizedText(
enText: selectedFestival.enTitle!,
boText: selectedFestival.tbTitle!,
enText: selectedFestival.eventEnName!,
boText: selectedFestival.eventTbName!,
)),
body: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
Expand All @@ -40,8 +40,8 @@ class FestivalDetailScreen extends ConsumerWidget {
Center(
child: Text(
context.localizedText(
enText: selectedFestival.enTitle!,
boText: selectedFestival.tbTitle!,
enText: selectedFestival.eventEnName!,
boText: selectedFestival.eventTbName!,
),
style: const TextStyle(
fontSize: 24,
Expand All @@ -62,8 +62,8 @@ class FestivalDetailScreen extends ConsumerWidget {
const SizedBox(height: 16),
Text(
context.localizedText(
enText: selectedFestival.enContent!,
boText: selectedFestival.tbContent!,
enText: selectedFestival.enDescription!,
boText: selectedFestival.tbDescription!,
),
style: TextStyle(
fontSize: 16, height: context.getLocalizedHeight()),
Expand Down
8 changes: 4 additions & 4 deletions lib/ui/widget/festival_card_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class FestivalCardItem extends ConsumerWidget {
children: [
Text(
context.localizedText(
enText: festival.enTitle!,
boText: festival.tbTitle!,
enText: festival.eventEnName!,
boText: festival.eventTbName!,
),
style: const TextStyle(
fontSize: 18,
Expand All @@ -60,8 +60,8 @@ class FestivalCardItem extends ConsumerWidget {
Expanded(
child: Text(
context.localizedText(
enText: festival.enContent!,
boText: festival.tbContent!,
enText: festival.enDescription!,
boText: festival.tbDescription!,
maxLength: kDescriptionMaxLength,
),
style: const TextStyle(fontSize: 16),
Expand Down
27 changes: 17 additions & 10 deletions lib/ui/widget/search_card_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:go_router/go_router.dart';
import 'package:gompa_tour/helper/localization_helper.dart';
import 'package:gompa_tour/models/festival_model.dart';

import '../../config/constant.dart';
import '../../models/deity_model.dart';
import '../../models/organization_model.dart';
import '../../states/deties_state.dart';
Expand Down Expand Up @@ -55,9 +56,12 @@ class SearchCardItem extends ConsumerWidget {
children: [
Text(
context.localizedText(
enText: searchableItem.enTitle,
boText: searchableItem.tbTitle,
),
enText: searchableItem is Festival
? searchableItem.eventEnName
: searchableItem.enTitle,
boText: searchableItem is Festival
? searchableItem.eventTbName
: searchableItem.tbTitle),
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
Expand All @@ -81,12 +85,15 @@ class SearchCardItem extends ConsumerWidget {
const SizedBox(width: 16),
Expanded(
child: Text(
context
.localizedText(
enText: searchableItem.enContent,
boText: searchableItem.tbContent,
)
.substring(0, 50),
context.localizedText(
enText: searchableItem is Festival
? searchableItem.eventEnName
: searchableItem.enContent,
boText: searchableItem is Festival
? searchableItem.eventTbName
: searchableItem.tbContent,
maxLength: kDescriptionMaxLength,
),
style: const TextStyle(fontSize: 16),
),
),
Expand All @@ -108,7 +115,7 @@ class SearchCardItem extends ConsumerWidget {
child: Text(
_getTitle(searchableItem, context),
style: TextStyle(
color: Theme.of(context).colorScheme.onPrimary,
color: Colors.white,
),
),
)
Expand Down
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: 1.0.6+7
version: 1.0.7+8

environment:
sdk: ^3.5.3
Expand Down

0 comments on commit f97d231

Please sign in to comment.