Skip to content

desktop and large screen optimizations #496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 60 additions & 22 deletions lib/app/modules/home/views/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import 'package:taskwarrior/app/utils/home_path/home_path.dart' as rc;
import '../controllers/home_controller.dart';

class HomeView extends GetView<HomeController> {
static const double _largeScreenBreakpoint = 800.0;

const HomeView({super.key});
@override
Widget build(BuildContext context) {
Expand All @@ -34,29 +36,65 @@ class HomeView extends GetView<HomeController> {
controller.checkForSync(context);

return Obx(
() => Scaffold(
appBar: HomePageAppBar(
server: server,
credentials: credentials,
controller: controller,
),
backgroundColor: controller.isDarkModeOn.value
? TaskWarriorColors.kprimaryBackgroundColor
: TaskWarriorColors.kLightPrimaryBackgroundColor,
drawer: NavDrawer(homeController: controller),
body: HomePageBody(
controller: controller,
),
endDrawer: Obx(
() => FilterDrawer(
filters: controller.getFilters(),
homeController: controller,
() {
// Get the current screen width
final screenWidth = MediaQuery.of(context).size.width;
final bool isLargeScreen = screenWidth >= _largeScreenBreakpoint;

return Scaffold(
appBar: HomePageAppBar(
server: server,
credentials: credentials,
controller: controller,
),
),
floatingActionButton:
HomePageFloatingActionButton(controller: controller),
resizeToAvoidBottomInset: false,
),
backgroundColor: controller.isDarkModeOn.value
? TaskWarriorColors.kprimaryBackgroundColor
: TaskWarriorColors.kLightPrimaryBackgroundColor,
// Only show default Scaffold drawer/endDrawer on small screens
drawer: isLargeScreen ? null : NavDrawer(homeController: controller),
endDrawer: isLargeScreen
? null
: Obx(
() => FilterDrawer(
filters: controller.getFilters(),
homeController: controller,
),
),
body: isLargeScreen
? Row(
children: [
// Static Drawer
SizedBox(
width: 250, // Adjust width as needed for your drawer
child: NavDrawer(homeController: controller),
),
// Main content takes remaining space
Expanded(
child: HomePageBody(
controller: controller,
),
),
// Static End Drawer
SizedBox(
width: 250, // Adjust width as needed for your end drawer
child: Obx(
() => FilterDrawer(
filters: controller.getFilters(),
homeController: controller,
),
),
),
],
)
: HomePageBody(
// Regular body for small screens
controller: controller,
),
floatingActionButton:
HomePageFloatingActionButton(controller: controller),
resizeToAvoidBottomInset: false,
);
},
);
}
}
8 changes: 8 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:get/get.dart';
import 'package:taskwarrior/app/utils/app_settings/app_settings.dart';
import 'package:taskwarrior/app/utils/debug_logger/log_databse_helper.dart';
Expand All @@ -10,6 +13,11 @@ import 'app/routes/app_pages.dart';
LogDatabaseHelper _logDatabaseHelper = LogDatabaseHelper();

void main() async {
if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) {
sqfliteFfiInit();
databaseFactory = databaseFactoryFfi;
}

debugPrint = (String? message, {int? wrapWidth}) {
if (message != null) {
debugPrintSynchronously(message, wrapWidth: wrapWidth);
Expand Down