Skip to content

Commit 737aa74

Browse files
committed
more refactoring / add card screen
1 parent e3d1f4f commit 737aa74

File tree

5 files changed

+129
-312
lines changed

5 files changed

+129
-312
lines changed

lib/main.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import 'package:mollet/screens/register_screens/registration_screen.dart';
1414
import 'package:mollet/screens/register_screens/reset_screen.dart';
1515
import 'package:mollet/screens/settings_screens/cards.dart';
1616
import 'package:mollet/screens/settings_screens/changePassword.dart';
17-
import 'package:mollet/screens/settings_screens/inviteFriend.dart';
1817
import 'package:mollet/screens/settings_screens/passwordSecurity.dart';
1918
import 'package:mollet/utils/colors.dart';
2019
import 'package:mollet/widgets/provider.dart';
@@ -39,7 +38,6 @@ final routes = {
3938
'/Security': (BuildContext context) => SecurityScreen(),
4039
'/ChangePassword': (BuildContext context) => ChangePasswordScreen(),
4140
'/Cards': (BuildContext context) => Cards(),
42-
'/InviteFriend': (BuildContext context) => InviteFriendScreen(),
4341
'/MyTabs': (BuildContext context) => TabsLayout(),
4442
};
4543

lib/screens/settings_screens/cards.dart

