Automatic refresh history if something has been uploaded and add fastlane alpha and debug

This commit is contained in:
Varakh 2021-02-04 01:07:03 +01:00
parent 162137ee10
commit 1adf487782
11 changed files with 102 additions and 31 deletions

View file

@ -1,4 +1,7 @@
# CHANGELOG
## 1.0.0+2
* Automatic refresh history if something has been uploaded
## 1.0.0+1
* Initial release

View file

@ -1,11 +1,22 @@
default_platform(:android)
platform :android do
desc "Build Debug"
lane :build_debug do
sh("#{ENV['PWD']}/fastlane/buildAndroidDebug.sh")
end
desc "Build"
lane :build do
sh("#{ENV['PWD']}/fastlane/buildAndroid.sh")
end
desc "Deploy a new version to the Google Play as Alpha"
lane :alpha do
build
upload_to_play_store(track: 'alpha', aab: '../build/app/outputs/bundle/release/app-release.aab')
end
desc "Deploy a new version to the Google Play as Beta"
lane :beta do
build

View file

@ -16,11 +16,21 @@ or alternatively using `brew install fastlane`
# Available Actions
## Android
### android build_debug
```
fastlane android build_debug
```
Build Debug
### android build
```
fastlane android build
```
Build
### android alpha
```
fastlane android alpha
```
Deploy a new version to the Google Play as Alpha
### android beta
```
fastlane android beta

View file

@ -4,11 +4,13 @@ import 'package:flutter_translate/localization_provider.dart';
import 'package:flutter_translate/localized_app.dart';
import 'package:provider/provider.dart';
import 'core/enums/refresh_event.dart';
import 'core/manager/dialog_manager.dart';
import 'core/manager/lifecycle_manager.dart';
import 'core/models/session.dart';
import 'core/services/dialog_service.dart';
import 'core/services/navigation_service.dart';
import 'core/services/refresh_service.dart';
import 'core/services/session_service.dart';
import 'locator.dart';
import 'ui/app_router.dart';
@ -22,24 +24,27 @@ class MyApp extends StatelessWidget {
return LocalizationProvider(
state: LocalizationProvider.of(context).state,
child: StreamProvider<Session>(
initialData: Session.initial(),
create: (context) => locator<SessionService>().sessionController.stream,
child: LifeCycleManager(
child: MaterialApp(
title: translate('app.title'),
builder: (context, child) => Navigator(
key: locator<DialogService>().dialogNavigationKey,
onGenerateRoute: (settings) => MaterialPageRoute(builder: (context) => DialogManager(child: child)),
),
theme: ThemeData(
brightness: Brightness.light, primarySwatch: primaryAccentColor, primaryColor: primaryAccentColor),
onGenerateRoute: AppRouter.generateRoute,
navigatorKey: locator<NavigationService>().navigationKey,
home: StartUpView(),
supportedLocales: localizationDelegate.supportedLocales,
locale: localizationDelegate.currentLocale,
)),
));
child: StreamProvider<RefreshEvent>(
initialData: null,
create: (context) => locator<RefreshService>().refreshHistoryController.stream,
child: StreamProvider<Session>(
initialData: Session.initial(),
create: (context) => locator<SessionService>().sessionController.stream,
child: LifeCycleManager(
child: MaterialApp(
title: translate('app.title'),
builder: (context, child) => Navigator(
key: locator<DialogService>().dialogNavigationKey,
onGenerateRoute: (settings) => MaterialPageRoute(builder: (context) => DialogManager(child: child)),
),
theme: ThemeData(
brightness: Brightness.light, primarySwatch: primaryAccentColor, primaryColor: primaryAccentColor),
onGenerateRoute: AppRouter.generateRoute,
navigatorKey: locator<NavigationService>().navigationKey,
home: StartUpView(),
supportedLocales: localizationDelegate.supportedLocales,
locale: localizationDelegate.currentLocale,
)),
)));
}
}

View file

@ -0,0 +1 @@
enum RefreshEvent { RefreshHistory }

View file

@ -0,0 +1,13 @@
import 'dart:async';
import '../enums/refresh_event.dart';
class RefreshService {
StreamController<RefreshEvent> refreshHistoryController = StreamController<RefreshEvent>();
void addEvent(RefreshEvent event) {
if (refreshHistoryController.hasListener) {
refreshHistoryController.add(event);
}
}
}

View file

@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter_translate/flutter_translate.dart';
@ -6,6 +7,7 @@ import 'package:logger/logger.dart';
import '../../locator.dart';
import '../datamodels/dialog_response.dart';
import '../enums/error_code.dart';
import '../enums/refresh_event.dart';
import '../enums/viewstate.dart';
import '../error/rest_service_exception.dart';
import '../error/service_exception.dart';
@ -15,18 +17,30 @@ import '../models/uploaded_paste.dart';
import '../services/dialog_service.dart';
import '../services/file_service.dart';
import '../services/link_service.dart';
import '../services/refresh_service.dart';
import '../util/logger.dart';
import 'base_model.dart';
class HistoryModel extends BaseModel {
final Logger _logger = getLogger();
final FileService _fileService = locator<FileService>();
final RefreshService _refreshService = locator<RefreshService>();
final LinkService _linkService = locator<LinkService>();
final DialogService _dialogService = locator<DialogService>();
String errorMessage;
StreamSubscription _refreshTriggerSubscription;
List<UploadedPaste> pastes = [];
String errorMessage;
void init() {
this._refreshTriggerSubscription = _refreshService.refreshHistoryController.stream.listen((event) {
if (event == RefreshEvent.RefreshHistory) {
_logger.d('History needs a refresh');
getHistory();
}
});
}
Future getHistory() async {
setState(ViewState.Busy);
@ -64,7 +78,6 @@ class HistoryModel extends BaseModel {
}
pastes.sort((a, b) => a.date.compareTo(b.date));
errorMessage = null;
} catch (e) {
if (e is RestServiceException) {
@ -148,4 +161,10 @@ class HistoryModel extends BaseModel {
void openLink(String link) {
_linkService.open(link);
}
@override
void dispose() {
_refreshTriggerSubscription.cancel();
super.dispose();
}
}

View file

@ -11,6 +11,7 @@ import 'package:receive_sharing_intent/receive_sharing_intent.dart';
import '../../locator.dart';
import '../enums/error_code.dart';
import '../enums/refresh_event.dart';
import '../enums/viewstate.dart';
import '../error/rest_service_exception.dart';
import '../error/service_exception.dart';
@ -19,6 +20,7 @@ import '../models/rest/uploaded_multi_response.dart';
import '../models/rest/uploaded_response.dart';
import '../services/file_service.dart';
import '../services/link_service.dart';
import '../services/refresh_service.dart';
import '../util/logger.dart';
import 'base_model.dart';
@ -26,6 +28,7 @@ class UploadModel extends BaseModel {
final Logger _logger = getLogger();
final FileService _fileService = locator<FileService>();
final LinkService _linkService = locator<LinkService>();
final RefreshService _refreshService = locator<RefreshService>();
TextEditingController _pasteTextController = TextEditingController();
StreamSubscription _intentDataStreamSubscription;
@ -171,6 +174,7 @@ class UploadModel extends BaseModel {
clearCachedFiles();
_pasteTextController.clear();
_refreshService.addEvent(RefreshEvent.RefreshHistory);
errorMessage = null;
return uploadedPasteIds;
} catch (e) {

View file

@ -7,6 +7,7 @@ import 'core/services/file_service.dart';
import 'core/services/link_service.dart';
import 'core/services/navigation_service.dart';
import 'core/services/permission_service.dart';
import 'core/services/refresh_service.dart';
import 'core/services/session_service.dart';
import 'core/services/storage_service.dart';
import 'core/viewmodels/about_model.dart';
@ -35,6 +36,7 @@ void setupLocator() {
locator.registerLazySingleton(() => FileService());
locator.registerLazySingleton(() => LinkService());
locator.registerLazySingleton(() => PermissionService());
locator.registerLazySingleton(() => RefreshService());
/// view models
locator.registerFactory(() => StartUpViewModel());

View file

@ -21,7 +21,10 @@ class HistoryView extends StatelessWidget {
var url = Provider.of<Session>(context).url;
return BaseView<HistoryModel>(
onModelReady: (model) => model.getHistory(),
onModelReady: (model) {
model.init();
return model.getHistory();
},
builder: (context, model, child) => Scaffold(
appBar: MyAppBar(title: Text(translate('titles.history'))),
backgroundColor: backgroundColor,
@ -40,14 +43,6 @@ class HistoryView extends StatelessWidget {
);
}
Widget _renderOpenInBrowser(HistoryModel model, String url) {
return IconButton(
icon: Icon(Icons.open_in_new, color: Colors.blue, textDirection: TextDirection.ltr),
onPressed: () {
return model.openLink(url);
});
}
Widget _render(HistoryModel model, String url) {
List<Widget> cards = List<Widget>();
@ -163,4 +158,12 @@ class HistoryView extends StatelessWidget {
physics: AlwaysScrollableScrollPhysics(),
);
}
Widget _renderOpenInBrowser(HistoryModel model, String url) {
return IconButton(
icon: Icon(Icons.open_in_new, color: Colors.blue, textDirection: TextDirection.ltr),
onPressed: () {
return model.openLink(url);
});
}
}

View file

@ -11,7 +11,7 @@ description: A mobile client for FileBin.
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
version: 1.0.0+2
environment:
sdk: ">=2.7.0 <3.0.0"