mirror of
https://github.com/SoPat712/RUSwipeShare.git
synced 2025-08-21 10:58:47 -04:00
461 lines
19 KiB
Dart
461 lines
19 KiB
Dart
import 'dart:collection';
|
|
import 'dart:ui';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:material_dialogs/shared/types.dart';
|
|
import 'package:material_dialogs/widgets/buttons/icon_button.dart';
|
|
import 'package:material_dialogs/widgets/buttons/icon_outline_button.dart';
|
|
import 'package:material_dialogs/material_dialogs.dart';
|
|
import 'package:ruswipeshare/main.dart';
|
|
|
|
enum CampusState { campuses, list_options, offers }
|
|
|
|
final List<String> entries = <String>[
|
|
'Antoinette Beauchamp',
|
|
'Iliana Campbell',
|
|
'Angelique Straub',
|
|
'Ryleigh Pond',
|
|
'Andy Watters',
|
|
'Raphael Gossett',
|
|
'Kent Deutsch',
|
|
'Bridger Mojica',
|
|
'Pearl Morse',
|
|
'Jana Munguia'
|
|
];
|
|
final Map<String, String> nameToAsset = {
|
|
'Brower Dining Hall': 'brower.jpg',
|
|
'Cafe West': 'cafe_west.jpg',
|
|
'Busch Dining Hall': 'bdh.jpg',
|
|
'Woody\'s Cafe': 'woodys.jpg',
|
|
'Livingston Dining Hall': 'ldh.jpg',
|
|
'Kilmer\'s Market': 'kilmers.png',
|
|
'Sbarro\'s': 'sbarros.jpg',
|
|
'Neilson Dining Hall': 'neilson.jpg',
|
|
'Cook Cafe': 'cook_cafe.jpg',
|
|
'Douglass Cafe': 'doug_cafe.jpg',
|
|
'Harvest INFH': 'harvest.jpg',
|
|
'Red Pine Pizza': 'red_pine.jpg'
|
|
};
|
|
final List<List<String>> eatingLocations = [
|
|
<String>['Brower Dining Hall', 'Cafe West'],
|
|
<String>['Busch Dining Hall', 'Woody\'s Cafe'],
|
|
<String>[
|
|
'Livingston Dining Hall',
|
|
'Kilmer\'s Market',
|
|
'Sbarro\'s',
|
|
],
|
|
<String>[
|
|
'Neilson Dining Hall',
|
|
'Cook Cafe',
|
|
'Douglass Cafe',
|
|
'Harvest INFH',
|
|
'Red Pine Pizza'
|
|
]
|
|
];
|
|
final List<int> colorCodes = <int>[600, 500, 100];
|
|
final List<String> timeBgAssets = <String>[
|
|
'assets/daytime_swipe.jpg',
|
|
'assets/afternoon_swipe.jpg',
|
|
'assets/nighttime_swipe.jpg'
|
|
];
|
|
|
|
class BuyScreen extends StatefulWidget {
|
|
const BuyScreen({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
_BuyScreenState createState() => _BuyScreenState();
|
|
}
|
|
|
|
class _BuyScreenState extends State<BuyScreen> {
|
|
CampusState _currentState = CampusState.campuses;
|
|
List<String> _diningOptions = List.empty();
|
|
String _selectedLocation = "";
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
switch (_currentState) {
|
|
case CampusState.campuses:
|
|
return Scaffold(
|
|
body: Column(
|
|
children: [
|
|
Expanded(
|
|
child: Center(
|
|
child: GridView.count(
|
|
shrinkWrap: true,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
crossAxisCount: 2,
|
|
crossAxisSpacing: 15,
|
|
childAspectRatio: 0.8,
|
|
mainAxisSpacing: 20,
|
|
padding: const EdgeInsets.all(10),
|
|
children: [
|
|
InkWell(
|
|
onTap: () {
|
|
setState(() {
|
|
_currentState = CampusState.list_options;
|
|
_diningOptions = eatingLocations[0];
|
|
});
|
|
},
|
|
child: ClipRRect(
|
|
borderRadius:
|
|
const BorderRadius.all(Radius.circular(25)),
|
|
child: Column(
|
|
children: [
|
|
Expanded(
|
|
child: Image.asset(
|
|
'assets/ca_bg.jpg',
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.all(8),
|
|
color: Colors.red,
|
|
child: const Text(
|
|
"College Avenue",
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
setState(() {
|
|
_currentState = CampusState.list_options;
|
|
_diningOptions = eatingLocations[1];
|
|
});
|
|
},
|
|
child: ClipRRect(
|
|
borderRadius:
|
|
const BorderRadius.all(Radius.circular(25)),
|
|
child: Column(
|
|
children: [
|
|
Expanded(
|
|
child: Image.asset(
|
|
'assets/busch_bg.jpg',
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.all(8),
|
|
color: Colors.red,
|
|
child: const Text(
|
|
"Busch",
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
setState(() {
|
|
_currentState = CampusState.list_options;
|
|
_diningOptions = eatingLocations[2];
|
|
});
|
|
},
|
|
child: ClipRRect(
|
|
borderRadius:
|
|
const BorderRadius.all(Radius.circular(25)),
|
|
child: Column(
|
|
children: [
|
|
Expanded(
|
|
child: Image.asset(
|
|
'assets/livi_bg.jpg',
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.all(8),
|
|
color: Colors.red,
|
|
child: const Text(
|
|
"Livi",
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
setState(() {
|
|
_currentState = CampusState.list_options;
|
|
_diningOptions = eatingLocations[3];
|
|
});
|
|
},
|
|
child: ClipRRect(
|
|
borderRadius:
|
|
const BorderRadius.all(Radius.circular(25)),
|
|
child: Column(
|
|
children: [
|
|
Expanded(
|
|
child: Image.asset(
|
|
'assets/cd_bg.jpg',
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.all(8),
|
|
color: Colors.red,
|
|
child: const Text(
|
|
"Cook-Douglass",
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)),
|
|
],
|
|
),
|
|
);
|
|
case CampusState.list_options:
|
|
return Scaffold(
|
|
body: Column(children: [
|
|
Container(
|
|
width: double.infinity,
|
|
child: ElevatedButton(
|
|
onPressed: () {
|
|
setState(() {
|
|
_currentState = CampusState.campuses;
|
|
});
|
|
},
|
|
child: const Text("Choose A Different Location")),
|
|
),
|
|
Expanded(
|
|
child: ListView.builder(
|
|
physics: const BouncingScrollPhysics(),
|
|
itemCount: _diningOptions.length,
|
|
padding: EdgeInsets.zero,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return Container(
|
|
margin: const EdgeInsets.all(4),
|
|
decoration: BoxDecoration(
|
|
border: Border.all(
|
|
color: CustomMaterialColor(240, 240, 240).mdColor,
|
|
width: 2),
|
|
borderRadius:
|
|
const BorderRadius.all(Radius.circular(40))),
|
|
child: InkWell(
|
|
onTap: () {
|
|
setState(() {
|
|
_currentState = CampusState.offers;
|
|
_selectedLocation = _diningOptions.elementAt(index);
|
|
});
|
|
},
|
|
child: ClipRRect(
|
|
borderRadius:
|
|
const BorderRadius.all(Radius.circular(40)),
|
|
child: Container(
|
|
height: 80,
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
fit: BoxFit.cover,
|
|
image: AssetImage("assets/" +
|
|
nameToAsset[
|
|
_diningOptions.elementAt(index)]!),
|
|
)),
|
|
child: BackdropFilter(
|
|
filter: ImageFilter.blur(sigmaX: 3, sigmaY: 3),
|
|
child: Container(
|
|
padding: const EdgeInsets.only(right: 40),
|
|
alignment: Alignment.bottomRight,
|
|
margin: const EdgeInsets.only(
|
|
top: 4, left: 20, bottom: 4),
|
|
child: Text(
|
|
_diningOptions[index],
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(fontSize: 24),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
)
|
|
]),
|
|
);
|
|
case CampusState.offers:
|
|
return Scaffold(
|
|
body: Column(
|
|
children: [
|
|
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
|
|
Flexible(
|
|
flex: 8,
|
|
fit: FlexFit.tight,
|
|
child: ElevatedButton(
|
|
onPressed: () {
|
|
setState(() {
|
|
_currentState = CampusState.campuses;
|
|
});
|
|
},
|
|
child: const Text("Choose A Different Location")),
|
|
),
|
|
Flexible(
|
|
flex: 2,
|
|
child: ElevatedButton(
|
|
onPressed: () {}, child: const Icon(Icons.filter_list)))
|
|
]),
|
|
Expanded(
|
|
child: ListView.builder(
|
|
physics: const BouncingScrollPhysics(),
|
|
itemCount: 30,
|
|
padding: EdgeInsets.zero,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return InkWell(
|
|
onTap: () {
|
|
Dialogs.materialDialog(
|
|
color: CustomMaterialColor(240, 240, 240).mdColor,
|
|
customView: const TransactionDetails(),
|
|
customViewPosition:
|
|
CustomViewPosition.BEFORE_ACTION,
|
|
msg:
|
|
'Please read all the information below before purchasing.',
|
|
title: 'Transaction Details',
|
|
context: context,
|
|
actions: [
|
|
IconsOutlineButton(
|
|
onPressed: () {},
|
|
text: 'Cancel',
|
|
iconData: Icons.cancel_outlined,
|
|
textStyle: const TextStyle(color: Colors.grey),
|
|
iconColor: Colors.grey,
|
|
),
|
|
IconsButton(
|
|
onPressed: () {},
|
|
text: 'Purchase',
|
|
iconData: Icons.done,
|
|
color: Colors.blue,
|
|
iconColor: Colors.white,
|
|
),
|
|
],
|
|
);
|
|
},
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
border: Border.all(
|
|
color: CustomMaterialColor(240, 240, 240)
|
|
.mdColor,
|
|
width: 2),
|
|
borderRadius:
|
|
const BorderRadius.all(Radius.circular(40))),
|
|
margin: const EdgeInsets.all(4),
|
|
height: 80,
|
|
child: ClipRRect(
|
|
borderRadius:
|
|
const BorderRadius.all(Radius.circular(40)),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
colorFilter: const ColorFilter.mode(
|
|
Colors.black26, BlendMode.darken),
|
|
fit: BoxFit.cover,
|
|
image: AssetImage(timeBgAssets[index % 3]),
|
|
)),
|
|
child: BackdropFilter(
|
|
filter: ImageFilter.blur(sigmaX: 2, sigmaY: 2),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
flex: 7,
|
|
child: Container(
|
|
padding: EdgeInsets.only(left: 20),
|
|
// color: Colors.red,
|
|
margin: const EdgeInsets.only(
|
|
top: 4, left: 4, bottom: 4),
|
|
child: Column(
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
entries[index % entries.length],
|
|
textAlign: TextAlign.start,
|
|
overflow: TextOverflow.ellipsis,
|
|
style:
|
|
const TextStyle(fontSize: 20),
|
|
),
|
|
Row(
|
|
children: const [
|
|
Icon(Icons.star, size: 16),
|
|
Icon(Icons.star, size: 16),
|
|
Icon(Icons.star, size: 16),
|
|
Icon(Icons.star_half, size: 16),
|
|
Icon(Icons.star_border,
|
|
size: 16),
|
|
],
|
|
),
|
|
Expanded(
|
|
child: Column(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.end,
|
|
children: const [
|
|
Text(
|
|
'88:88PM - 88:88PM',
|
|
textAlign: TextAlign.start,
|
|
overflow:
|
|
TextOverflow.ellipsis,
|
|
style:
|
|
TextStyle(fontSize: 16),
|
|
),
|
|
],
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 3,
|
|
child: Container(
|
|
padding: EdgeInsets.only(right: 15),
|
|
child: Text(
|
|
'\$88',
|
|
textAlign: TextAlign.end,
|
|
style: TextStyle(fontSize: 44),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
class TransactionDetails extends StatefulWidget {
|
|
const TransactionDetails({super.key});
|
|
|
|
@override
|
|
State<TransactionDetails> createState() => _TransactionDetailsState();
|
|
}
|
|
|
|
class _TransactionDetailsState extends State<TransactionDetails> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
height: 80,
|
|
color: Colors.blue,
|
|
);
|
|
}
|
|
}
|