Lines changed: 122 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_svg/svg.dart';
3-
import 'package:google_fonts/google_fonts.dart';
43
import 'package:mollet/model/notifiers/userData_notifier.dart';
54
import 'package:mollet/model/services/user_management.dart';
65
import 'package:mollet/screens/tab_screens/checkout_screens/addPaymentMethod.dart';
@@ -45,76 +44,74 @@ class _CardsState extends State<Cards> {
4544
return Scaffold(
4645
key: _scaffoldKey,
4746
backgroundColor: MColors.primaryWhiteSmoke,
48-
appBar: AppBar(
49-
elevation: 0.0,
50-
brightness: Brightness.light,
51-
backgroundColor: MColors.primaryWhite,
52-
leading: IconButton(
47+
appBar: primaryAppBar(
48+
IconButton(
5349
icon: Icon(
5450
Icons.arrow_back_ios,
55-
color: MColors.textDark,
51+
color: MColors.textGrey,
5652
),
5753
onPressed: () {
5854
Navigator.of(context).pop();
5955
},
6056
),
61-
title: Text(
57+
Text(
6258
"Cards",
63-
style: GoogleFonts.montserrat(
64-
fontSize: 20.0,
65-
color: MColors.primaryPurple,
66-
fontWeight: FontWeight.bold),
59+
style: boldFont(MColors.primaryPurple, 18.0),
6760
),
68-
centerTitle: true,
61+
MColors.primaryWhiteSmoke,
62+
null,
63+
true,
64+
null,
6965
),
70-
body: Column(
71-
children: <Widget>[
72-
Container(
73-
padding: EdgeInsets.all(20.0),
74-
child: FutureBuilder(
75-
future: cardFuture,
76-
builder: (c, s) {
77-
switch (s.connectionState) {
78-
case ConnectionState.active:
79-
return Container(
80-
height: MediaQuery.of(context).size.height / 7,
81-
color: MColors.primaryWhiteSmoke,
82-
child: Center(
83-
child: CircularProgressIndicator(
84-
strokeWidth: 2.0,
66+
body: primaryContainer(
67+
Column(
68+
children: <Widget>[
69+
Container(
70+
child: FutureBuilder(
71+
future: cardFuture,
72+
builder: (c, s) {
73+
switch (s.connectionState) {
74+
case ConnectionState.active:
75+
return Container(
76+
height: MediaQuery.of(context).size.height / 7,
77+
color: MColors.primaryWhiteSmoke,
78+
child: Center(
79+
child: CircularProgressIndicator(
80+
strokeWidth: 2.0,
81+
),
8582
),
86-
),
87-
);
88-
break;
89-
case ConnectionState.done:
90-
return cardList.isEmpty ? noCard() : savedPaymentMethod();
91-
break;
92-
case ConnectionState.waiting:
93-
return Container(
94-
height: MediaQuery.of(context).size.height / 7,
95-
color: MColors.primaryWhiteSmoke,
96-
child: Center(
97-
child: CircularProgressIndicator(
98-
strokeWidth: 2.0,
83+
);
84+
break;
85+
case ConnectionState.done:
86+
return cardList.isEmpty ? noCard() : savedPaymentMethod();
87+
break;
88+
case ConnectionState.waiting:
89+
return Container(
90+
height: MediaQuery.of(context).size.height / 7,
91+
color: MColors.primaryWhiteSmoke,
92+
child: Center(
93+
child: CircularProgressIndicator(
94+
strokeWidth: 2.0,
95+
),
9996
),
100-
),
101-
);
102-
break;
103-
default:
104-
return Container(
105-
height: MediaQuery.of(context).size.height / 7,
106-
color: MColors.primaryWhiteSmoke,
107-
child: Center(
108-
child: CircularProgressIndicator(
109-
strokeWidth: 2.0,
97+
);
98+
break;
99+
default:
100+
return Container(
101+
height: MediaQuery.of(context).size.height / 7,
102+
color: MColors.primaryWhiteSmoke,
103+
child: Center(
104+
child: CircularProgressIndicator(
105+
strokeWidth: 2.0,
106+
),
110107
),
111-
),
112-
);
113-
}
114-
},
108+
);
109+
}
110+
},
111+
),
115112
),
116-
),
117-
],
113+
],
114+
),
118115
),
119116
);
120117
}
@@ -138,6 +135,7 @@ class _CardsState extends State<Cards> {
138135
),
139136
child: Column(
140137
crossAxisAlignment: CrossAxisAlignment.start,
138+
mainAxisAlignment: MainAxisAlignment.center,
141139
children: <Widget>[
142140
Row(
143141
children: <Widget>[
@@ -154,10 +152,7 @@ class _CardsState extends State<Cards> {
154152
child: Container(
155153
child: Text(
156154
"Payment method",
157-
style: GoogleFonts.montserrat(
158-
fontSize: 14.0,
159-
color: MColors.textGrey,
160-
),
155+
style: normalFont(MColors.textGrey, 14.0),
161156
),
162157
),
163158
),
@@ -187,13 +182,8 @@ class _CardsState extends State<Cards> {
187182
);
188183
}
189184
},
190-
child: Text(
191-
"Change",
192-
style: GoogleFonts.montserrat(
193-
fontSize: 14.0,
194-
color: MColors.primaryPurple,
195-
fontWeight: FontWeight.w600),
196-
),
185+
child: Text("Change",
186+
style: boldFont(MColors.primaryPurple, 14.0)),
197187
),
198188
),
199189
],
@@ -204,27 +194,19 @@ class _CardsState extends State<Cards> {
204194
crossAxisAlignment: CrossAxisAlignment.start,
205195
children: <Widget>[
206196
Container(
207-
padding: const EdgeInsets.only(top: 5.0),
208197
child: Text(
209198
card.cardHolder,
210-
style: GoogleFonts.montserrat(
211-
fontSize: 16.0,
212-
color: MColors.textDark,
213-
fontWeight: FontWeight.w500,
214-
),
199+
style: boldFont(MColors.textDark, 16.0),
215200
),
216201
),
217202
Row(
218203
children: <Widget>[
219204
Container(
220205
child: Text(
221-
"**** **** **** " +
206+
"•••• •••• •••• " +
222207
card.cardNumber
223208
.substring(card.cardNumber.length - 4),
224-
style: GoogleFonts.montserrat(
225-
fontSize: 16.0,
226-
color: MColors.textGrey,
227-
),
209+
style: normalFont(MColors.textGrey, 16.0),
228210
),
229211
),
230212
Spacer(),
@@ -248,89 +230,72 @@ class _CardsState extends State<Cards> {
248230
UserDataCardNotifier cardNotifier =
249231
Provider.of<UserDataCardNotifier>(context);
250232
var cardList = cardNotifier.userDataCardList;
251-
var card = cardList.first;
252-
return Center(
253-
child: Padding(
254-
padding: const EdgeInsets.all(20.0),
255-
child: Column(
256-
mainAxisAlignment: MainAxisAlignment.center,
257-
crossAxisAlignment: CrossAxisAlignment.center,
258-
children: <Widget>[
259-
SvgPicture.asset(
260-
"assets/images/creditcard.svg",
261-
height: 150,
262-
),
263-
SizedBox(
264-
height: 20.0,
265-
),
266-
Text(
267-
"No card is attached to this account",
268-
style: GoogleFonts.montserrat(
269-
fontSize: 16.0,
270-
color: MColors.primaryPurple,
271-
),
272-
),
273-
SizedBox(
274-
height: 5.0,
275-
),
276-
Padding(
277-
padding: const EdgeInsets.only(left: 30.0, right: 30.0),
278-
child: Text(
279-
"Add a new card to start making quick and easy payments",
280-
style: GoogleFonts.montserrat(
281-
fontSize: 14.0,
282-
color: MColors.textGrey,
233+
return Container(
234+
width: MediaQuery.of(context).size.width,
235+
padding: EdgeInsets.all(20.0),
236+
decoration: BoxDecoration(
237+
color: MColors.primaryWhite,
238+
borderRadius: BorderRadius.all(
239+
Radius.circular(10.0),
240+
),
241+
),
242+
child: Column(
243+
crossAxisAlignment: CrossAxisAlignment.start,
244+
mainAxisAlignment: MainAxisAlignment.center,
245+
children: <Widget>[
246+
Row(
247+
children: <Widget>[
248+
Container(
249+
child: SvgPicture.asset(
250+
"assets/images/icons/Wallet.svg",
251+
color: MColors.primaryPurple,
283252
),
284-
textAlign: TextAlign.center,
285253
),
286-
),
287-
SizedBox(
288-
height: 20.0,
289-
),
290-
SizedBox(
291-
width: double.infinity,
292-
height: 60.0,
293-
child: RawMaterialButton(
294-
elevation: 0.0,
295-
hoverElevation: 0.0,
296-
focusElevation: 0.0,
297-
highlightElevation: 0.0,
298-
fillColor: MColors.primaryPurple,
299-
onPressed: () async {
300-
UserDataCardNotifier cardNotifier =
301-
Provider.of<UserDataCardNotifier>(context, listen: false);
302-
303-
var navigationResult = await Navigator.of(context).push(
304-
MaterialPageRoute(
305-
builder: (context) => AddNewCard(card, cardList),
306-
),
307-
);
308-
if (navigationResult == true) {
309-
setState(() {
310-
getCard(cardNotifier);
311-
});
312-
showSimpleSnack(
313-
"Card has been updated",
314-
Icons.check_circle_outline,
315-
Colors.green,
316-
_scaffoldKey,
317-
);
318-
}
319-
},
320-
child: Text(
321-
"Add Card",
322-
style: GoogleFonts.montserrat(
323-
color: MColors.primaryWhite,
324-
fontSize: 16.0,
325-
fontWeight: FontWeight.bold),
326-
),
327-
shape: RoundedRectangleBorder(
328-
borderRadius: new BorderRadius.circular(10.0),
254+
SizedBox(
255+
width: 5.0,
256+
),
257+
Expanded(
258+
child: Container(
259+
child: Text(
260+
"Payment method",
261+
style: normalFont(MColors.textGrey, 14.0),
262+
),
329263
),
330264
),
265+
],
266+
),
267+
SizedBox(height: 10.0),
268+
Container(
269+
padding: const EdgeInsets.only(left: 25.0),
270+
child: Text(
271+
"No payment method added to this account",
272+
style: normalFont(MColors.textGrey, 16.0),
331273
),
332-
],
333-
),
274+
),
275+
SizedBox(height: 10.0),
276+
primaryButtonWhiteSmoke(
277+
Text("Add a payment method",
278+
style: boldFont(MColors.primaryPurple, 16.0)),
279+
() async {
280+
var navigationResult = await Navigator.of(context).push(
281+
MaterialPageRoute(
282+
builder: (context) => AddNewCard(null, cardList),
283+
),
284+
);
285+
if (navigationResult == true) {
286+
setState(() {
287+
getCard(cardNotifier);
288+
});
289+
showSimpleSnack(
290+
"Card has been updated",
291+
Icons.check_circle_outline,
292+
Colors.green,
293+
_scaffoldKey,
294+
);
295+
}
296+
},
297+
),
298+
],
334299
),
335300
);
336301
}

0 commit comments

Comments
 (0)