-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move invocation code to service.dart
- Loading branch information
Showing
2 changed files
with
84 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,125 +1,92 @@ | ||
// The original content is temporarily commented out to allow generating a self-contained demo - feel free to uncomment later. | ||
|
||
// import 'package:flutter/material.dart'; | ||
// import 'package:qb_mobile/service.dart'; | ||
// | ||
// void main() async { | ||
// WidgetsFlutterBinding.ensureInitialized(); | ||
// print("kekw"); | ||
// await initializeService(); | ||
// | ||
// runApp(const QuixByteApp()); | ||
// } | ||
// | ||
// class QuixByteApp extends StatelessWidget { | ||
// const QuixByteApp({super.key}); | ||
// | ||
// // This widget is the root of your application. | ||
// @override | ||
// Widget build(BuildContext context) { | ||
// return MaterialApp( | ||
// title: 'QuixByte Mobile', | ||
// theme: ThemeData( | ||
// // This is the theme of your application. | ||
// // | ||
// // TRY THIS: Try running your application with "flutter run". You'll see | ||
// // the application has a purple toolbar. Then, without quitting the app, | ||
// // try changing the seedColor in the colorScheme below to Colors.green | ||
// // and then invoke "hot reload" (save your changes or press the "hot | ||
// // reload" button in a Flutter-supported IDE, or press "r" if you used | ||
// // the command line to start the app). | ||
// // | ||
// // Notice that the counter didn't reset back to zero; the application | ||
// // state is not lost during the reload. To reset the state, use hot | ||
// // restart instead. | ||
// // | ||
// // This works for code too, not just values: Most code changes can be | ||
// // tested with just a hot reload. | ||
// colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), | ||
// useMaterial3: true, | ||
// ), | ||
// home: const QuixByteHomePage(), | ||
// ); | ||
// } | ||
// } | ||
// | ||
// class QuixByteHomePage extends StatelessWidget { | ||
// const QuixByteHomePage({super.key}); | ||
// | ||
// @override | ||
// Widget build(BuildContext context) { | ||
// // This method is rerun every time setState is called, for instance as done | ||
// // by the _incrementCounter method above. | ||
// // | ||
// // The Flutter framework has been optimized to make rerunning build methods | ||
// // fast, so that you can just rebuild anything that needs updating rather | ||
// // than having to individually change instances of widgets. | ||
// return Scaffold( | ||
// appBar: AppBar( | ||
// // TRY THIS: Try changing the color here to a specific color (to | ||
// // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar | ||
// // change color while the other colors stay the same. | ||
// backgroundColor: Theme.of(context).colorScheme.inversePrimary, | ||
// // Here we take the value from the MyHomePage object that was created by | ||
// // the App.build method, and use it to set our appbar title. | ||
// title: const Text("QuixByte Mobile"), | ||
// ), | ||
// body: Center( | ||
// // Center is a layout widget. It takes a single child and positions it | ||
// // in the middle of the parent. | ||
// child: Column( | ||
// // Column is also a layout widget. It takes a list of children and | ||
// // arranges them vertically. By default, it sizes itself to fit its | ||
// // children horizontally, and tries to be as tall as its parent. | ||
// // | ||
// // Column has various properties to control how it sizes itself and | ||
// // how it positions its children. Here we use mainAxisAlignment to | ||
// // center the children vertically; the main axis here is the vertical | ||
// // axis because Columns are vertical (the cross axis would be | ||
// // horizontal). | ||
// // | ||
// // TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint" | ||
// // action in the IDE, or press "p" in the console), to see the | ||
// // wireframe for each widget. | ||
// mainAxisAlignment: MainAxisAlignment.center, | ||
// children: <Widget>[ | ||
// FilledButton(onPressed: () {}, child: const Text("Settings")), | ||
// FilledButton(onPressed: () {}, child: const Text("Manage")), | ||
// FilledButton(onPressed: () {}, child: const Text("View Files")), | ||
// ], | ||
// ), | ||
// ), | ||
// ); | ||
// } | ||
// } | ||
// | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:path_provider/path_provider.dart'; | ||
import 'package:qb_mobile/src/rust/api/daemon.dart'; | ||
import 'package:qb_mobile/src/rust/frb_generated.dart'; | ||
import 'package:qb_mobile/service.dart'; | ||
|
||
Future<void> main() async { | ||
await RustLib.init(); | ||
final dir = await getApplicationDocumentsDirectory(); | ||
final daemon = await DaemonWrapper.init(path: '$dir'); | ||
print(daemon); | ||
runApp(const MyApp()); | ||
void main() async { | ||
WidgetsFlutterBinding.ensureInitialized(); | ||
await initializeService(); | ||
|
||
runApp(const QuixByteApp()); | ||
} | ||
|
||
class MyApp extends StatelessWidget { | ||
const MyApp({super.key}); | ||
class QuixByteApp extends StatelessWidget { | ||
const QuixByteApp({super.key}); | ||
|
||
// This widget is the root of your application. | ||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
home: Scaffold( | ||
appBar: AppBar(title: const Text('flutter_rust_bridge quickstart')), | ||
body: Center( | ||
child: Text( | ||
'Action: Call Rust `greet("Tom")`\nResult:`'), | ||
title: 'QuixByte Mobile', | ||
theme: ThemeData( | ||
// This is the theme of your application. | ||
// | ||
// TRY THIS: Try running your application with "flutter run". You'll see | ||
// the application has a purple toolbar. Then, without quitting the app, | ||
// try changing the seedColor in the colorScheme below to Colors.green | ||
// and then invoke "hot reload" (save your changes or press the "hot | ||
// reload" button in a Flutter-supported IDE, or press "r" if you used | ||
// the command line to start the app). | ||
// | ||
// Notice that the counter didn't reset back to zero; the application | ||
// state is not lost during the reload. To reset the state, use hot | ||
// restart instead. | ||
// | ||
// This works for code too, not just values: Most code changes can be | ||
// tested with just a hot reload. | ||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), | ||
useMaterial3: true, | ||
), | ||
home: const QuixByteHomePage(), | ||
); | ||
} | ||
} | ||
|
||
class QuixByteHomePage extends StatelessWidget { | ||
const QuixByteHomePage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
// This method is rerun every time setState is called, for instance as done | ||
// by the _incrementCounter method above. | ||
// | ||
// The Flutter framework has been optimized to make rerunning build methods | ||
// fast, so that you can just rebuild anything that needs updating rather | ||
// than having to individually change instances of widgets. | ||
return Scaffold( | ||
appBar: AppBar( | ||
// TRY THIS: Try changing the color here to a specific color (to | ||
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar | ||
// change color while the other colors stay the same. | ||
backgroundColor: Theme.of(context).colorScheme.inversePrimary, | ||
// Here we take the value from the MyHomePage object that was created by | ||
// the App.build method, and use it to set our appbar title. | ||
title: const Text("QuixByte Mobile"), | ||
), | ||
body: Center( | ||
// Center is a layout widget. It takes a single child and positions it | ||
// in the middle of the parent. | ||
child: Column( | ||
// Column is also a layout widget. It takes a list of children and | ||
// arranges them vertically. By default, it sizes itself to fit its | ||
// children horizontally, and tries to be as tall as its parent. | ||
// | ||
// Column has various properties to control how it sizes itself and | ||
// how it positions its children. Here we use mainAxisAlignment to | ||
// center the children vertically; the main axis here is the vertical | ||
// axis because Columns are vertical (the cross axis would be | ||
// horizontal). | ||
// | ||
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint" | ||
// action in the IDE, or press "p" in the console), to see the | ||
// wireframe for each widget. | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: <Widget>[ | ||
FilledButton(onPressed: () {}, child: const Text("Settings")), | ||
FilledButton(onPressed: () {}, child: const Text("Manage")), | ||
FilledButton(onPressed: () {}, child: const Text("View Files")), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters