diff --git a/lib/project/project_page.dart b/lib/project/project_page.dart index b64911f..4b89857 100644 --- a/lib/project/project_page.dart +++ b/lib/project/project_page.dart @@ -1,7 +1,9 @@ import 'package:doppio_dev_ixn/core/index.dart'; +import 'package:doppio_dev_ixn/generated/l10n.dart'; import 'package:doppio_dev_ixn/main.dart'; import 'package:doppio_dev_ixn/project_setting/index.dart'; import 'package:doppio_dev_ixn/service/index.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:doppio_dev_ixn/project/index.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -66,7 +68,13 @@ class _ProjectPageState extends State { onWillPop: () => _willPop(currentState as InProjectState), child: Scaffold( appBar: AppBar( - title: Text(i10n.project_name_title(name)), + title: Row( + children: [ + if (!kIsWeb) _addWidget(i10n), + Expanded(child: Center(child: Text(i10n.project_name_title(name)))), + if (!kIsWeb) ..._actionsWidget(), + ], + ), actions: [ IconButton( icon: Icon(Icons.settings), @@ -85,44 +93,20 @@ class _ProjectPageState extends State { ) ], ), - persistentFooterButtons: [ - Container( - width: ContextService().deviceSize.width, - child: Row( - children: [ - IconButton( - onPressed: () async { - _addKey(); - }, - tooltip: i10n.project_add, - icon: Icon(Icons.add), - ), - Spacer(), - IconButton( - onPressed: () async { - await projectModel.export(); - }, - tooltip: i10n.project_export, - icon: Icon(Icons.file_upload), - ), - IconButton( - onPressed: () async { - await _import(); - }, - tooltip: i10n.project_import, - icon: Icon(Icons.file_download), + persistentFooterButtons: kIsWeb + ? [ + Container( + width: ContextService().deviceSize.width, + child: Row( + children: [ + _addWidget(i10n), + Spacer(), + ..._actionsWidget(), + ], + ), ), - IconButton( - onPressed: () async { - _projectBloc.add(SaveProjectEvent(projectModel)); - }, - tooltip: i10n.project_save, - icon: Icon(Icons.save), - ), - ], - ), - ), - ], + ] + : null, body: projectScreen, ), ); @@ -130,6 +114,45 @@ class _ProjectPageState extends State { ); } + List _actionsWidget() { + final i10n = TranslateService().locale; + return [ + IconButton( + onPressed: () async { + await projectModel.export(); + }, + tooltip: i10n.project_export, + icon: Icon(Icons.file_upload), + ), + IconButton( + onPressed: () async { + await _import(); + }, + tooltip: i10n.project_import, + icon: Icon(Icons.file_download), + ), + IconButton( + onPressed: () async { + _projectBloc.add(SaveProjectEvent(projectModel)); + }, + tooltip: i10n.project_save, + icon: Icon(Icons.save), + ) + ]; + } + + IconButton _addWidget(S i10n) { + return IconButton( + onPressed: projectModel?.defaultLocale == null + ? null + : () async { + _addKey(); + }, + tooltip: i10n.project_add, + icon: Icon(Icons.add), + ); + } + Future _willPop(InProjectState currentState) async { var canPop = currentState.project == projectModel; final i10n = TranslateService().locale; diff --git a/lib/project_setting/project_setting_page.dart b/lib/project_setting/project_setting_page.dart index cca5180..b1f9554 100644 --- a/lib/project_setting/project_setting_page.dart +++ b/lib/project_setting/project_setting_page.dart @@ -1,6 +1,7 @@ import 'package:doppio_dev_ixn/main.dart'; import 'package:doppio_dev_ixn/project/index.dart'; import 'package:doppio_dev_ixn/service/index.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:doppio_dev_ixn/project_setting/index.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -52,37 +53,33 @@ class _ProjectSettingPageState extends State { onWillPop: _willPop, child: Scaffold( appBar: AppBar( - title: Text(i10n.page_settings), + title: Row( + children: [ + _undoWidget(currentState), + Expanded( + child: Center( + child: Text(i10n.page_settings), + ), + ), + _saveWidget(), + ], + ), actions: [], ), - persistentFooterButtons: [ - Container( - width: ContextService().deviceSize.width, - child: Row( - children: [ - IconButton( - icon: const Icon(Icons.undo), - onPressed: () { - setState(() { - if (currentState is InProjectSettingState) { - projectModel = currentState.project.copyWith(); - projectModelBackup = projectModel == null ? null : projectModel.copyWith(); - backuped = true; - } - }); - }, - tooltip: i10n.discard, + persistentFooterButtons: kIsWeb + ? [ + Container( + width: ContextService().deviceSize.width, + child: Row( + children: [ + _undoWidget(currentState), + Spacer(), + _saveWidget(), + ], + ), ), - Spacer(), - IconButton( - icon: const Icon(Icons.save), - onPressed: _save, - tooltip: i10n.save, - ), - ], - ), - ), - ], + ] + : null, body: screen, ), ), @@ -91,6 +88,30 @@ class _ProjectSettingPageState extends State { ); } + IconButton _saveWidget() { + return IconButton( + icon: const Icon(Icons.save), + onPressed: _save, + tooltip: i10n.save, + ); + } + + IconButton _undoWidget(ProjectSettingState currentState) { + return IconButton( + icon: const Icon(Icons.undo), + onPressed: () { + setState(() { + if (currentState is InProjectSettingState) { + projectModel = currentState.project.copyWith(); + projectModelBackup = projectModel == null ? null : projectModel.copyWith(); + backuped = true; + } + }); + }, + tooltip: i10n.discard, + ); + } + void _save() { if (!autoValidate) { autoValidate = true; @@ -133,6 +154,6 @@ class _ProjectSettingPageState extends State { ), ); } - return Future.value(canPop); + return canPop; } } diff --git a/lib/projects/projects_page.dart b/lib/projects/projects_page.dart index 65501ee..813198c 100644 --- a/lib/projects/projects_page.dart +++ b/lib/projects/projects_page.dart @@ -1,5 +1,6 @@ import 'package:doppio_dev_ixn/project/index.dart'; import 'package:doppio_dev_ixn/service/index.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:doppio_dev_ixn/projects/index.dart'; import 'package:line_awesome_icons/line_awesome_icons.dart'; @@ -24,54 +25,75 @@ class _ProjectsPageState extends State { Widget build(BuildContext context) { final i10n = TranslateService().locale; return Scaffold( - key: Key('projecs_sc'), - appBar: AppBar( - title: Text(i10n.projects_title), - actions: [ - IconButton( - icon: Icon(LineAwesomeIcons.github), - onPressed: () async { - final url = 'https://github.com/doppio-dev/iXn'; - if (await canLaunch(url)) { - await launch(url); - } - }, - ) + key: Key('projecs_sc'), + appBar: AppBar( + title: Row( + children: [ + _actionsWidget(), + Expanded(child: Center(child: Text(i10n.projects_title))), ], ), - body: projectsScreen, - persistentFooterButtons: [ - Container( - width: ContextService().deviceSize.width, - child: Row( - children: [ - IconButton( - onPressed: () async { - projectsScreen.projectsBloc.add(AddProjectsEvent(projectModel: ProjectModel(id: Uuid().v4()))); - }, - tooltip: i10n.projects_add, - icon: Icon(Icons.add), + actions: [ + IconButton( + icon: Icon(LineAwesomeIcons.github), + onPressed: () async { + final url = 'https://github.com/doppio-dev/iXn'; + if (await canLaunch(url)) { + await launch(url); + } + }, + ) + ], + ), + body: projectsScreen, + persistentFooterButtons: kIsWeb + ? [ + Container( + width: ContextService().deviceSize.width, + child: Row( + children: [Expanded(child: _actionsWidget())], ), - IconButton( - onPressed: () async { - showRemove = !showRemove; - projectsScreen.projectsBloc.add(ViewProjectsEvent(showRemove: showRemove)); - }, - tooltip: i10n.projects_show_remove, - icon: Icon(Icons.remove), - ), - Spacer(), - // IconButton( - // onPressed: () async { - // await _import(); - // }, - // tooltip: i10n.projects_import, - // icon: Icon(Icons.file_download), - // ), - ], - ), + ), + ] + : null, + ); + } + + Widget _actionsWidget() { + final i10n = TranslateService().locale; + return Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + IconButton( + onPressed: () async { + projectsScreen.projectsBloc.add(AddProjectsEvent(projectModel: ProjectModel(id: Uuid().v4()))); + }, + tooltip: i10n.projects_add, + icon: Icon(Icons.add), + ), + IconButton( + onPressed: () async { + showRemove = !showRemove; + projectsScreen.projectsBloc.add(ViewProjectsEvent(showRemove: showRemove)); + }, + tooltip: i10n.projects_show_remove, + icon: Icon(Icons.remove), + ), + ], ), - ]); + // IconButton( + // onPressed: () async { + // await _import(); + // }, + // tooltip: i10n.projects_import, + // icon: Icon(Icons.file_download), + // ), + ], + ), + ); } // Future _import() async { diff --git a/lib/widget/edit_lang_word.dart b/lib/widget/edit_lang_word.dart index c8318d3..1d04473 100644 --- a/lib/widget/edit_lang_word.dart +++ b/lib/widget/edit_lang_word.dart @@ -29,7 +29,7 @@ class _EditLangWordState extends State { Widget build(BuildContext context) { final i10n = TranslateService().locale; final key = widget.projectModel.keys[widget.index]; - final newkey = '${key.id}${widget.locale.key}'; + final newkey = '${key.id}${widget.locale?.key}'; final keyOrigin = '${key.id}${widget.projectModel.defaultLocale.key}'; var word = widget.projectModel.getWord(newkey, key, widget.locale); var wordOrigin = widget.projectModel.getWord(keyOrigin, key, widget.projectModel.defaultLocale); diff --git a/macos/Runner/doppio_dev_ixnDebug.entitlements b/macos/Runner/doppio_dev_ixnDebug.entitlements index cb7e3f5..91f41fb 100644 --- a/macos/Runner/doppio_dev_ixnDebug.entitlements +++ b/macos/Runner/doppio_dev_ixnDebug.entitlements @@ -12,5 +12,7 @@ com.apple.security.network.client + com.apple.security.network.server +