Skip to content

Commit fc5148d

Browse files
committed
desktop optimization
1 parent 7f19fcb commit fc5148d

File tree

2 files changed

+68
-22
lines changed

2 files changed

+68
-22
lines changed

lib/app/modules/home/views/home_view.dart

Lines changed: 60 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import 'package:taskwarrior/app/utils/home_path/home_path.dart' as rc;
1414
import '../controllers/home_controller.dart';
1515

1616
class HomeView extends GetView<HomeController> {
17+
static const double _largeScreenBreakpoint = 800.0;
18+
1719
const HomeView({super.key});
1820
@override
1921
Widget build(BuildContext context) {
@@ -34,29 +36,65 @@ class HomeView extends GetView<HomeController> {
3436
controller.checkForSync(context);
3537

3638
return Obx(
37-
() => Scaffold(
38-
appBar: HomePageAppBar(
39-
server: server,
40-
credentials: credentials,
41-
controller: controller,
42-
),
43-
backgroundColor: controller.isDarkModeOn.value
44-
? TaskWarriorColors.kprimaryBackgroundColor
45-
: TaskWarriorColors.kLightPrimaryBackgroundColor,
46-
drawer: NavDrawer(homeController: controller),
47-
body: HomePageBody(
48-
controller: controller,
49-
),
50-
endDrawer: Obx(
51-
() => FilterDrawer(
52-
filters: controller.getFilters(),
53-
homeController: controller,
39+
() {
40+
// Get the current screen width
41+
final screenWidth = MediaQuery.of(context).size.width;
42+
final bool isLargeScreen = screenWidth >= _largeScreenBreakpoint;
43+
44+
return Scaffold(
45+
appBar: HomePageAppBar(
46+
server: server,
47+
credentials: credentials,
48+
controller: controller,
5449
),
55-
),
56-
floatingActionButton:
57-
HomePageFloatingActionButton(controller: controller),
58-
resizeToAvoidBottomInset: false,
59-
),
50+
backgroundColor: controller.isDarkModeOn.value
51+
? TaskWarriorColors.kprimaryBackgroundColor
52+
: TaskWarriorColors.kLightPrimaryBackgroundColor,
53+
// Only show default Scaffold drawer/endDrawer on small screens
54+
drawer: isLargeScreen ? null : NavDrawer(homeController: controller),
55+
endDrawer: isLargeScreen
56+
? null
57+
: Obx(
58+
() => FilterDrawer(
59+
filters: controller.getFilters(),
60+
homeController: controller,
61+
),
62+
),
63+
body: isLargeScreen
64+
? Row(
65+
children: [
66+
// Static Drawer
67+
SizedBox(
68+
width: 250, // Adjust width as needed for your drawer
69+
child: NavDrawer(homeController: controller),
70+
),
71+
// Main content takes remaining space
72+
Expanded(
73+
child: HomePageBody(
74+
controller: controller,
75+
),
76+
),
77+
// Static End Drawer
78+
SizedBox(
79+
width: 250, // Adjust width as needed for your end drawer
80+
child: Obx(
81+
() => FilterDrawer(
82+
filters: controller.getFilters(),
83+
homeController: controller,
84+
),
85+
),
86+
),
87+
],
88+
)
89+
: HomePageBody(
90+
// Regular body for small screens
91+
controller: controller,
92+
),
93+
floatingActionButton:
94+
HomePageFloatingActionButton(controller: controller),
95+
resizeToAvoidBottomInset: false,
96+
);
97+
},
6098
);
6199
}
62100
}

lib/main.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import 'dart:io';
2+
13
import 'package:flutter/foundation.dart';
24
import 'package:flutter/material.dart';
5+
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
36
import 'package:get/get.dart';
47
import 'package:taskwarrior/app/utils/app_settings/app_settings.dart';
58
import 'package:taskwarrior/app/utils/debug_logger/log_databse_helper.dart';
@@ -10,6 +13,11 @@ import 'app/routes/app_pages.dart';
1013
LogDatabaseHelper _logDatabaseHelper = LogDatabaseHelper();
1114

1215
void main() async {
16+
if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) {
17+
sqfliteFfiInit();
18+
databaseFactory = databaseFactoryFfi;
19+
}
20+
1321
debugPrint = (String? message, {int? wrapWidth}) {
1422
if (message != null) {
1523
debugPrintSynchronously(message, wrapWidth: wrapWidth);

0 commit comments

Comments
 (0)