123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356 |
- import 'package:flutter/material.dart';
- import 'package:flutter_compass/flutter_compass.dart';
- import 'dart:math' as math;
- import 'package:url_launcher/url_launcher.dart'; // 导入 url_launcher 包
- void main() {
- runApp(MyApp());
- }
- class MyApp extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- home: HomePage(),
- );
- }
- }
- class HomePage extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- double screenWidth = MediaQuery.of(context).size.width;
- double screenHeight = MediaQuery.of(context).size.height;
- return Scaffold(
- appBar: AppBar(
- title: Text('Ask Tao'),
- ),
- body: SingleChildScrollView(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- // Daily Tao 图片背景
- Container(
- width: screenWidth,
- height: screenHeight * 0.25,
- decoration: BoxDecoration(
- image: DecorationImage(
- image: AssetImage('assets/daily_tao_background.png'),
- fit: BoxFit.cover,
- ),
- ),
- child: Padding(
- padding: EdgeInsets.symmetric(
- horizontal: screenWidth * 0.05,
- vertical: screenHeight * 0.02,
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.end,
- children: [
- Text(
- 'Daily Tao',
- style: TextStyle(
- color: Colors.white,
- fontSize: screenWidth * 0.07,
- fontWeight: FontWeight.bold,
- ),
- ),
- SizedBox(height: screenHeight * 0.01),
- Text(
- '行者南游归,慈云洞庭开。\n寻经十二部,普度度有生。',
- style: TextStyle(
- color: Colors.white,
- fontSize: screenWidth * 0.04,
- ),
- ),
- SizedBox(height: screenHeight * 0.02),
- ElevatedButton(
- onPressed: () {
- // 按钮点击事件
- },
- style: ElevatedButton.styleFrom(
- backgroundColor: Colors.white.withOpacity(0.6),
- padding: EdgeInsets.symmetric(
- horizontal: screenWidth * 0.1,
- vertical: screenHeight * 0.02,
- ),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(30),
- ),
- ),
- child: Text(
- 'Learn more →',
- style: TextStyle(
- fontSize: screenWidth * 0.05,
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- // Study Tao & Find Inner Peace
- Padding(
- padding: EdgeInsets.all(screenWidth * 0.05),
- child: ListView(
- shrinkWrap: true,
- physics: NeverScrollableScrollPhysics(),
- children: [
- _buildOptionCard(
- screenWidth: screenWidth,
- screenHeight: screenHeight,
- image: 'assets/study_tao.png',
- title: 'Study Tao',
- subtitle: 'Chat to gain deeper understanding of Tao.',
- ),
- SizedBox(height: screenHeight * 0.02),
- _buildOptionCard(
- screenWidth: screenWidth,
- screenHeight: screenHeight,
- image: 'assets/inner_peace.png',
- title: 'Find Inner Peace',
- subtitle: 'Tell your troubles and find your inner peace.',
- ),
- SizedBox(height: screenHeight * 0.02),
- // 下方的小图标部分
- Padding(
- padding: EdgeInsets.all(screenWidth * 0.05),
- child: GridView.count(
- crossAxisCount: 3,
- shrinkWrap: true,
- physics: NeverScrollableScrollPhysics(),
- crossAxisSpacing: screenWidth * 0.02,
- mainAxisSpacing: screenHeight * 0.02,
- children: [
- _buildIconTile(
- screenWidth: screenWidth,
- icon: 'assets/fengshui.png',
- label: 'Fengshui',
- onTap: () {
- Navigator.push(
- context,
- MaterialPageRoute(builder: (context) => PropertyPage()),
- );
- },
- ),
- _buildIconTile(
- screenWidth: screenWidth,
- icon: 'assets/fortune_telling.png',
- label: 'Fortune telling',
- onTap: () {
- Navigator.push(
- context,
- MaterialPageRoute(builder: (context) => FortuneTellingPage()),
- );
- },
- ),
- _buildIconTile(
- screenWidth: screenWidth,
- icon: 'assets/divination.png',
- label: 'Divination',
- onTap: () {
- Navigator.push(
- context,
- MaterialPageRoute(builder: (context) => ClickAndDrawPage()),
- );
- },
- ),
- _buildIconTile(
- screenWidth: screenWidth,
- icon: 'assets/taoistpractice.png',
- label: 'Taoist practice',
- ),
- _buildIconTile(
- screenWidth: screenWidth,
- icon: 'assets/interpretdream.png',
- label: 'Interpret dream',
- onTap: () {
- Navigator.push(
- context,
- MaterialPageRoute(builder: (context) => DreamInterpretationScreen()),
- );
- },
- ),
- _buildIconTile(
- screenWidth: screenWidth,
- icon: 'assets/taoistculture.png',
- label: 'Taoist culture',
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- );
- }
- Widget _buildOptionCard({
- required double screenWidth,
- required double screenHeight,
- required String image,
- required String title,
- required String subtitle,
- }) {
- return Container(
- width: screenWidth,
- height: screenHeight * 0.12,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(20),
- image: DecorationImage(
- image: AssetImage(image),
- fit: BoxFit.cover,
- ),
- ),
- child: Padding(
- padding: EdgeInsets.all(screenWidth * 0.05),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- title,
- style: TextStyle(
- color: Colors.white,
- fontSize: screenWidth * 0.06,
- fontWeight: FontWeight.bold,
- ),
- ),
- SizedBox(height: screenHeight * 0.01),
- Flexible(
- child: Text(
- subtitle,
- style: TextStyle(
- color: Colors.white,
- fontSize: screenWidth * 0.04,
- ),
- overflow: TextOverflow.ellipsis,
- maxLines: 2,
- ),
- ),
- ],
- ),
- ),
- );
- }
- Widget _buildIconTile({
- required double screenWidth,
- required String icon,
- required String label,
- VoidCallback? onTap,
- }) {
- return GestureDetector(
- onTap: onTap,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Container(
- width: screenWidth * 0.15,
- height: screenWidth * 0.15,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- image: DecorationImage(
- image: AssetImage(icon),
- fit: BoxFit.cover,
- ),
- ),
- ),
- SizedBox(height: screenWidth * 0.01),
- Text(
- label,
- style: TextStyle(
- fontSize: screenWidth * 0.03,
- ),
- textAlign: TextAlign.center,
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- ),
- ],
- ),
- );
- }
- }
- PreferredSizeWidget commonAppBar(BuildContext context, String title) {
- return AppBar(
- title: Text(
- title,
- style: TextStyle(
- color: Colors.white,
- fontWeight: FontWeight.bold,
- ),
- ),
- backgroundColor: Colors.black,
- leading: IconButton(
- icon: Icon(Icons.arrow_back, color: Colors.white),
- onPressed: () => Navigator.of(context).pop(),
- ),
- actions: [
- IconButton(
- icon: Icon(Icons.home, color: Colors.white),
- onPressed: () {
- Navigator.of(context).popUntil((route) => route.isFirst);
- },
- ),
- ],
- );
- }
- class PropertyPage extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- double screenHeight = MediaQuery.of(context).size.height;
- double screenWidth = MediaQuery.of(context).size.width;
- return Scaffold(
- appBar: commonAppBar(context, 'Property Type'),
-
- body: SingleChildScrollView(
- child: Column(
- children: [
- // Yang Property Section
- Container(
- color: Color(0xFF00164C),
- child: ListTile(
- leading: Icon(Icons.house, color: Colors.white),
- title: Text(
- "Yang Property",
- style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
- ),
- ),
- ),
- Container(
- height: screenHeight * 0.3,
- child: PageView(
- scrollDirection: Axis.horizontal,
- children: [
- PropertyCard(
- title: "Town House",
- imageAsset: 'assets/townhouse.png',
- ),
- PropertyCard(
- title: "Single Family House",
- imageAsset: 'assets/singlefamily.png',
- ),
- PropertyCard(
- title: "Condo",
- imageAsset: 'assets/condo.png',
- ),
- ],
- ),
- ),
- SizedBox(height: screenHeight * 0.02),
- // Yin Property Section
- Container(
- color: Color(0xFF00164C),
- child: ListTile(
- leading: Icon(Icons.nights_stay, color: Colors.white),
- title: Text(
- "Yin Property",
- style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
- ),
- ),
- ),
- Container(
- height: screenHeight * 0.3,
- child: PropertyCard(
- title: "Grave",
- imageAsset: 'assets/grave.png',
- ),
- ),
- ],
- ),
- ),
- );
- }
- }
- class PropertyCard extends StatelessWidget {
- final String title;
- final String imageAsset;
- PropertyCard({required this.title, required this.imageAsset});
- @override
- Widget build(BuildContext context) {
- return Card(
- child: InkWell(
- onTap: () {
- print("PropertyCard tapped: $title");
- Navigator.push(
- context,
- MaterialPageRoute(builder: (context) => CompassPage()),
- );
- },
- child: Column(
- children: [
- Expanded(
- child: Image.asset(
- imageAsset,
- fit: BoxFit.cover,
- width: double.infinity,
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: Text(
- title,
- style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
- ),
- ),
- ],
- ),
- ),
- );
- }
- }
- class CompassPage extends StatefulWidget {
- @override
- _CompassPageState createState() => _CompassPageState();
- }
- class _CompassPageState extends State<CompassPage> {
- String address = "";
- bool isAddressEntered = false;
- double _direction = 0;
- double _confirmedDirection = 0;
- @override
- void initState() {
- super.initState();
- FlutterCompass.events!.listen((CompassEvent event) {
- setState(() {
- _direction = event.heading ?? 0;
- });
- });
- }
- @override
- Widget build(BuildContext context) {
- double screenHeight = MediaQuery.of(context).size.height;
- double screenWidth = MediaQuery.of(context).size.width;
- return Scaffold(
- appBar: commonAppBar(context, 'Property Type'),
-
- body: Container(
- decoration: BoxDecoration(
- gradient: LinearGradient(
- colors: [Colors.green[100]!, Colors.white],
- begin: Alignment.topLeft,
- end: Alignment.bottomRight,
- ),
- ),
- child: Column(
- children: [
- SizedBox(height: screenHeight * 0.02),
- Text(
- 'Gate Direction',
- style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
- ),
- Text(
- 'Use the compass to confirm your gate direction',
- style: TextStyle(color: Colors.grey, fontSize: 14),
- ),
- SizedBox(height: screenHeight * 0.03),
- Container(
- width: screenWidth * 0.75,
- height: screenWidth * 0.75,
- child: Transform.rotate(
- angle: ((_direction ?? 0) * (math.pi / 180) * -1),
- child: Image.asset('assets/compass.png'),
- ),
- ),
- SizedBox(height: screenHeight * 0.02),
- Text(
- '${_confirmedDirection.toStringAsFixed(0)}°',
- style: TextStyle(fontSize: 32, fontWeight: FontWeight.bold),
- ),
- Text(
- _getDirectionText(_confirmedDirection),
- style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
- ),
- SizedBox(height: screenHeight * 0.05),
- ElevatedButton(
- onPressed: () {
- setState(() {
- _confirmedDirection = _direction;
- });
- },
- style: ElevatedButton.styleFrom(
- backgroundColor: Colors.black,
- padding: EdgeInsets.symmetric(horizontal: 50, vertical: 15),
- ),
- child: Text(
- 'Confirm',
- style: TextStyle(color: Colors.white, fontSize: 18),
- ),
- ),
- SizedBox(height: screenHeight * 0.02),
- TextField(
- decoration: InputDecoration(
- labelText: 'Input your address',
- border: OutlineInputBorder(),
- ),
- onChanged: (value) {
- setState(() {
- address = value;
- isAddressEntered = value.isNotEmpty;
- });
- },
- ),
- SizedBox(height: screenHeight * 0.02),
- ElevatedButton(
- onPressed: isAddressEntered
- ? () {
- // 跳转到上传页面
- Navigator.push(
- context,
- MaterialPageRoute(builder: (context) => UploadPage()),
- );
- }
- : null,
- style: ElevatedButton.styleFrom(
- backgroundColor: isAddressEntered ? Colors.black : Colors.grey,
- padding: EdgeInsets.symmetric(horizontal: 50, vertical: 15),
- ),
- child: Text(
- 'Continue',
- style: TextStyle(color: Colors.white, fontSize: 18),
- ),
- ),
- ],
- ),
- ),
- );
- }
- String _getDirectionText(double direction) {
- if (direction >= 337.5 || direction < 22.5) return 'North';
- if (direction >= 22.5 && direction < 67.5) return 'North East';
- if (direction >= 67.5 && direction < 112.5) return 'East';
- if (direction >= 112.5 && direction < 157.5) return 'South East';
- if (direction >= 157.5 && direction < 202.5) return 'South';
- if (direction >= 202.5 && direction < 247.5) return 'South West';
- if (direction >= 247.5 && direction < 292.5) return 'West';
- if (direction >= 292.5 && direction < 337.5) return 'North West';
- return '';
- }
- }
- class UploadPage extends StatefulWidget {
- @override
- _UploadPageState createState() => _UploadPageState();
- }
- class _UploadPageState extends State<UploadPage> {
- String? selectedOption = "Floor Plan"; // 默认选择 "Floor Plan"
- @override
- Widget build(BuildContext context) {
- double screenHeight = MediaQuery.of(context).size.height;
- double screenWidth = MediaQuery.of(context).size.width;
- return Scaffold(
- appBar: commonAppBar(context, 'Property Type'),
-
- body: Container(
- padding: EdgeInsets.all(screenHeight * 0.02),
- decoration: BoxDecoration(
- gradient: LinearGradient(
- colors: [Colors.green[100]!, Colors.white],
- begin: Alignment.topLeft,
- end: Alignment.bottomRight,
- ),
- ),
- child: Column(
- children: [
-
- Text(
- "Upload",
- style: TextStyle(
- fontSize: screenWidth * 0.06,
- fontWeight: FontWeight.bold,
- color: Colors.black,
- ),
- ),
- SizedBox(height: screenHeight * 0.02),
- Container(
- width: screenWidth * 0.85,
- height: screenHeight * 0.2,
- decoration: BoxDecoration(
- color: Colors.grey.withOpacity(0.5),
- borderRadius: BorderRadius.circular(15),
- ),
- child: Center(
- child: Text(
- "Select File",
- style: TextStyle(color: Colors.black),
- ),
- ),
- ),
- SizedBox(height: screenHeight * 0.02),
- Column(
- children: [
- _buildRadioOption("Floor Plan"),
- _buildRadioOption("Indoor Photo"),
- _buildRadioOption("Surroundings"),
- ],
- ),
- SizedBox(height: screenHeight * 0.02),
- SizedBox(height: screenHeight * 0.02),
- ElevatedButton(
- onPressed: () async {
- const url = 'https://your-payment-url.com'; // 替换为实际的付费链接
- if (await canLaunch(url)) {
- await launch(url);
- Navigator.push(
- context,
- MaterialPageRoute(builder: (context) => FengShuiInterpretationPage()),
- );
- } else {
- throw 'Could not launch $url';
- }
- },
- child: Text("Pay to unlock", style: TextStyle(color: Colors.white, fontSize: 18)),
- style: ElevatedButton.styleFrom(
- backgroundColor: Colors.black,
- padding: EdgeInsets.symmetric(vertical: 15, horizontal: 30),
- ),
- ),
- SizedBox(height: screenHeight * 0.02),
- Row(
- children: [
- Expanded(child: Divider(color: Colors.grey)),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8.0),
- child: Text("or", style: TextStyle(color: Colors.black)),
- ),
- Expanded(child: Divider(color: Colors.grey)),
- ],
- ),
- SizedBox(height: screenHeight * 0.02),
- Container(
- decoration: BoxDecoration(
- color: Colors.black,
- borderRadius: BorderRadius.circular(30),
- ),
- child: TextButton(
- onPressed: () {
- Navigator.push(
- context,
- MaterialPageRoute(builder: (context) => FengShuiInterpretationPage()),
- );
- },
- child: Text(
- "Skip",
- style: TextStyle(color: Colors.white, fontSize: 18),
- ),
- ),
- ),
- ],
- ),
- ),
- );
- }
- Widget _buildRadioOption(String title) {
- bool isSelected = selectedOption == title;
- return Container(
- width: MediaQuery.of(context).size.width * 0.65,
- margin: EdgeInsets.symmetric(vertical: 5.0),
- decoration: BoxDecoration(
- color: isSelected ? Colors.black.withOpacity(0.6) : Colors.grey.withOpacity(0.3),
- borderRadius: BorderRadius.circular(10),
- ),
- child: RadioListTile(
- value: title,
- groupValue: selectedOption,
- title: Text(
- title,
- style: TextStyle(color: Colors.white),
- ),
- onChanged: (value) {
- setState(() {
- selectedOption = value as String?;
- });
- },
- activeColor: Colors.white,
- controlAffinity: ListTileControlAffinity.trailing,
- ),
- );
- }
- }
- class FengShuiInterpretationPage extends StatelessWidget {
- final TextEditingController _controller = TextEditingController();
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: commonAppBar(context, 'Feng Shui Interpretation'),
-
- body: Container(
- decoration: BoxDecoration(
- gradient: LinearGradient(
- colors: [Colors.green[100]!, Colors.white],
- begin: Alignment.topLeft,
- end: Alignment.bottomRight,
- ),
- ),
- child: Column(
- children: [
- Expanded(
- child: Container(
- padding: EdgeInsets.all(16.0),
- decoration: BoxDecoration(
- color: Colors.grey[200],
- borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
- ),
- child: SingleChildScrollView(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- 'Feng Shui Interpretation Content',
- style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
- ),
- SizedBox(height: 10),
- Text(
- 'Here you can provide detailed interpretations based on the user\'s input.',
- style: TextStyle(fontSize: 16),
- ),
- ],
- ),
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: Row(
- children: [
- Expanded(
- child: TextField(
- controller: _controller,
- decoration: InputDecoration(
- hintText: 'Type your message...',
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(30),
- ),
- filled: true,
- fillColor: Colors.white,
- ),
- ),
- ),
- IconButton(
- icon: Icon(Icons.send, color: Colors.black),
- onPressed: () {
- String message = _controller.text;
- if (message.isNotEmpty) {
- print("Message sent: $message");
- _controller.clear();
- }
- },
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- );
- }
- }
- class FortuneTellingPage extends StatefulWidget {
- @override
- _FortuneTellingPageState createState() => _FortuneTellingPageState();
- }
- class _FortuneTellingPageState extends State<FortuneTellingPage> {
- String? selectedGender;
- int? selectedHour;
- int? selectedMinute;
- TextEditingController countryController = TextEditingController();
- TextEditingController stateController = TextEditingController();
- TextEditingController cityController = TextEditingController();
- bool isAllFieldsFilled = false;
- void checkFieldsFilled() {
- if (selectedHour != null &&
- selectedMinute != null &&
- selectedGender != null &&
- countryController.text.isNotEmpty &&
- stateController.text.isNotEmpty &&
- cityController.text.isNotEmpty) {
- setState(() {
- isAllFieldsFilled = true;
- });
- } else {
- setState(() {
- isAllFieldsFilled = false;
- });
- }
- }
- @override
- Widget build(BuildContext context) {
- final screenHeight = MediaQuery.of(context).size.height;
- final screenWidth = MediaQuery.of(context).size.width;
- return Scaffold(
- appBar: commonAppBar(context, 'Fortune Telling'),
-
- body: Container(
- decoration: BoxDecoration(
- gradient: LinearGradient(
- colors: [Colors.green[100]!, Colors.white],
- begin: Alignment.topLeft,
- end: Alignment.bottomRight,
- ),
- ),
- padding: EdgeInsets.symmetric(
- horizontal: screenWidth * 0.08,
- vertical: screenHeight * 0.05,
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- // Birthday Section
- ListTile(
- title: Text('Birthday', style: TextStyle(fontSize: 18)),
- trailing: TextButton(
- child: Text('Select', style: TextStyle(color: Colors.green[800])),
- onPressed: () {
- showDatePicker(
- context: context,
- initialDate: DateTime.now(),
- firstDate: DateTime(1900),
- lastDate: DateTime(2100),
- );
- },
- ),
- ),
- SizedBox(height: screenHeight * 0.03),
- // Birth-time Section
- ListTile(
- title: Text('Birth-time', style: TextStyle(fontSize: 18)),
- trailing: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- _buildDropdownHour(),
- SizedBox(width: screenWidth * 0.02),
- _buildDropdownMinute(),
- ],
- ),
- ),
- SizedBox(height: screenHeight * 0.03),
- // Gender Section
- ListTile(
- title: Text('Gender', style: TextStyle(fontSize: 18)),
- trailing: _buildGenderDropdown(),
- ),
- SizedBox(height: screenHeight * 0.03),
- // Birth Place Section
- ListTile(
- title: Text('Birth Place', style: TextStyle(fontSize: 18)),
- ),
- _buildTextField(countryController, 'Country', (value) {
- checkFieldsFilled();
- }),
- SizedBox(height: screenHeight * 0.01),
- _buildTextField(stateController, 'State', (value) {
- checkFieldsFilled();
- }),
- SizedBox(height: screenHeight * 0.01),
- _buildTextField(cityController, 'City', (value) {
- checkFieldsFilled();
- }),
- SizedBox(height: screenHeight * 0.05),
- // Fortune Telling Button
- Center(
- child: ElevatedButton(
- style: ButtonStyle(
- backgroundColor: MaterialStateProperty.all(
- isAllFieldsFilled ? Colors.orange : Colors.grey,
- ),
- padding: MaterialStateProperty.all(EdgeInsets.symmetric(vertical: 15, horizontal: 30)),
- shape: MaterialStateProperty.all(RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(30),
- )),
- ),
- onPressed: isAllFieldsFilled
- ? () {
- // Implement your fortune telling logic here
- }
- : null,
- child: Text('Fortune Telling', style: TextStyle(fontSize: 18)),
- ),
- ),
- ],
- ),
- ),
- );
- }
- Widget _buildDropdownHour() {
- return DropdownButton<int>(
- hint: Text('hr'),
- value: selectedHour,
- items: List.generate(24, (index) {
- return DropdownMenuItem(
- value: index,
- child: Text(index.toString().padLeft(2, '0')),
- );
- }),
- onChanged: (value) {
- setState(() {
- selectedHour = value;
- });
- checkFieldsFilled();
- },
- );
- }
- Widget _buildDropdownMinute() {
- return DropdownButton<int>(
- hint: Text('min'),
- value: selectedMinute,
- items: List.generate(60, (index) {
- return DropdownMenuItem(
- value: index,
- child: Text(index.toString().padLeft(2, '0')),
- );
- }),
- onChanged: (value) {
- setState(() {
- selectedMinute = value;
- });
- checkFieldsFilled();
- },
- );
- }
- Widget _buildGenderDropdown() {
- return DropdownButton<String>(
- hint: Text('Select'),
- value: selectedGender,
- items: [
- DropdownMenuItem(value: 'Male', child: Text('Male')),
- DropdownMenuItem(value: 'Female', child: Text('Female')),
- DropdownMenuItem(value: 'Other', child: Text('Other')),
- ],
- onChanged: (value) {
- setState(() {
- selectedGender = value;
- });
- checkFieldsFilled();
- },
- );
- }
- Widget _buildTextField(TextEditingController controller, String hint, Function(String) onChanged) {
- return TextField(
- controller: controller,
- decoration: InputDecoration(
- hintText: hint,
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(30),
- ),
- filled: true,
- fillColor: Colors.white,
- ),
- onChanged: onChanged,
- );
- }
- }
- class ClickAndDrawPage extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: commonAppBar(context, 'Divination'),
- body: Container(
- decoration: BoxDecoration(
- image: DecorationImage(
- image: AssetImage('assets/抽签.gif'), // 确保您有这个GIF文件
- fit: BoxFit.cover,
- ),
- ),
- child: Padding(
- padding: EdgeInsets.only(top: 30.0),
- child: Align(
- alignment: Alignment.topCenter,
- child: ElevatedButton(
- onPressed: () {
- Navigator.push(
- context,
- MaterialPageRoute(builder: (context) => ResultPage()),
- );
- },
- child: Text(
- 'Click & Draw',
- style: TextStyle(fontSize: 20, color: Colors.white, fontWeight: FontWeight.bold),
- ),
- style: ElevatedButton.styleFrom(
- backgroundColor: Colors.orange.withOpacity(0.6),
- padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(30),
- ),
- ),
- ),
- ),
- ),
- ),
- );
- }
- }
- class ResultPage extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- final screenHeight = MediaQuery.of(context).size.height;
- final screenWidth = MediaQuery.of(context).size.width;
- return Scaffold(
- appBar: commonAppBar(context, 'Divination Result'),
- body: Container(
- padding: EdgeInsets.all(20),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Container(
- height: screenHeight * 0.6,
- width: screenWidth * 0.9,
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(20),
- boxShadow: [
- BoxShadow(
- color: Colors.grey.withOpacity(0.5),
- spreadRadius: 5,
- blurRadius: 7,
- offset: Offset(0, 3),
- ),
- ],
- ),
- padding: EdgeInsets.all(20),
- child: SingleChildScrollView(
- child: Text(
- 'Your divination result will be displayed here...',
- style: TextStyle(fontSize: 18),
- textAlign: TextAlign.center,
- ),
- ),
- ),
- SizedBox(height: 30),
- ElevatedButton(
- onPressed: () {
- // 这里添加更多详情的逻辑
- },
- child: Text(
- 'More Details',
- style: TextStyle(fontSize: 18, color: Colors.white, fontWeight: FontWeight.bold),
- ),
- style: ElevatedButton.styleFrom(
- backgroundColor: Colors.black,
- padding: EdgeInsets.symmetric(horizontal: 40, vertical: 15),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(30),
- ),
- ),
- ),
- ],
- ),
- ),
- );
- }
- }
- class DreamInterpretationScreen extends StatefulWidget {
- @override
- _DreamInterpretationScreenState createState() => _DreamInterpretationScreenState();
- }
- class _DreamInterpretationScreenState extends State<DreamInterpretationScreen> {
- int selectedIndex = -1;
- String selectedFilter = 'New';
- bool isTyping = false;
-
- final List<String> dreamObjects = [
- 'Teeth', 'Parents', 'Cats', 'Thunder', 'Frog', 'Rain', 'Sea', 'Flying', 'Chasing'
- ];
- List<String> userQuestions = [];
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: commonAppBar(context, 'Dream Interpretation'),
- body: Container(
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- colors: [Colors.blue[100]!, Colors.blue[900]!],
- ),
- ),
- child: Column(
- children: [
- Padding(
- padding: const EdgeInsets.all(16.0),
- child: Text(
- 'Let Zhou Gong interpret your dream',
- style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
- textAlign: TextAlign.center,
- ),
- ),
- // Dream objects wrap
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16.0),
- child: Container(
- width: MediaQuery.of(context).size.width * 0.85,
- child: Wrap(
- alignment: WrapAlignment.spaceEvenly,
- spacing: 8.0,
- runSpacing: 8.0,
- children: List.generate((dreamObjects.length / 3).ceil(), (rowIndex) {
- return Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: List.generate(3, (colIndex) {
- final index = rowIndex * 3 + colIndex;
- if (index >= dreamObjects.length) return SizedBox.shrink();
- return Expanded(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 4.0),
- child: GestureDetector(
- onTap: () {
- setState(() {
- selectedIndex = index;
- });
- },
- child: Container(
- padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(20),
- border: Border.all(
- color: selectedIndex == index ? Colors.blue : Colors.transparent,
- width: 2,
- ),
- ),
- child: Text(
- dreamObjects[index],
- style: TextStyle(
- color: Colors.blue,
- fontWeight: FontWeight.bold,
- ),
- textAlign: TextAlign.center,
- ),
- ),
- ),
- ),
- );
- }),
- );
- }).toList(),
- ),
- ),
- ),
- SizedBox(height: 16),
- // Content frame
- Expanded(
- child: Container(
- margin: EdgeInsets.fromLTRB(16, 0, 16, 16),
- decoration: BoxDecoration(
- color: Colors.white.withOpacity(0.1),
- borderRadius: BorderRadius.circular(20),
- ),
- child: Column(
- children: [
- // Filter buttons for "New" and "Hot"
- Padding(
- padding: const EdgeInsets.all(16.0),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- _buildFilterButton('New'),
- SizedBox(width: 16),
- _buildFilterButton('Hot'),
- ],
- ),
- ),
- // User content
- Expanded(
- child: ListView.builder(
- itemCount: userQuestions.length,
- itemBuilder: (context, index) {
- return Card(
- margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
- child: ListTile(
- title: Text(userQuestions[index]),
- trailing: ElevatedButton(
- onPressed: () {
- Navigator.push(
- context,
- MaterialPageRoute(builder: (context) => DreamResultPage()),
- );
- },
- child: Text('More', style: TextStyle(color: Colors.white)),
- style: ElevatedButton.styleFrom(
- backgroundColor: Colors.blue,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(20),
- ),
- ),
- ),
- ),
- );
- },
- ),
- ),
- ],
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(16.0),
- child: _buildInputField(),
- ),
- ],
- ),
- ),
- );
- }
- Widget _buildFilterButton(String label) {
- return ElevatedButton(
- onPressed: () {
- setState(() {
- selectedFilter = label;
- });
- },
- style: ElevatedButton.styleFrom(
- backgroundColor: selectedFilter == label ? Colors.blue[700] : Colors.blue[300],
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(20),
- ),
- ),
- child: Text(
- label,
- style: TextStyle(
- color: Colors.white,
- fontWeight: FontWeight.bold,
- ),
- ),
- );
- }
- Widget _buildInputField() {
- return TextField(
- onSubmitted: (value) {
- if (value.isNotEmpty) {
- setState(() {
- userQuestions.insert(0, "User: $value");
- });
- Navigator.push(
- context,
- MaterialPageRoute(builder: (context) => DreamResultPage()),
- );
- }
- },
- decoration: InputDecoration(
- hintText: 'Ask Zhou Gong Anything...',
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(25),
- ),
- fillColor: Colors.white,
- filled: true,
- suffixIcon: IconButton(
- icon: Icon(Icons.send),
- onPressed: () {
- Navigator.push(
- context,
- MaterialPageRoute(builder: (context) => DreamResultPage()),
- );
- },
- ),
- ),
- );
- }
- }
- class DreamResultPage extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- final screenHeight = MediaQuery.of(context).size.height;
- final screenWidth = MediaQuery.of(context).size.width;
- return Scaffold(
- appBar: commonAppBar(context, 'Dream Interpretation'),
- body: Container(
- padding: EdgeInsets.all(20),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Container(
- height: screenHeight * 0.6,
- width: screenWidth * 0.9,
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(20),
- boxShadow: [
- BoxShadow(
- color: Colors.grey.withOpacity(0.5),
- spreadRadius: 5,
- blurRadius: 7,
- offset: Offset(0, 3),
- ),
- ],
- ),
- padding: EdgeInsets.all(20),
- child: SingleChildScrollView(
- child: Text(
- 'Your dream interpretation result will be displayed here...',
- style: TextStyle(fontSize: 18),
- textAlign: TextAlign.center,
- ),
- ),
- ),
- SizedBox(height: 30),
- ElevatedButton(
- onPressed: () {
- // 这里添加更多详情的逻辑
- },
- child: Text(
- 'More Details',
- style: TextStyle(fontSize: 18, color: Colors.white, fontWeight: FontWeight.bold),
- ),
- style: ElevatedButton.styleFrom(
- backgroundColor: Colors.black,
- padding: EdgeInsets.symmetric(horizontal: 40, vertical: 15),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(30),
- ),
- ),
- ),
- ],
- ),
- ),
- );
- }
- }
|