#walletconnect

import os

import zipfile

# Re-create the folder structure after state reset

project_root = '/mnt/data/FanbookReady'

lib_dir = os.path.join(project_root, 'lib')

android_app_dir = os.path.join(project_root, 'android', 'app')

os.makedirs(lib_dir, exist_ok=True)

os.makedirs(android_app_dir, exist_ok=True)

# pubspec.yaml content

pubspec_content = """

name: fanbook

description: A new Flutter project for Fanbook.

publish_to: 'none'

environment:

sdk: ">=3.1.0 <4.0.0"

dependencies:

flutter:

sdk: flutter

firebase_core: ^2.30.0

firebase_auth: ^4.18.0

dev_dependencies:

flutter_test:

sdk: flutter

flutter:

uses-material-design: true

"""

# Root build.gradle content

build_gradle_root_content = """

buildscript {

dependencies {

classpath 'com.google.gms:google-services:4.4.0'

}

}

"""

# App-level build.gradle content

build_gradle_app_content = """

apply plugin: 'com.android.application'

apply plugin: 'com.google.gms.google-services'

android {

compileSdkVersion 33

defaultConfig {

applicationId "com.example.fanbook"

minSdkVersion 21

targetSdkVersion 33

versionCode 1

versionName "1.0"

}

}

dependencies {

implementation platform('com.google.firebase:firebase-bom:32.7.2')

}

"""

# main.dart file content

main_dart_content = """

import 'package:flutter/material.dart';

import 'package:firebase_core/firebase_core.dart';

import 'package:firebase_auth/firebase_auth.dart';

void main() async {

WidgetsFlutterBinding.ensureInitialized();

await Firebase.initializeApp();

runApp(FanbookApp());

}

class FanbookApp extends StatelessWidget {

@override

Widget build(BuildContext context) {

return MaterialApp(

title: 'Fanbook',

theme: ThemeData(

primarySwatch: Colors.green,

),

home: LoginPage(),

);

}

}

class LoginPage extends StatelessWidget {

final emailController = TextEditingController();

final passwordController = TextEditingController();

@override

Widget build(BuildContext context) {

return Scaffold(

appBar: AppBar(title: Text("Fanbook Login")),

body: Padding(

padding: EdgeInsets.all(20),

child: Column(

mainAxisAlignment: MainAxisAlignment.center,

children: [

Text("Welcome to Fanbook", style: TextStyle(fontSize: 22)),

TextField(

controller: emailController,

decoration: InputDecoration(labelText: "Email"),

),

TextField(

controller: passwordController,

obscureText: true,

decoration: InputDecoration(labelText: "Password"),

),

SizedBox(height: 20),

ElevatedButton(

onPressed: () async {

try {

await FirebaseAuth.instance.signInWithEmailAndPassword(

email: emailController.text.trim(),

password: passwordController.text.trim(),

);

ScaffoldMessenger.of(context).showSnackBar(

SnackBar(content: Text("Login successful!")),

);

} catch (e) {

ScaffoldMessenger.of(context).showSnackBar(

SnackBar(content: Text("Login failed: ${e.toString()}")),

);

}

},

child: Text("Login"),

),

TextButton(

onPressed: () {

Navigator.push(context,

MaterialPageRoute(builder: (_) => SignupPage()));

},

child: Text("No account? Sign up"),

),

],

),

),

);

}

}

class SignupPage extends StatelessWidget {

final emailController = TextEditingController();

final passwordController = TextEditingController();

final confirmPasswordController = TextEditingController();

@override

Widget build(BuildContext context) {

return Scaffold(

appBar: AppBar(title: Text("Fanbook Signup")),

body: Padding(

padding: EdgeInsets.all(20),

child: Column(

mainAxisAlignment: MainAxisAlignment.center,

children: [

Text("Create Fanbook Account", style: TextStyle(fontSize: 22)),

TextField(

controller: emailController,

decoration: InputDecoration(labelText: "Email"),

),

TextField(

controller: passwordController,

obscureText: true,

decoration: InputDecoration(labelText: "Password"),

),

TextField(

controller: confirmPasswordController,

obscureText: true,

decoration: InputDecoration(labelText: "Confirm Password"),

),

SizedBox(height: 20),

ElevatedButton(

onPressed: () async {

if (passwordController.text != confirmPasswordController.text) {

ScaffoldMessenger.of(context).showSnackBar(

SnackBar(content: Text("Passwords do not match!")),

);

return;

}

try {

await FirebaseAuth.instance.createUserWithEmailAndPassword(

email: emailController.text.trim(),

password: passwordController.text.trim(),

);

ScaffoldMessenger.of(context).showSnackBar(

SnackBar(content: Text("Signup successful!")),

);

Navigator.pop(context);

} catch (e) {

ScaffoldMessenger.of(context).showSnackBar(

SnackBar(content: Text("Signup failed: ${e.toString()}")),

);

}

},

child: Text("Sign Up"),

),

],

),

),

);

}

}

"""

# Write files

with open(os.path.join(project_root, 'pubspec.yaml'), 'w') as f:

f.write(pubspec_content)

with open(os.path.join(project_root, 'android', 'build.gradle'), 'w') as f:

f.write(build_gradle_root_content)

with open(os.path.join(android_app_dir, 'build.gradle'), 'w') as f:

f.write(build_gradle_app_content)

with open(os.path.join(lib_dir, 'main.dart'), 'w') as f:

f.write(main_dart_content)

# Zip the project folder

zip_path = '/mnt/data/FanbookReady.zip'

with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zipf:

for root, _, files in os.walk(project_root):

for file in files:

file_path = os.path.join(root, file)

arcname = os.path.relpath(file_path, project_root)

zipf.write(file_path, arcname)

zip_path