Skip to content

Commit

Permalink
cleanup, simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
onur-yildiz committed Mar 28, 2021
1 parent 527b431 commit d1d63f3
Show file tree
Hide file tree
Showing 18 changed files with 157 additions and 189 deletions.
2 changes: 1 addition & 1 deletion lib/providers/addictions_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class AddictionsProvider with ChangeNotifier {
}

void reorderAddictions(int oldIndex, int newIndex) async {
// if reverting a delete, skip (see insertAddiction func.)
// if reverting a delete, skip (see insertAddiction funt.)
if (oldIndex != _addictions.length) {
Addiction temp = _addictions.removeAt(oldIndex);
_addictions.insert(newIndex, temp);
Expand Down
17 changes: 9 additions & 8 deletions lib/screens/addiction_item_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class _AddictionItemState extends State<AddictionItemScreen> {

@override
Widget build(BuildContext context) {
final t = Theme.of(context);
final AddictionItemScreenArgs args =
ModalRoute.of(context).settings.arguments;
final local = AppLocalizations.of(context);
Expand All @@ -56,20 +57,20 @@ class _AddictionItemState extends State<AddictionItemScreen> {
PersistentBottomNavBarItem(
icon: FaIcon(FontAwesomeIcons.infoCircle),
title: (local.overview),
activeColor: Theme.of(context).primaryColor,
inactiveColor: Theme.of(context).hintColor,
activeColor: t.primaryColor,
inactiveColor: t.hintColor,
),
PersistentBottomNavBarItem(
icon: FaIcon(FontAwesomeIcons.gifts),
title: (local.rewards),
activeColor: Theme.of(context).primaryColor,
inactiveColor: Theme.of(context).hintColor,
activeColor: t.primaryColor,
inactiveColor: t.hintColor,
),
PersistentBottomNavBarItem(
icon: FaIcon(FontAwesomeIcons.trophy),
title: (local.achievements),
activeColor: Theme.of(context).primaryColor,
inactiveColor: Theme.of(context).hintColor,
activeColor: t.primaryColor,
inactiveColor: t.hintColor,
),
];
}
Expand All @@ -96,14 +97,14 @@ class _AddictionItemState extends State<AddictionItemScreen> {
screens: _buildScreens(),
items: _navBarItems(),
confineInSafeArea: true,
backgroundColor: Theme.of(context).cardColor,
backgroundColor: t.cardColor,
handleAndroidBackButtonPress: true,
resizeToAvoidBottomInset: true,
stateManagement: true,
hideNavigationBarWhenKeyboardShows: true,
decoration: NavBarDecoration(
borderRadius: BorderRadius.circular(0.0),
colorBehindNavBar: Theme.of(context).canvasColor,
colorBehindNavBar: t.canvasColor,
),
popAllScreensOnTapOfSelectedTab: true,
popActionScreens: PopActionScreensType.all,
Expand Down
18 changes: 9 additions & 9 deletions lib/screens/addictions_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class _AddictionsScreenState extends State<AddictionsScreen> {

@override
Widget build(BuildContext context) {
final t = Theme.of(context);
final deviceSize = MediaQuery.of(context).size;
final local = AppLocalizations.of(context);

Expand Down Expand Up @@ -114,7 +115,7 @@ class _AddictionsScreenState extends State<AddictionsScreen> {
child: FloatingActionButton(
heroTag: 'newAddiction',
onPressed: pushCreateAddictionScreen,
backgroundColor: Theme.of(context).primaryColor,
backgroundColor: t.primaryColor,
tooltip: local.newMsg,
child: Icon(Icons.add),
),
Expand All @@ -133,8 +134,8 @@ class _AddictionsScreenState extends State<AddictionsScreen> {
_setProgNotifTasks(addictionsData.addictions);
return addictionsData.addictions.length > 0
? Theme(
data: Theme.of(context).copyWith(
cardColor: Theme.of(context).canvasColor,
data: t.copyWith(
cardColor: t.canvasColor,
canvasColor: Colors.transparent,
shadowColor: Colors.black26,
),
Expand Down Expand Up @@ -167,11 +168,11 @@ class _AddictionsScreenState extends State<AddictionsScreen> {
child: FloatingActionButton(
heroTag: 'newAddiction',
elevation: 0,
backgroundColor: Theme.of(context).primaryColor,
foregroundColor: Theme.of(context).canvasColor,
backgroundColor: t.primaryColor,
foregroundColor: t.canvasColor,
child: Icon(
Icons.add,
size: Theme.of(context).textTheme.headline1.fontSize,
size: t.textTheme.headline1.fontSize,
),
onPressed: null,
),
Expand All @@ -184,9 +185,8 @@ class _AddictionsScreenState extends State<AddictionsScreen> {
child: Text(
local.appName,
style: TextStyle(
fontSize:
Theme.of(context).textTheme.headline2.fontSize,
color: Theme.of(context).primaryColor,
fontSize: t.textTheme.headline2.fontSize,
color: t.primaryColor,
fontWeight: FontWeight.bold,
),
),
Expand Down
45 changes: 22 additions & 23 deletions lib/screens/create_addiction_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ class CreateAddictionScreen extends StatelessWidget {

@override
Widget build(BuildContext context) {
final t = Theme.of(context);
final statusBarHeight = MediaQuery.of(context).padding.top;
return Hero(
tag: 'newAddiction',
transitionOnUserGestures: true,
child: Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).primaryColor,
backgroundColor: t.primaryColor,
),
body: AddictionCard(statusBarHeight),
),
Expand Down Expand Up @@ -182,12 +183,13 @@ class _AddictionCardState extends State<AddictionCard>

@override
Widget build(BuildContext context) {
final t = Theme.of(context);
final local = AppLocalizations.of(context);
final deviceSize = MediaQuery.of(context).size;

return Container(
margin: EdgeInsets.zero,
color: Theme.of(context).cardColor,
color: t.cardColor,
child: Form(
key: _formKey,
child: SingleChildScrollView(
Expand Down Expand Up @@ -216,11 +218,11 @@ class _AddictionCardState extends State<AddictionCard>
children: [
Material(
type: MaterialType.button,
color: Theme.of(context).canvasColor,
color: t.canvasColor,
borderRadius: BorderRadius.circular(5),
child: InkWell(
borderRadius: BorderRadius.circular(5),
splashColor: Theme.of(context).highlightColor,
splashColor: t.highlightColor,
onTap: () {
setState(() {
FocusScope.of(context).unfocus();
Expand All @@ -231,7 +233,7 @@ class _AddictionCardState extends State<AddictionCard>
});
},
child: Container(
height: Theme.of(context).buttonTheme.height * 2,
height: t.buttonTheme.height * 2,
padding: const EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
Expand All @@ -246,7 +248,7 @@ class _AddictionCardState extends State<AddictionCard>
.subtitle2
.fontSize,
fontWeight: FontWeight.bold,
color: Theme.of(context).hintColor,
color: t.hintColor,
),
),
Wrap(
Expand All @@ -261,12 +263,12 @@ class _AddictionCardState extends State<AddictionCard>
addictionData['quit_date']),
),
style: TextStyle(
color: Theme.of(context).hintColor,
color: t.hintColor,
),
),
Icon(
Icons.date_range,
color: Theme.of(context).hintColor,
color: t.hintColor,
),
],
),
Expand All @@ -277,20 +279,20 @@ class _AddictionCardState extends State<AddictionCard>
),
Material(
type: MaterialType.button,
color: Theme.of(context).canvasColor,
color: t.canvasColor,
borderRadius: BorderRadius.circular(5),
child: InkWell(
focusNode: _focusNode,
borderRadius: BorderRadius.circular(5),
splashColor: Theme.of(context).highlightColor,
splashColor: t.highlightColor,
onTap: () {
setState(() {
showModalBottomSheet(
backgroundColor: Colors.transparent,
context: context,
builder: (context) => Container(
decoration: BoxDecoration(
color: Theme.of(context).cardColor,
color: t.cardColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10),
Expand Down Expand Up @@ -318,13 +320,12 @@ class _AddictionCardState extends State<AddictionCard>
},
icon: Icon(
Icons.iso_outlined,
color: Theme.of(context).hintColor,
color: t.hintColor,
),
label: Text(
local.quantity,
style: TextStyle(
color:
Theme.of(context).hintColor,
color: t.hintColor,
fontWeight: FontWeight.bold,
),
),
Expand All @@ -351,13 +352,12 @@ class _AddictionCardState extends State<AddictionCard>
},
icon: Icon(
Icons.hourglass_bottom_rounded,
color: Theme.of(context).hintColor,
color: t.hintColor,
),
label: Text(
local.hour(0),
style: TextStyle(
color:
Theme.of(context).hintColor,
color: t.hintColor,
fontWeight: FontWeight.bold,
),
),
Expand All @@ -369,11 +369,11 @@ class _AddictionCardState extends State<AddictionCard>
});
},
child: Container(
height: Theme.of(context).buttonTheme.height * 2,
height: t.buttonTheme.height * 2,
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: Theme.of(context).canvasColor,
color: t.canvasColor,
),
child: Column(
mainAxisAlignment:
Expand All @@ -388,7 +388,7 @@ class _AddictionCardState extends State<AddictionCard>
.subtitle2
.fontSize,
fontWeight: FontWeight.bold,
color: Theme.of(context).hintColor,
color: t.hintColor,
),
),
Text(
Expand All @@ -400,7 +400,7 @@ class _AddictionCardState extends State<AddictionCard>
.textTheme
.subtitle2
.fontSize,
color: Theme.of(context).hintColor,
color: t.hintColor,
),
),
],
Expand Down Expand Up @@ -456,8 +456,7 @@ class _AddictionCardState extends State<AddictionCard>
child: Text(
local.quitAddiction,
style: TextStyle(
fontSize:
Theme.of(context).textTheme.headline6.fontSize,
fontSize: t.textTheme.headline6.fontSize,
),
),
),
Expand Down
Loading

0 comments on commit d1d63f3

Please sign in to comment.