Skip to content

Commit

Permalink
Update copyright and text editor view
Browse files Browse the repository at this point in the history
  • Loading branch information
tseli0s committed Jan 2, 2024
1 parent 1035f14 commit af21265
Show file tree
Hide file tree
Showing 13 changed files with 375 additions and 113 deletions.
2 changes: 1 addition & 1 deletion lib/config.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* FlText: A simple and nice-looking text editor.
* Copyright (C) 2023 Aggelos Tselios
* Copyright (C) 2023-2024 Aggelos Tselios
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion lib/custom_text_styles.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* FlText: A simple and nice-looking text editor.
* Copyright (C) 2023 Aggelos Tselios
* Copyright (C) 2023-2024 Aggelos Tselios
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
42 changes: 42 additions & 0 deletions lib/l10n/app_fi.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"@@locale": "fi",
"settings": "Vettopwo",
"aboutFltext": "Lwo FlTexte...",
"fltextDesc": "FlTexte sal pykettet, nawirende sotscenenjottop nirutgo Edartseg pe Flutter, jokoguvobe sexegtota wininde byrakuvobe nekepe.",
"githubRepo": "GitHub Repositori",
"welcomeToFltext": "Kenn wippetu Efltextseke",
"startByEither": "Apeltäptua joc...",
"creatingAFile": "Ageppetua sal verfäil...",
"or": "jocett...",
"selectAFile": "Mäpxe sal fäil...",
"tooManyFilesSelected": "äää",
"tooManyFilesSelected_t": "äää",
"openAnExistingFile": "Ajextua sal everfäilnde",
"newFile": "Ageppetua verfäil...",
"close": "Gowap",
"beginTypingYourTextHere": "Apeltäptua aniruttuhepa sotscenenetu kipp...",
"loading": "Jukk...",
"errorWhileLoadingFile": "Ekennende jukkopseg fäile!",
"thereWasAnErrorLoadingFile": "There was an error while loading the file: ",
"editFile": "Jotopp fäildene",
"saveFileAt": "Äðeðmogtua fäile wä...",
"operationCancelled": "Operation Cancelled",
"noFileWasSelected": "No filename was selected, possibly because you cancelled the operation (Went back or closed the window). Try again.",
"editorFont": "Editor font",
"editorFont_t": "Set the font used by the text editor. By default, the system font is used.",
"saveSuccess": "Saved succesfully.",
"warning": "Warning",
"androidWarning": "On Android, you won't get a dialog to save the file because it's unsupported by the libraries we use. When you create a new file, you should get a dialog to enter the filename on Android. We know this is frustrating, and we apologize for any extra effort.",
"selectColor": "Select color",
"selectColorShade": "Select color shade",
"selectedColorAndShades": "Selected color and its shades",
"colorScheme": "Color scheme",
"selectColorSchemeUsed": "Select the color scheme used by the application",
"recents": "Nenytte",
"unableToOpenURL": "Unable to open URL",
"anUnknownErrorOccured_URL": "An unknown error occured while attempting to open the URL requested.",
"pleaseEnterFilename": "Please enter the filename for your new text file here. It will be saved in your documents directory on Android/Fuschia. (No extension is added automatically!)",
"filenameTitle": "Enter filename...",
"errorCreatingNewFile": "Error while creating new file",
"cancel": "Dnep"
}
42 changes: 42 additions & 0 deletions lib/l10n/app_hu.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"@@locale": "hu",
"settings": "Balitaasok",
"aboutFltext": "Szetika mi to Fltext...",
"fltextDesc": "FlText is a blazingly fast, lightweight text editor written in Dart using Flutter, designed to maintain usability without giving away on looks.",
"githubRepo": "GitHub Repository",
"welcomeToFltext": "Dzso repat eis to FlText",
"startByEither": "Arisztie eite...",
"creatingAFile": "Ipeiate en' akta...",
"or": "eidallos...",
"selectAFile": "Ivalastate en' akta...",
"tooManyFilesSelected": "Nagyÿk kaktak ivalastan!",
"tooManyFilesSelected_t": "Nagyÿk kaktak ivalastan. To FlText dÿnattei na enichsei mÿnasza en' akta ana fora ecs tora. Kelme na epilechste mÿnasza en' akta ecs epechsergasian.",
"openAnExistingFile": "Enichstie en' yfistamena akta...",
"newFile": "Neu akta...",
"close": "Csukninn",
"beginTypingYourTextHere": "Arisztie na irite to keimena sei dotte...",
"loading": "Fortosi...",
"errorWhileLoadingFile": "Szfalma eis fortosi c' aktas",
"thereWasAnErrorLoadingFile": "There was an error while loading the file: ",
"editFile": "Epechsergasia c' keimenos",
"saveFileAt": "Save file at...",
"operationCancelled": "Operation Cancelled",
"noFileWasSelected": "No filename was selected, possibly because you cancelled the operation (Went back or closed the window). Try again.",
"editorFont": "Editor font",
"editorFont_t": "Set the font used by the text editor. By default, the system font is used.",
"saveSuccess": "Saved succesfully.",
"warning": "Warning",
"androidWarning": "On Android, you won't get a dialog to save the file because it's unsupported by the libraries we use. When you create a new file, you should get a dialog to enter the filename on Android. We know this is frustrating, and we apologize for any extra effort.",
"selectColor": "Select color",
"selectColorShade": "Select color shade",
"selectedColorAndShades": "Selected color and its shades",
"colorScheme": "Color scheme",
"selectColorSchemeUsed": "Select the color scheme used by the application",
"recents": "Praszfatak",
"unableToOpenURL": "Unable to open URL",
"anUnknownErrorOccured_URL": "An unknown error occured while attempting to open the URL requested.",
"pleaseEnterFilename": "Please enter the filename for your new text file here. It will be saved in your documents directory on Android/Fuschia. (No extension is added automatically!)",
"filenameTitle": "Enter filename...",
"errorCreatingNewFile": "Error while creating new file",
"cancel": "Akerro"
}
49 changes: 4 additions & 45 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* FlText: A simple and nice-looking text editor.
* Copyright (C) 2023 Aggelos Tselios
* Copyright (C) 2023-2024 Aggelos Tselios
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -15,13 +15,12 @@ import 'package:file_picker/file_picker.dart';
import 'package:fltext/custom_text_styles.dart';
import 'package:fltext/settings_screen.dart';
import 'package:fltext/single_line_input.dart';
import 'package:fltext/text_edit.dart';
import 'package:fltext/tabbed_text_editor.dart';
import 'package:fltext/utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:fltext/config.dart';
import 'package:path_provider/path_provider.dart';

