Professional Documents
Culture Documents
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:tip_calculator/rating_page.dart';
@override
State<MealRaterHomeView> createState() => _MealRaterHomeViewState();
}
});
});
} on FirebaseException catch (e) {
print(e.code);
}
},
child: const Text(
'Save',
style: TextStyle(
color: Color(0xffEC9E37),
fontWeight: FontWeight.w500,
fontSize: 24,
),
),
),
),
),
const SizedBox(width: 20),
Expanded(
child: SizedBox(
height: 50,
width: 250,
child: ElevatedButton(
onPressed: () {
navigateToRatingScreen();
},
child: const Text(
'Rate Meal',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.w500,
color: Color(0xffEC9E37),
),
),
),
),
),
],
),
],
),
),
),
);
}
import 'package:flutter/material.dart';
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppBar(
leading: InkWell(
onTap: () {
Navigator.pop(context);
},
child: const Icon(
Icons.arrow_back,
color: Color(0xffEC9E37),
)),
backgroundColor: const Color(0xff1E3C64),
title: const Text('Rate this meal'),
),
body: Column(
children: <Widget>[
const SizedBox(height: 40),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
for (int i = 1; i <= 5; i++)
GestureDetector(
onTap: () {
_handleRatingChanged(i);
},
child: Container(
width: 70,
height: 50,
decoration: BoxDecoration(
border: Border(
top: const BorderSide(
color: Colors.blue,
width: 2.0,
),
left: i != 2 && i != 4 && i != 3 && i != 5
? const BorderSide(
color: Colors.blue,
width: 2.0,
)
: BorderSide.none,
right:
const BorderSide(color: Colors.blue, width: 2.0),
bottom:
const BorderSide(color: Colors.blue, width: 2.0),
),
color: _currentRating >= i ? Colors.blue : Colors.white,
),
child: Center(
child: Text(
'$i',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: _currentRating >= i
? Colors.white
: Colors.blue),
),
),
),
),
],
),
const SizedBox(height: 20),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Expanded(
child: SizedBox(
height: 50,
child: ElevatedButton(
onPressed: () {
setState(() {
_currentRating = 1;
});
},
child: const Text(
' Cancel',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.w500,
color: Color(0xffEC9E37)),
),
),
),
),
const SizedBox(width: 10),
Expanded(
child: SizedBox(
height: 50,
child: ElevatedButton(
onPressed: () {
Navigator.pop(context, _currentRating);
},
child: const Text(
'Save',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.w500,
color: Color(0xffEC9E37)),
),
),
),
),
],
),
),
],
),
),
);
}