Skip to content

Commit

Permalink
added custom title bar for desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
LAITH343 committed Oct 25, 2023
1 parent 559376e commit 357fde1
Show file tree
Hide file tree
Showing 27 changed files with 325 additions and 45 deletions.
4 changes: 4 additions & 0 deletions assets/close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion assets/l10n/app_ar.arb
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,9 @@
"deleteConfirmButton": "نعم",
"deleteCancelButton": "كلا",
"deleteSuccessMsg": "تم الحذف",
"deleteFailedMsg": "فشل الحذف"
"deleteFailedMsg": "فشل الحذف",
"titleBarCloseToolTip": "خروج",
"titleBarMinimizeTollTip": "تصغير",
"titleBarMaximizeToolTip": "تكبير",
"titleBarUNMaximizeToolTip": "الغاء التكبير"
}
6 changes: 5 additions & 1 deletion assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,9 @@
"deleteConfirmButton": "Yes",
"deleteCancelButton": "No",
"deleteSuccessMsg": "Deleted",
"deleteFailedMsg": "deleting failed"
"deleteFailedMsg": "deleting failed",
"titleBarCloseToolTip": "exit",
"titleBarMinimizeTollTip": "Minimize",
"titleBarMaximizeToolTip": "Maximize",
"titleBarUNMaximizeToolTip": "un Maximize"
}
4 changes: 4 additions & 0 deletions assets/maximize.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/minimize.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/un-maximize.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:exam_reminder/models/database.dart';
import 'package:exam_reminder/models/localizations_manager.dart';
import 'package:exam_reminder/models/theme_manager.dart';

const String appVersion = "1.0.1-beta";
const String appVersion = "1.0.2-beta";
const String appSourceCodeURL = "https://github.com/LAITH343/exam-reminder";

late DataBaseManager mainDB;
Expand Down
4 changes: 4 additions & 0 deletions lib/global_methods.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';

Expand Down Expand Up @@ -49,3 +51,5 @@ Future<bool> onSelectDatePressed(
return false;
}
}

bool isPlatformDesktop() => Platform.isLinux || Platform.isMacOS || Platform.isWindows;
24 changes: 24 additions & 0 deletions lib/localization/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,30 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'deleting failed'**
String get deleteFailedMsg;

/// No description provided for @titleBarCloseToolTip.
///
/// In en, this message translates to:
/// **'exit'**
String get titleBarCloseToolTip;

/// No description provided for @titleBarMinimizeTollTip.
///
/// In en, this message translates to:
/// **'Minimize'**
String get titleBarMinimizeTollTip;

/// No description provided for @titleBarMaximizeToolTip.
///
/// In en, this message translates to:
/// **'Maximize'**
String get titleBarMaximizeToolTip;

/// No description provided for @titleBarUNMaximizeToolTip.
///
/// In en, this message translates to:
/// **'un Maximize'**
String get titleBarUNMaximizeToolTip;
}