Expand All @@ -31,7 +30,6 @@ void main() {
runApp(const FlText());
}

final githubURL = Uri.parse("https://github.com/tseli0s/FlText");
final ThemeData darkTheme = ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: Color(accentColor),
Expand Down Expand Up @@ -133,28 +131,7 @@ class _HomepageState extends State<Homepage> {
ListTile(
leading: const Icon(Icons.info),
title: Text(AppLocalizations.of(context)!.aboutFltext),
onTap: () {
showAboutDialog(
applicationName: "FlText",
applicationVersion: "0.1.0",
applicationIcon: SizedBox.fromSize(
size: const Size.square(48),
child: const Image(
image: AssetImage('assets/logo.png'),
),
),
children: [
Text(AppLocalizations.of(context)!.fltextDesc),
TextButton(
onPressed: () async {
await openURL(githubURL);
},
child: Text(AppLocalizations.of(context)!.githubRepo),
)
],
context: context,
);
},
onTap: () => showFltextAbout(context),
),
],
),
Expand Down Expand Up @@ -292,27 +269,9 @@ class _HomepageState extends State<Homepage> {
context,
CupertinoPageRoute(
builder: (context) {
return TextEditor(filename: filename);
return TabbedTextEditor(filename: filename);
},
),
);
}

Future<void> openURL(Uri url) async {
/*
* Like the documentation says, launchUrl may either throw an exception or return false on failure,
* depending on the error. Here we handle both so we never have to manually debug what went wrong.
*/
try {
if (await launchUrl(url) != true) {
final title = AppLocalizations.of(context)!.unableToOpenURL;
final msg = AppLocalizations.of(context)!.anUnknownErrorOccured_URL;
showErrorDialog(context, title, msg);
}
} catch (e) {
final title = AppLocalizations.of(context)!.unableToOpenURL;
final msg = "Failed to load ${url.toString()}: ${e.toString()}";
showErrorDialog(context, title, msg);
}
}
}
2 changes: 1 addition & 1 deletion lib/multiline_text_input.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* FlText: A simple and nice-looking text editor.
* Copyright (C) 2023 Aggelos Tselios
* Copyright (C) 2023-2024 Aggelos Tselios
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion lib/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/*
* FlText: A simple and nice-looking text editor.
* Copyright (C) 2023 Aggelos Tselios
* Copyright (C) 2023-2024 Aggelos Tselios
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
10 changes: 10 additions & 0 deletions lib/single_line_input.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* FlText: A simple and nice-looking text editor.
* Copyright (C) 2023-2024 Aggelos Tselios
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

Expand Down
144 changes: 144 additions & 0 deletions lib/tabbed_text_editor.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
// ignore_for_file: unused_element

/*
* FlText: A simple and nice-looking text editor.
* Copyright (C) 2023-2024 Aggelos Tselios
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/

import 'dart:io';

import 'package:fltext/text_edit.dart';
import 'package:fltext/utils.dart';
import 'package:flutter/material.dart';
import 'package:menu_bar/menu_bar.dart';

class TabbedTextEditor extends StatefulWidget {
final List<String> filesOpen = [];

TabbedTextEditor({super.key, String? filename}) {
filesOpen.add(filename ?? "");
}

@override
State<StatefulWidget> createState() => TabbedTextEditorState();
}

class TabbedTextEditorState extends State<TabbedTextEditor> {
@override
Widget build(BuildContext context) {
var l = 0;
final List<Widget> tabs = [];
final List<Widget> children = [];

for (final f in widget.filesOpen) {
tabs.add(
Tab(
icon: const Icon(Icons.file_open),
text: f != "" ? f : "* New file",
),
);
children.add(
TextEditor(
filename: f != "" ? f : null,
),
);
l++;
}

/*
return DefaultTabController(
length: l,
child: Scaffold(
appBar: TabBar(tabs: tabs),
body: TabBarView(children: children),
),
);
*/
return MenuBarWidget(
barButtons: [
BarButton(
text: const Text('File'),
submenu: SubMenu(
menuItems: [
MenuButton(
text: const Text('Save'),
onTap: () {},
icon: const Icon(Icons.save),
shortcutText: 'Ctrl+S',
),
const MenuDivider(),
MenuButton(
text: const Text('Save as'),
onTap: () {},
icon: const Icon(Icons.save),
shortcutText: 'Ctrl+Shift+S',
),
const MenuDivider(),
MenuButton(
text: const Text('Back to home'),
onTap: () {
Navigator.of(context).popUntil((route) => route.isFirst);
},
icon: const Icon(Icons.exit_to_app),
),
const MenuDivider(),
MenuButton(
text: const Text('Exit'),
onTap: () {
exit(0);
},
icon: const Icon(Icons.exit_to_app),
shortcutText: 'Ctrl+Q',
),
],
),
),
BarButton(
text: const Text('Edit'),
submenu: SubMenu(
menuItems: [
MenuButton(
text: const Text('Preferences...'),
onTap: () {},
),
],
),
),
BarButton(
text: const Text('Help'),
submenu: SubMenu(
menuItems: [
MenuButton(
text: const Text('View License'),
onTap: () {
showLicense(context);
},
),
MenuButton(
text: const Text('About'),
onTap: () {
showFltextAbout(context);
},
icon: const Icon(Icons.info),
),
],
),
),
],

// Set the child, i.e. the application under the menu bar
child: DefaultTabController(
length: l,
child: Scaffold(
appBar: TabBar(tabs: tabs),
body: TabBarView(children: children),
),
),
);
}
}
Loading

0 comments on commit af21265

Please sign in to comment.