Skip to content

Commit

Permalink
added empty_data widget
Browse files Browse the repository at this point in the history
  • Loading branch information
luhluh-17 committed Jun 1, 2020
1 parent e647ca7 commit a2096a4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 46 deletions.
11 changes: 8 additions & 3 deletions lib/pages/records_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:neucalcu/models/record.dart';
import 'package:neucalcu/themes/colors.dart';
import 'package:neucalcu/themes/dimensions.dart';
import 'package:neucalcu/widgets/custom_icon_button.dart';
import 'package:neucalcu/widgets/empty_data.dart';
import 'package:neucalcu/widgets/record_container.dart';

const double _padding = 16.0;
Expand Down Expand Up @@ -58,7 +59,9 @@ class RecordsPage extends StatelessWidget {
),
),
SizedBox(height: 24.0),
RecordListViewBuilder(box: recordBox),
recordBox.length >= 1
? RecordListViewBuilder(box: recordBox)
: EmptyData()
],
),
);
Expand All @@ -76,7 +79,10 @@ class RecordListViewBuilder extends StatelessWidget {
child: ListView.builder(
physics: BouncingScrollPhysics(),
padding: EdgeInsets.only(
left: _padding, right: _padding, bottom: _padding),
left: _padding,
right: _padding,
bottom: _padding,
),
itemCount: box.length,
itemBuilder: (context, index) {
final Record record = box.get(index);
Expand All @@ -86,4 +92,3 @@ class RecordListViewBuilder extends StatelessWidget {
);
}
}

20 changes: 20 additions & 0 deletions lib/widgets/empty_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:flutter/material.dart';
import 'package:neucalcu/themes/colors.dart';
import 'package:neucalcu/themes/dimensions.dart';

class EmptyData extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Expanded(
child: Center(
child: Text(
'Empty Data',
style: TextStyle(
color: AppColors.primaryText,
fontSize: sizeHeadline1,
),
),
),
);
}
}
72 changes: 29 additions & 43 deletions lib/widgets/record_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,58 +18,44 @@ class RecordContainer extends StatefulWidget {
}

class _RecordContainerState extends State<RecordContainer> {
bool _isPressed = false;

@override
Widget build(BuildContext context) {
return Container(
height: 120.0,
height: 112.0,
width: double.infinity,
margin: EdgeInsets.symmetric(vertical: 8.0),
child: Listener(
onPointerDown: (event) {
setState(() => _isPressed = true);
},
onPointerUp: (event) {
setState(() => _isPressed = false);
context.read<Calculate>().getDataFromRecords(
answer: widget.record.answer,
equation: widget.record.equation,
date: widget.record.date);
Navigator.pop(context);
},
child: Stack(
child: Container(
padding: EdgeInsets.all(16.0),
decoration: getOuterShadow(radius: 15.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
AnimatedContainer(
duration: Duration(milliseconds: 100),
decoration: _isPressed
? getInnerShadow(radius: 16.0)
: getOuterShadow(radius: 16.0),
Row(
children: <Widget>[
Text(
getFormattedDate(date: widget.record.date),
style: TextStyle(color: AppColors.accent),
),
],
),
Container(
padding: EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Row(
children: <Widget>[
Text(
getFormattedDate(date: widget.record.date),
style: TextStyle(color: AppColors.accent),
),
],
),
SizedBox(height: 16.0),
Expanded(
child: DisplayScreen(
leadingText: widget.record.answer,
fontSizeLeading: sizeHeadline2,
trailingText: widget.record.equation,
),
),
],
SizedBox(height: 8.0),
Expanded(
child: GestureDetector(
onTap: (){
context.read<Calculate>().getDataFromRecords(
answer: widget.record.answer,
equation: widget.record.equation,
date: widget.record.date);
Navigator.pop(context);
},
child: DisplayScreen(
leadingText: widget.record.answer,
fontSizeLeading: sizeHeadline2,
trailingText: widget.record.equation,
),
),
)
),
],
),
),
Expand Down

0 comments on commit a2096a4

Please sign in to comment.