-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from ia-toki/issue-28-material-pdf
Issue 28- Material Menu (List) Page and pdfViewer Page
- Loading branch information
Showing
15 changed files
with
540 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class BebrasGroupCategory { | ||
final int index; | ||
final String bebrasChallengeKey; | ||
|
||
const BebrasGroupCategory(this.index, this.bebrasChallengeKey); | ||
} | ||
|
||
List<BebrasGroupCategory> bebrasGroupList = [ | ||
BebrasGroupCategory(0, 'sikecil'), | ||
BebrasGroupCategory(1, 'siaga'), | ||
BebrasGroupCategory(2, 'penggalang'), | ||
BebrasGroupCategory(3, 'penegak'), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
List<String> bebrasMaterialIds = [ | ||
"penegak_2016-buku_bebras", | ||
"penegak_2017-buku_bebras", | ||
"penegak_2018-buku_bebras", | ||
"penggalang_2016-buku_bebras", | ||
"penggalang_2017-buku_bebras", | ||
"penggalang_2018-buku_bebras", | ||
"siaga_2016-buku_bebras", | ||
"siaga_2017-buku_bebras", | ||
"siaga_2018-buku_bebras", | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
app/lib/features/material/menu/presentation/pages/_pages.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
import 'package:bebras_pandai/core/constants/BebrasGroupCategory.dart'; | ||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
import 'package:firebase_storage/firebase_storage.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
|
||
import '../../../../../core/bases/widgets/layout/bebras_scaffold.dart'; | ||
import '../../../../../core/constants/assets.dart'; | ||
|
||
part 'material_menu.dart'; |
210 changes: 210 additions & 0 deletions
210
app/lib/features/material/menu/presentation/pages/material_menu.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
part of '_pages.dart'; | ||
|
||
class MaterialMenu extends StatefulWidget { | ||
const MaterialMenu({super.key}); | ||
|
||
@override | ||
State<MaterialMenu> createState() => _MaterialMenuState(); | ||
} | ||
|
||
class _MaterialMenuState extends State<MaterialMenu> { | ||
final Stream<QuerySnapshot> materialsStream = | ||
FirebaseFirestore.instance.collection('learning_material').snapshots(); | ||
|
||
String? selectedValue = null; | ||
|
||
int filterIndex = 0; | ||
|
||
Widget CustomRadioButton(String text, int index) { | ||
return InkWell( | ||
onTap: () { | ||
setState(() { | ||
filterIndex = index; | ||
}); | ||
}, | ||
child: Container( | ||
alignment: Alignment.center, | ||
height: 40, | ||
width: 130, | ||
decoration: BoxDecoration( | ||
border: Border.all(), | ||
color: (filterIndex == index) ? Colors.black54 : Colors.white, | ||
boxShadow: [ | ||
BoxShadow( | ||
color: (filterIndex == index) ? Colors.white : Colors.black, | ||
blurRadius: 2.0, | ||
spreadRadius: 0.0, | ||
offset: (filterIndex == index) | ||
? Offset(0, 0) | ||
: Offset(2.0, 2.0), // shadow direction: bottom right | ||
) | ||
], | ||
), | ||
child: Text( | ||
text, | ||
style: TextStyle( | ||
fontSize: 16, | ||
fontWeight: FontWeight.w400, | ||
color: (filterIndex == index) ? Colors.white : Colors.black), | ||
), | ||
), | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return BebrasScaffold( | ||
avoidBottomInset: false, | ||
body: Padding( | ||
padding: const EdgeInsets.only(top: 10.0), | ||
child: Stack( | ||
children: [ | ||
Container( | ||
padding: const EdgeInsets.all(32), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
children: [ | ||
Image.asset( | ||
Assets.bebrasPandaiText, | ||
), | ||
const SizedBox( | ||
height: 30, | ||
), | ||
Container( | ||
height: 40, | ||
width: 296, // double.infinity, | ||
decoration: BoxDecoration(border: Border.all()), | ||
child: ListView( | ||
scrollDirection: Axis.horizontal, | ||
children: <Widget>[ | ||
CustomRadioButton( | ||
"siKecil", bebrasGroupList[0].index), | ||
CustomRadioButton("Siaga", bebrasGroupList[1].index), | ||
CustomRadioButton( | ||
"Penggalang", bebrasGroupList[2].index), | ||
CustomRadioButton( | ||
"Penegak", bebrasGroupList[3].index), | ||
]), | ||
), | ||
// Container( | ||
// height: 70, | ||
// width: 296, // double.infinity, | ||
// decoration: BoxDecoration(border: Border.all()), | ||
// child: Column( | ||
// children: [ | ||
// Row( | ||
// children: [ | ||
// CustomRadioButton( | ||
// "siKecil", bebrasGroupList[0].index), | ||
// CustomRadioButton( | ||
// "Siaga", bebrasGroupList[1].index), | ||
// ], | ||
// ), | ||
// Row( | ||
// children: [ | ||
// CustomRadioButton( | ||
// "Penggalang", bebrasGroupList[2].index), | ||
// CustomRadioButton( | ||
// "Penegak", bebrasGroupList[3].index), | ||
// ], | ||
// ), | ||
// ], | ||
// ), | ||
// ), | ||
const SizedBox( | ||
height: 10, | ||
), | ||
Container( | ||
width: double.infinity, | ||
child: const Text('Daftar Materi')), | ||
const SizedBox( | ||
height: 10, | ||
), | ||
StreamBuilder<QuerySnapshot>( | ||
stream: materialsStream, | ||
builder: (BuildContext context, | ||
AsyncSnapshot<QuerySnapshot> snapshot) { | ||
if (snapshot.hasError) { | ||
return Text('Something went wrong'); | ||
} | ||
|
||
if (snapshot.connectionState == | ||
ConnectionState.waiting) { | ||
return Text("Loading"); | ||
} | ||
|
||
return Container( | ||
height: 360, | ||
decoration: BoxDecoration(border: Border.all()), | ||
child: ListView( | ||
children: snapshot.data!.docs | ||
.map((DocumentSnapshot document) { | ||
Map<String, dynamic> materialDoc = | ||
document.data()! as Map<String, dynamic>; | ||
if (materialDoc['challenge_group'] == | ||
bebrasGroupList[filterIndex] | ||
.bebrasChallengeKey) { | ||
return InkWell( | ||
onTap: () { | ||
context.push(Uri( | ||
path: '/material/${document.id}', | ||
queryParameters: { | ||
'id': document.id, | ||
'title': materialDoc['title'], | ||
'description': | ||
materialDoc['description'], | ||
'pdfUrl': materialDoc['gsReference'], | ||
}).toString()); | ||
}, | ||
child: Container( | ||
height: 80, | ||
width: double.infinity, | ||
padding: const EdgeInsets.symmetric( | ||
horizontal: 16), | ||
decoration: | ||
BoxDecoration(border: Border.all()), | ||
child: Padding( | ||
padding: const EdgeInsets.symmetric( | ||
horizontal: 7, vertical: 10), | ||
child: Row( | ||
mainAxisAlignment: | ||
MainAxisAlignment.spaceBetween, | ||
children: [ | ||
Container( | ||
width: 140, | ||
child: Text( | ||
materialDoc['title'].toString(), | ||
style: TextStyle( | ||
fontSize: 16, | ||
fontWeight: FontWeight.w600), | ||
), | ||
), | ||
Container( | ||
width: 60, | ||
child: Text( | ||
'Terakhir dilihat: 15/09', | ||
style: TextStyle( | ||
fontSize: 14, | ||
fontWeight: FontWeight.w400), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
return Container(); | ||
}).toList(), | ||
), | ||
); | ||
}), | ||
], | ||
), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
app/lib/features/material/viewer/presentation/pages/_pages.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'dart:async'; | ||
import 'dart:io'; | ||
|
||
import 'package:dio/dio.dart'; | ||
import 'package:firebase_storage/firebase_storage.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_pdfview/flutter_pdfview.dart'; | ||
import 'package:path_provider/path_provider.dart'; | ||
import 'package:permission_handler/permission_handler.dart'; | ||
|
||
|
||
part 'pdf_viewer_page.dart'; |
Oops, something went wrong.