Fakultas Ilmu Komputer UI

Commit 1703356e authored by Michael Wiryadinata Halim's avatar Michael Wiryadinata Halim
Browse files

[REFACTOR] Fix code smell

parent aa8ea4ec
Pipeline #52306 passed with stages
in 26 minutes and 32 seconds
......@@ -4,9 +4,8 @@ import 'package:intl/intl.dart';
class DateFormatter{
final DateFormat formatter = DateFormat(DateFormat.YEAR_MONTH_DAY);
final DateTime dateTime;
final TextStyle style;
DateFormatter({Key key, @required this.dateTime, this.style});
DateFormatter({Key key, @required this.dateTime});
String format() {
return dateTime != null ? formatter.format(dateTime): "";
......@@ -16,9 +15,8 @@ class DateFormatter{
class TimeFormatter{
final DateFormat formatter = DateFormat(DateFormat.HOUR24_MINUTE);
final DateTime dateTime;
final TextStyle style;
TimeFormatter({Key key, @required this.dateTime, this.style});
TimeFormatter({Key key, @required this.dateTime});
String format() {
return dateTime != null ? formatter.format(dateTime): "";
......
......@@ -4,15 +4,17 @@ import 'package:google_fonts/google_fonts.dart';
class AppTheme {
static ThemeData custom(ThemeData base) {
return base.copyWith(
appBarTheme: const AppBarTheme().copyWith(
appBarTheme: base.appBarTheme.copyWith(
color: Colors.white,
iconTheme: IconThemeData(color: Colors.black),
iconTheme: IconThemeData(color: Colors.black87),
elevation: 0.5,
textTheme: TextTheme().copyWith(
title: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w700,
fontSize: 20))),
textTheme: GoogleFonts.montserratTextTheme(TextTheme(
title:
TextStyle(fontSize: 20, fontWeight: FontWeight.w600)))
.apply(
bodyColor: Colors.black,
displayColor: Colors.black,
)),
textTheme: GoogleFonts.montserratTextTheme(base.textTheme).apply(
bodyColor: Colors.black,
displayColor: Colors.black,
......
......@@ -30,7 +30,7 @@ class OTPPage extends StatelessWidget {
"One Time Password",
style: TextStyle(color: Colors.white),
),
iconTheme: IconThemeData(color: Colors.white),
iconTheme: const IconThemeData(color: Colors.white),
centerTitle: true,
backgroundColor: const Color(0xff3C8DBC),
),
......
......@@ -39,7 +39,6 @@ class DetailProduct extends StatelessWidget {
),
),
elevation: 0.5,
iconTheme: IconThemeData(color: Colors.black),
actions: <Widget>[
Material(
color: Colors.transparent,
......@@ -163,7 +162,7 @@ class _BodyDetailProduct extends StatelessWidget {
children: <Widget>[
const Text(
"Deskripsi",
style: TextStyle(fontSize: 22, fontWeight: FontWeight.w800),
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w800),
),
Text(
"${product.description}",
......
export 'search_program_bloc.dart';
export 'search_program_event.dart';
export 'search_program_state.dart';
export 'search_program_bloc.dart';
\ No newline at end of file
export 'search_program_state.dart';
\ No newline at end of file
......@@ -6,8 +6,9 @@ abstract class SearchProgramState extends Equatable {
final int page;
final String searchQuery;
final bool hasReachedMax;
const SearchProgramState(this.page, this.searchQuery, {@required this.hasReachedMax})
: assert(hasReachedMax != null);
const SearchProgramState(this.page, this.searchQuery,
{@required this.hasReachedMax})
: assert(hasReachedMax != null);
}
class InitialSearchProgramState extends SearchProgramState {
......@@ -21,7 +22,10 @@ class SearchProgramLoaded extends SearchProgramState {
final List<Program> programs;
const SearchProgramLoaded(
{@required this.programs, @required hasReachedMax, @required page, @required programQuery})
{@required this.programs,
@required hasReachedMax,
@required page,
@required programQuery})
: super(page, programQuery, hasReachedMax: hasReachedMax);
@override
......@@ -30,17 +34,17 @@ class SearchProgramLoaded extends SearchProgramState {
class SearchProgramLoading extends SearchProgramState {
const SearchProgramLoading({int page, String searchQuery, bool hasReachedMax})
: super (page, searchQuery, hasReachedMax: hasReachedMax);
: super(page, searchQuery, hasReachedMax: hasReachedMax);
@override
List<Object> get props => [page, searchQuery];
}
class SearchProgramError extends SearchProgramState{
class SearchProgramError extends SearchProgramState {
final String error;
const SearchProgramError({this. error, @required query})
: super(0, query, hasReachedMax: true);
const SearchProgramError({this.error, @required query})
: super(0, query, hasReachedMax: true);
@override
List<Object> get props => [page, searchQuery, error];
}
\ No newline at end of file
}
......@@ -19,99 +19,101 @@ class DetailProgram extends StatelessWidget {
centerTitle: true,
),
backgroundColor: Colors.white,
body: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
flex: 2,
child: Hero(
tag: program.id, child: CachedImage(url: program.image))),
Expanded(
flex: 5,
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
flex: 7,
child: Text(
"Pilar Belajar Vol. 3",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 22, fontWeight: FontWeight.w800),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
flex: 2,
child: Hero(
tag: program.id, child: CachedImage(url: program.image))),
Expanded(
flex: 5,
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const Expanded(
flex: 7,
child: Text(
"Pilar Belajar Vol. 3",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 22, fontWeight: FontWeight.w800),
),
Spacer(
flex: 1,
),
Expanded(
flex: 15,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
_DeskripsiRow(
icon: Icons.calendar_today,
),
const Spacer(
flex: 1,
),
Expanded(
flex: 15,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
_DeskripsiRow(
icon: Icons.calendar_today,
label:
'${DateFormatter(dateTime:
program.startDateTime).format()} - '
'${DateFormatter(dateTime:
program.endDateTime).format()}',
),
_DeskripsiRow(
icon: Icons.query_builder,
label:
'${DateFormatter(dateTime: program.startDateTime).format()} - '
'${DateFormatter(dateTime: program.endDateTime).format()}',
),
_DeskripsiRow(
icon: Icons.query_builder,
label:
'${TimeFormatter(dateTime: program.startDateTime).format()} - '
'${TimeFormatter(dateTime: program.endDateTime).format()}'),
_DeskripsiRow(
icon: Icons.room,
label: program.location,
),
_DeskripsiRow(
icon: Icons.perm_identity,
label: program.speaker)
],
),
),
Spacer(
flex: 1,
'${TimeFormatter(dateTime:
program.startDateTime).format()} - '
'${TimeFormatter(dateTime:
program.endDateTime).format()}'),
_DeskripsiRow(
icon: Icons.room,
label: program.location,
),
_DeskripsiRow(
icon: Icons.perm_identity,
label: program.speaker)
],
),
Expanded(
flex: 35,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Text(
"Deskripsi",
style: const TextStyle(
fontSize: 20, fontWeight: FontWeight.bold),
),
),
const Spacer(
flex: 1,
),
Expanded(
flex: 35,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Padding(
padding: EdgeInsets.only(bottom: 10),
child: Text(
"Deskripsi",
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.bold),
),
Text(
program.description,
overflow: TextOverflow.ellipsis,
maxLines: 8,
style: const TextStyle(fontSize: 17),
),
Spacer(
flex: 1,
),
SizedBox(
width: double.infinity,
height: 45,
child: BlueButton(
onPressed: () {}, label: "DONASI"))
],
),
)
],
),
),
Text(
program.description,
overflow: TextOverflow.ellipsis,
maxLines: 8,
style: const TextStyle(fontSize: 17),
),
const Spacer(
flex: 1,
),
SizedBox(
width: double.infinity,
height: 45,
child: BlueButton(
onPressed: () {}, label: "DONASI"))
],
),
)
],
),
)
],
),
),
)
],
));
}
}
......@@ -132,12 +134,12 @@ class _DeskripsiRow extends StatelessWidget {
padding: const EdgeInsets.only(right: 10),
child: Icon(
icon,
color: Color(0xff3C8DBC),
color: const Color(0xff3C8DBC),
),
),
Text(label,
overflow: TextOverflow.ellipsis,
style: TextStyle(
style: const TextStyle(
fontSize: 18,
))
]);
......
......@@ -44,7 +44,7 @@ class Programs extends StatelessWidget {
elevation: 0.5,
actions: <Widget>[
IconButton(
icon: Icon(Icons.search),
icon: const Icon(Icons.search),
onPressed: () async {
await onSearchPressed(context);
})
......@@ -116,8 +116,8 @@ class __ListProgramState extends State<_ListProgram> {
? state.programs.length
: state.programs.length + 1,
controller: _scrollController,
padding: EdgeInsets.symmetric(horizontal: 10),
physics: BouncingScrollPhysics(),
padding: const EdgeInsets.symmetric(horizontal: 10),
physics: const BouncingScrollPhysics(),
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) {
return index >= state.programs.length
......@@ -149,7 +149,7 @@ class ProgramCard extends StatelessWidget {
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
side: const BorderSide(color: Color(0xff43C8DBC), width: 1.5),
side: const BorderSide(color: Color(0xff3C8DBC), width: 1.5),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
......@@ -212,16 +212,20 @@ class _ProgramDescription extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'${DateFormatter(dateTime: program.startDateTime).format()} - '
'${DateFormatter(dateTime: program.endDateTime).format()}',
'${DateFormatter(dateTime:
program.startDateTime).format()} - '
'${DateFormatter(dateTime:
program.endDateTime).format()}',
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 16,
),
),
Text(
'${TimeFormatter(dateTime: program.startDateTime).format()} - '
'${TimeFormatter(dateTime: program.endDateTime).format()}',
'${TimeFormatter(dateTime:
program.startDateTime).format()} - '
'${TimeFormatter(dateTime:
program.endDateTime).format()}',
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 16,
......@@ -251,7 +255,7 @@ class _DonasiButton extends StatelessWidget {
return Container(
height: MediaQuery.of(context).size.height / 18,
child: SizedBox(
width: 100.0,
width: 100,
child: OutlineButton(
onPressed: () {
Navigator.of(context).pushNamed(Router.detailProgramPage,
......@@ -259,7 +263,7 @@ class _DonasiButton extends StatelessWidget {
},
child: const Text("DONASI"),
textColor: const Color(0xff3C8DBC),
borderSide: const BorderSide(color: Color(0xff43C8DBC), width: 2),
borderSide: const BorderSide(color: Color(0xff3C8DBC), width: 2),
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
),
......
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