class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
Expand Down
12 changes: 12 additions & 0 deletions lib/localization/app_localizations_ar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,16 @@ class AppLocalizationsAr extends AppLocalizations {

@override
String get deleteFailedMsg => 'فشل الحذف';

@override
String get titleBarCloseToolTip => 'خروج';

@override
String get titleBarMinimizeTollTip => 'تصغير';

@override
String get titleBarMaximizeToolTip => 'تكبير';

@override
String get titleBarUNMaximizeToolTip => 'الغاء التكبير';
}
12 changes: 12 additions & 0 deletions lib/localization/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,16 @@ class AppLocalizationsEn extends AppLocalizations {

@override
String get deleteFailedMsg => 'deleting failed';

@override
String get titleBarCloseToolTip => 'exit';

@override
String get titleBarMinimizeTollTip => 'Minimize';

@override
String get titleBarMaximizeToolTip => 'Maximize';

@override
String get titleBarUNMaximizeToolTip => 'un Maximize';
}
18 changes: 18 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
import 'package:exam_reminder/constants.dart';
import 'package:exam_reminder/global_methods.dart';
import 'package:exam_reminder/localization/app_localizations.dart';
import 'package:exam_reminder/providers/exams.dart';
import 'package:exam_reminder/providers/updater.dart';
import 'package:exam_reminder/screens/splash/splash.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:provider/provider.dart';
import 'package:window_manager/window_manager.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await themeManager.init();
await localizationManager.init();
if (isPlatformDesktop()) {
await windowManager.ensureInitialized();

WindowOptions windowOptions = const WindowOptions(
size: Size(1280, 720),
minimumSize: Size(420, 280),
center: true,
backgroundColor: Colors.transparent,
skipTaskbar: false,
titleBarStyle: TitleBarStyle.hidden,
);
windowManager.waitUntilReadyToShow(windowOptions, () async {
await windowManager.show();
await windowManager.focus();
});
}
runApp(
MultiProvider(
providers: [
Expand Down
7 changes: 6 additions & 1 deletion lib/screens/add/add_exam.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:exam_reminder/widgets/text_field.dart';
import 'package:exam_reminder/providers/exams.dart';
import 'package:exam_reminder/screens/add/methods.dart';
import 'package:exam_reminder/types.dart';
import 'package:exam_reminder/widgets/title_bar.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

Expand All @@ -25,8 +26,12 @@ class _AddExamScreenState extends State<AddExamScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.deepPurple,
title: Text(AppLocalizations.of(context)!.appBarAddExam),
backgroundColor: Colors.deepPurple,
flexibleSpace: const TitleBarWindowDraggable(),
actions: const [
TitleBarButtons(),
],
),
body: Consumer<ExamsProvider>(
builder: (context, value, child) => Column(
Expand Down
7 changes: 6 additions & 1 deletion lib/screens/edit/edit_exam.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:exam_reminder/widgets/text_field.dart';
import 'package:exam_reminder/providers/exams.dart';
import 'package:exam_reminder/screens/edit/methods.dart';
import 'package:exam_reminder/types.dart';
import 'package:exam_reminder/widgets/title_bar.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

Expand Down Expand Up @@ -45,8 +46,12 @@ class _EditExamScreenState extends State<EditExamScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.deepPurple,
title: Text(AppLocalizations.of(context)!.appBarEditExam),
backgroundColor: Colors.deepPurple,
flexibleSpace: const TitleBarWindowDraggable(),
actions: const [
TitleBarButtons(),
],
),
body: Consumer<ExamsProvider>(
builder: (context, value, child) => Column(
Expand Down
16 changes: 14 additions & 2 deletions lib/screens/home/home.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'package:exam_reminder/localization/app_localizations.dart';
import 'package:exam_reminder/providers/exams.dart';
import 'package:exam_reminder/screens/add/add_exam.dart';
import 'package:exam_reminder/screens/home/src/appbar.dart';
import 'package:exam_reminder/screens/home/src/tabs.dart';
import 'package:exam_reminder/screens/home/src/body.dart';
import 'package:exam_reminder/screens/home/src/drawer.dart';
import 'package:exam_reminder/widgets/title_bar.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

Expand All @@ -16,7 +18,17 @@ class HomeScreen extends StatelessWidget {
length: value.length(),
child: Scaffold(
drawer: const HomeScreenDrawer(),
appBar: generateHomeAppBar(value, context),
appBar: AppBar(
bottom: getTabBar(value, context),
title: TitleBarWindowDraggable(
child: Text(AppLocalizations.of(context)!.appBarHome),
),
backgroundColor: Colors.deepPurple,
flexibleSpace: const TitleBarWindowDraggable(),
actions: const [
TitleBarButtons(),
],
),
body: HomeScreenBody(
value: value,
),
Expand Down
23 changes: 0 additions & 23 deletions lib/screens/home/src/appbar.dart

This file was deleted.

18 changes: 18 additions & 0 deletions lib/screens/home/src/tabs.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:exam_reminder/providers/exams.dart';
import 'package:exam_reminder/screens/home/methods.dart';
import 'package:flutter/material.dart';

TabBar? getTabBar(ExamsProvider value, BuildContext context) {
return value.length() == 0
? null
: TabBar(
indicatorWeight: 3.0,
isScrollable: true,
tabAlignment: TabAlignment.center,
tabs: value.dates
.map((e) => Padding(
padding: const EdgeInsets.all(8.0),
child: Text(parseDate(e, context))))
.toList(),
);
}
6 changes: 6 additions & 0 deletions lib/screens/settings/settings.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:exam_reminder/localization/app_localizations.dart';
import 'package:exam_reminder/screens/settings/src/locale_selector.dart';
import 'package:exam_reminder/screens/settings/src/theme_selector.dart';
import 'package:exam_reminder/widgets/title_bar.dart';
import 'package:flutter/material.dart';

class SettingsScreen extends StatelessWidget {
Expand All @@ -11,6 +12,11 @@ class SettingsScreen extends StatelessWidget {
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context)!.appBarSettings),
backgroundColor: Colors.deepPurple,
flexibleSpace: const TitleBarWindowDraggable(),
actions: const [
TitleBarButtons(),
],
),
body: const Column(
children: [
Expand Down
22 changes: 9 additions & 13 deletions lib/screens/welcome/welcome.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:exam_reminder/screens/home/home.dart';
import 'package:exam_reminder/screens/settings/src/locale_selector.dart';
import 'package:exam_reminder/screens/settings/src/theme_selector.dart';
import 'package:exam_reminder/screens/welcome/methods.dart';
import 'package:exam_reminder/widgets/title_bar.dart';
import 'package:flutter/material.dart';

class WelcomeScreen extends StatelessWidget {
Expand All @@ -12,25 +13,20 @@ class WelcomeScreen extends StatelessWidget {
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context)!.welcomeTitle),
flexibleSpace: const TitleBarWindowDraggable(),
actions: const [
TitleBarButtons(),
],
centerTitle: true,
),
body: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: width,
child: Text(
AppLocalizations.of(context)!.welcomeTitle,
style: Theme.of(context).textTheme.headlineSmall,
textAlign: TextAlign.center,
),
),
],
),
Padding(
padding: const EdgeInsets.only(top: 10),
child: Row(
Expand Down
Loading

0 comments on commit 357fde1

Please sign in to comment.