Fakultas Ilmu Komputer UI

Commit abb5c267 authored by Michael Wiryadinata Halim's avatar Michael Wiryadinata Halim
Browse files

Resolve "Download report program"

parent 926de04f
Copyright 2011 The Montserrat Project Authors (https://github.com/JulietaUla/Montserrat)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
......@@ -157,7 +157,7 @@ class Router {
));
case donationReUpload:
final Map<String, dynamic> args = settings.arguments;
return MaterialPageRoute<Donasi>(
return MaterialPageRoute<DonationReUpload>(
builder: (context) => DonationReUpload(
donation: args['donation'],
));
......
......@@ -82,7 +82,7 @@ class _DonationState extends State<Donasi> {
children: <Widget>[
SizedBox(
height: MediaQuery.of(context).size.height / 4,
child: CachedImage(url: widget.program.image)),
child: CachedImage(url: widget.program.posterImage)),
DonasiBody(
tap: onTap,
program: widget.program,
......
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:home_industry/Component/blue_button.dart';
import 'package:home_industry/Component/border_blue_button.dart';
import 'package:home_industry/Component/custom_circular.dart';
import 'package:home_industry/Component/date_time_formatter.dart';
import 'package:home_industry/Component/product_image.dart';
import 'package:home_industry/Component/router.dart';
import 'package:home_industry/Pages/Program/model/program.dart';
import 'package:url_launcher/url_launcher.dart';
class DetailProgram extends StatelessWidget {
final Program program;
......@@ -22,8 +26,9 @@ class DetailProgram extends StatelessWidget {
children: <Widget>[
SizedBox(
height: MediaQuery.of(context).size.height / 4,
child:
Hero(tag: program.id, child: CachedImage(url: program.image)),
child: Hero(
tag: program.id,
child: CachedImage(url: program.posterImage)),
),
Container(
height: 490,
......@@ -82,13 +87,15 @@ class DetailProgram extends StatelessWidget {
child: Text(
program.description,
overflow: TextOverflow.ellipsis,
maxLines: 10,
maxLines: 9,
style: Theme.of(context).textTheme.bodyText1,
),
),
],
),
),
if (program.programMinutes != null)
_ButtonDownloadNote(program: program),
SizedBox(
width: double.infinity,
height: 40,
......@@ -106,6 +113,48 @@ class DetailProgram extends StatelessWidget {
}
}
class _ButtonDownloadNote extends StatelessWidget {
const _ButtonDownloadNote({
Key key,
@required this.program,
}) : super(key: key);
final Program program;
@override
Widget build(BuildContext context) {
return SizedBox(
width: double.infinity,
height: 40,
child: FutureBuilder<bool>(
future: canLaunch(program.programMinutes),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
if (snapshot.hasData && snapshot.data) {
return BorderBlueButton(
onPressed: () async {
await launch(program.programMinutes);
},
label: 'Unduh notulensi');
} else if (snapshot.hasError ||
(snapshot.hasData && !snapshot.data)) {
return BorderBlueButton(
onPressed: () {
Clipboard.setData(
ClipboardData(text: program.programMinutes));
Scaffold.of(context).showSnackBar(SnackBar(
content: Text('Url notulensi diduplikasi ke clipboard'),
backgroundColor: Theme.of(context).primaryColor,
));
},
label: 'Duplikat url notulensi ke clipboard');
}
return const Center(
child: CustomCircularIndicator(),
);
}));
}
}
class _DeskripsiRow extends StatelessWidget {
const _DeskripsiRow({
Key key,
......
......@@ -3,35 +3,48 @@ import 'package:json_annotation/json_annotation.dart';
part 'program.g.dart';
@JsonSerializable(nullable: true)
@JsonSerializable(nullable: true, fieldRename: FieldRename.snake)
class Program extends Equatable {
@JsonKey(nullable: false)
final String id;
@JsonKey(nullable: false)
final String code;
@JsonKey(nullable: false)
final String name;
@JsonKey(nullable: false)
final String description;
@JsonKey(name: 'start_date_time')
final DateTime startDateTime;
@JsonKey(name: 'end_date_time')
final DateTime endDateTime;
final String location;
final String speaker;
@JsonKey(nullable: false)
final bool openDonation;
final String programMinutes;
@JsonKey(name: 'poster_image')
final String image;
final String posterImage;
@JsonKey(nullable: false)
final String totalDonationAmount;
const Program(
{this.id,
this.name,
this.description,
this.code,
this.openDonation,
this.programMinutes,
this.totalDonationAmount,
this.startDateTime,
this.endDateTime,
this.location,
this.speaker,
this.image});
this.posterImage});
factory Program.fromJson(Map<String, dynamic> json) =>
_$ProgramFromJson(json);
......@@ -40,12 +53,16 @@ class Program extends Equatable {
@override
List<Object> get props => [
id,
code,
openDonation,
programMinutes,
totalDonationAmount,
name,
description,
startDateTime,
endDateTime,
location,
speaker,
image
posterImage
];
}
......@@ -11,6 +11,10 @@ Program _$ProgramFromJson(Map<String, dynamic> json) {
id: json['id'] as String,
name: json['name'] as String,
description: json['description'] as String,
code: json['code'] as String,
openDonation: json['open_donation'] as bool,
programMinutes: json['program_minutes'] as String,
totalDonationAmount: json['total_donation_amount'] as String,
startDateTime: json['start_date_time'] == null
? null
: DateTime.parse(json['start_date_time'] as String),
......@@ -19,17 +23,21 @@ Program _$ProgramFromJson(Map<String, dynamic> json) {
: DateTime.parse(json['end_date_time'] as String),
location: json['location'] as String,
speaker: json['speaker'] as String,
image: json['poster_image'] as String,
posterImage: json['poster_image'] as String,
);
}
Map<String, dynamic> _$ProgramToJson(Program instance) => <String, dynamic>{
'id': instance.id,
'code': instance.code,
'name': instance.name,
'description': instance.description,
'start_date_time': instance.startDateTime?.toIso8601String(),
'end_date_time': instance.endDateTime?.toIso8601String(),
'location': instance.location,
'speaker': instance.speaker,
'poster_image': instance.image,
'open_donation': instance.openDonation,
'program_minutes': instance.programMinutes,
'poster_image': instance.posterImage,
'total_donation_amount': instance.totalDonationAmount,
};
......@@ -159,7 +159,7 @@ class ProgramCard extends StatelessWidget {
child: Hero(
tag: program.id,
child: CachedImage(
url: program.image,
url: program.posterImage,
),
),
),
......
import 'package:bloc/bloc.dart';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
......@@ -39,6 +41,10 @@ Future<void> main() async {
await GlobalConfiguration().loadFromAsset('app_settings');
Intl.defaultLocale = 'id';
await initializeDateFormatting();
LicenseRegistry.addLicense(() async* {
final license = await rootBundle.loadString('font/OFL.txt');
yield LicenseEntryWithLineBreaks(['google_fonts'], license);
});
final options = BaseOptions(baseUrl: GlobalConfiguration().getString('url'));
final dio = Dio(options);
BlocSupervisor.delegate = SimpleBlocDelegate();
......
......@@ -477,14 +477,14 @@ packages:
name: node_interop
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
node_io:
dependency: transitive
description:
name: node_io
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
node_preamble:
dependency: transitive
description:
......@@ -526,7 +526,7 @@ packages:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.0.2"
pedantic:
dependency: "direct dev"
description:
......@@ -811,7 +811,7 @@ packages:
name: vm_service
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.3"
version: "4.0.4"
watcher:
dependency: transitive
description:
......@@ -832,7 +832,7 @@ packages:
name: webkit_inspection_protocol
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.3"
version: "0.5.4"
xml:
dependency: transitive
description:
......
......@@ -26,7 +26,11 @@ void main() {
endDateTime: null,
location: 'Rumah saya',
speaker: 'Sherlock Holmes',
image: 'test');
totalDonationAmount: '0',
programMinutes: null,
openDonation: true,
code: '123',
posterImage: 'test');
widgetTested = MaterialApp(
home: RepositoryProvider<ProgramRepository>.value(
value: progRep, child: DetailProgram(program: program)));
......@@ -43,6 +47,46 @@ void main() {
expect(find.byType(CachedNetworkImage), findsOneWidget);
expect(find.byType(RichText), findsNWidgets(13));
expect(find.text('DONASI'), findsOneWidget);
await tester.pump(Duration(seconds: 2));
expect(
find.byType(FutureBuilder<bool>(
builder: (BuildContext context, AsyncSnapshot asyncSnapshot) {
return SizedBox.shrink();
},
).runtimeType),
findsNothing);
});
testWidgets('Test detail loaded button download',
(WidgetTester tester) async {
final programHasReport = Program(
id: 'yha',
name: 'Rumah Belajar',
description: 'Belajar Komputer',
startDateTime: null,
endDateTime: null,
location: 'Rumah saya',
speaker: 'Sherlock Holmes',
totalDonationAmount: '0',
programMinutes: 'https://google.com',
openDonation: true,
code: '123',
posterImage: 'test');
final widget = MaterialApp(
home: RepositoryProvider<ProgramRepository>.value(
value: ProgramRepository(dio: dio),
child: DetailProgram(program: programHasReport)));
await tester.pumpWidget(widget);
expect(find.text('Rumah Belajar'), findsOneWidget);
expect(find.text('DONASI'), findsOneWidget);
await tester.pump(Duration(seconds: 2));
expect(
find.byType(FutureBuilder<bool>(
builder: (BuildContext context, AsyncSnapshot asyncSnapshot) {
return SizedBox.shrink();
},
).runtimeType),
findsOneWidget);
});
});
}
......@@ -83,7 +83,7 @@ void main() {
endDateTime: null,
location: 'Rumah saya',
speaker: 'Sherlock Holmes',
image: null);
posterImage: null);
final depRep = DependenciesRepositories(dio: DioMock());
widgetTested = RepositoryProvider<DependenciesRepositories>.value(
value: depRep,
......
......@@ -39,8 +39,12 @@ void main() {
startDateTime: null,
endDateTime: null,
location: 'Rumah saya',
code: '123',
openDonation: true,
programMinutes: null,
totalDonationAmount: '0',
speaker: 'Sherlock Holmes',
image: null);
posterImage: null);
listProgram =
ListProgram(count: 1, next: null, previous: null, results: [program]);
dio = DioMock();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment