|
1 |
| -import 'package:appwrite_flutter_starter_kit/data/models/log.dart'; |
2 |
| -import 'package:appwrite_flutter_starter_kit/data/models/status.dart'; |
3 |
| -import 'package:appwrite_flutter_starter_kit/data/repository/appwrite_repository.dart'; |
4 |
| -import 'package:appwrite_flutter_starter_kit/ui/components/checkered_background.dart'; |
5 |
| -import 'package:appwrite_flutter_starter_kit/ui/components/collapsible_bottomsheet.dart'; |
6 |
| -import 'package:appwrite_flutter_starter_kit/ui/components/connection_status_view.dart'; |
7 |
| -import 'package:appwrite_flutter_starter_kit/ui/components/getting_started_cards.dart'; |
8 |
| -import 'package:appwrite_flutter_starter_kit/ui/components/top_platform_view.dart'; |
| 1 | +import 'package:appwrite_flutter_starter_kit/app.dart'; |
9 | 2 | import 'package:appwrite_flutter_starter_kit/utils/app_initializer.dart';
|
10 |
| -import 'package:appwrite_flutter_starter_kit/utils/extensions/build_context.dart'; |
11 | 3 | import 'package:flutter/material.dart';
|
12 | 4 |
|
13 | 5 | void main() async {
|
14 | 6 | await AppInitializer.initialize();
|
15 | 7 | runApp(AppwriteApp());
|
16 | 8 | }
|
17 |
| - |
18 |
| -class AppwriteApp extends StatelessWidget { |
19 |
| - const AppwriteApp({super.key}); |
20 |
| - |
21 |
| - @override |
22 |
| - Widget build(BuildContext context) { |
23 |
| - return MaterialApp( |
24 |
| - title: 'Appwrite StarterKit', |
25 |
| - debugShowCheckedModeBanner: false, |
26 |
| - theme: ThemeData( |
27 |
| - useMaterial3: true, |
28 |
| - colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), |
29 |
| - ), |
30 |
| - home: const AppwriteStarterKit(), |
31 |
| - ); |
32 |
| - } |
33 |
| -} |
34 |
| - |
35 |
| -class AppwriteStarterKit extends StatefulWidget { |
36 |
| - const AppwriteStarterKit({super.key}); |
37 |
| - |
38 |
| - @override |
39 |
| - State<AppwriteStarterKit> createState() => _AppwriteStarterKit(); |
40 |
| -} |
41 |
| - |
42 |
| -class _AppwriteStarterKit extends State<AppwriteStarterKit> { |
43 |
| - final List<Log> _logs = []; |
44 |
| - Status _status = Status.idle; |
45 |
| - final AppwriteRepository _repository = AppwriteRepository(); |
46 |
| - |
47 |
| - @override |
48 |
| - Widget build(BuildContext context) { |
49 |
| - return Scaffold( |
50 |
| - body: CheckeredBackground( |
51 |
| - child: SafeArea( |
52 |
| - minimum: EdgeInsets.only(top: context.isLargeScreen ? 24 : 16), |
53 |
| - child: Stack( |
54 |
| - children: [ |
55 |
| - SingleChildScrollView( |
56 |
| - child: Column( |
57 |
| - spacing: 16, |
58 |
| - children: [ |
59 |
| - TopPlatformView(status: _status), |
60 |
| - ConnectionStatusView( |
61 |
| - status: _status, |
62 |
| - onButtonClick: () async { |
63 |
| - setState(() => _status = Status.loading); |
64 |
| - final log = await _repository.ping(); |
65 |
| - _logs.add(log); |
66 |
| - |
67 |
| - await Future.delayed( |
68 |
| - const Duration(milliseconds: 1250), |
69 |
| - ); |
70 |
| - |
71 |
| - setState( |
72 |
| - () => _status = |
73 |
| - (200 <= log.status && log.status <= 399) |
74 |
| - ? Status.success |
75 |
| - : Status.error, |
76 |
| - ); |
77 |
| - }, |
78 |
| - ), |
79 |
| - GettingStartedCards() |
80 |
| - ], |
81 |
| - ), |
82 |
| - ), |
83 |
| - |
84 |
| - // bottomsheet |
85 |
| - Align( |
86 |
| - alignment: Alignment.bottomCenter, |
87 |
| - child: CollapsibleBottomSheet( |
88 |
| - logs: _logs, |
89 |
| - projectInfo: _repository.getProjectInfo(), |
90 |
| - ), |
91 |
| - ), |
92 |
| - ], |
93 |
| - ), |
94 |
| - ), |
95 |
| - ), |
96 |
| - ); |
97 |
| - } |
98 |
| -} |
0 commit comments