-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55b61ab
commit 50bc599
Showing
18 changed files
with
455 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
examples/app_async_flutter/lib/domain/model/gateway/async_client_gateway.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import 'package:app_async_flutter/domain/model/channel_credentials.dart'; | ||
|
||
abstract class AsyncClientGateway { | ||
Future<ChannelCredential?> getCredentials(); | ||
Future<void> callBusinessUseCase(String channelRef, int delay); | ||
Future<ChannelCredential?> getCredentials(String userRef); | ||
Future<void> callBusinessUseCase( | ||
String channelRef, String userRef, int delay); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
import 'package:app_async_flutter/setup.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
void main() async { | ||
await dotenv.load(fileName: ".env"); | ||
WidgetsFlutterBinding.ensureInitialized(); | ||
runApp(Setup.getApp()); | ||
SharedPreferences prefs = await SharedPreferences.getInstance(); | ||
|
||
runApp(Setup.getApp(prefs)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,51 @@ | ||
import 'package:app_async_flutter/application/app_config.dart'; | ||
import 'package:app_async_flutter/infraestructure/notifier/log_notifier.dart'; | ||
import 'package:app_async_flutter/infrastructure/notifier/log_notifier.dart'; | ||
import 'package:app_async_flutter/my_app.dart'; | ||
import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
import 'package:logging/logging.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
class Setup { | ||
static AppConfig getApp() { | ||
static AppConfig getApp(SharedPreferences prefs) { | ||
var env = dotenv.env; | ||
Logger.root.level = Level.INFO; | ||
LogNotifier logNotifier = configureLogger(); | ||
prefs.getString('apiBusiness'); | ||
return AppConfig( | ||
businessUrl: getEnvironment(prefs, 'apiBusiness'), | ||
heartbeatInterval: int.parse(getEnvironment(prefs, 'heartbeatInterval')), | ||
maxRetries: int.parse(getEnvironment(prefs, 'maxRetries')), | ||
socketUrl: getEnvironment(prefs, 'socketUrl'), | ||
logNotifier: logNotifier, | ||
child: const MyApp(), | ||
); | ||
} | ||
|
||
static String getEnvironment( | ||
SharedPreferences prefs, | ||
String key, | ||
) { | ||
var businessUrl = prefs.getString(key); | ||
if (businessUrl == null) { | ||
businessUrl = dotenv.env[key]!; | ||
prefs.setString(key, businessUrl); | ||
} | ||
print(businessUrl); | ||
|
||
return businessUrl; | ||
} | ||
|
||
static LogNotifier configureLogger() { | ||
LogNotifier logNotifier = LogNotifier(); | ||
logNotifier.addListener(() { | ||
Logger.root.level = | ||
logNotifier.level == LogLevel.all ? Level.FINEST : Level.INFO; | ||
}); | ||
|
||
Logger.root.onRecord.listen((record) { | ||
var log = '${record.level.name}: ${record.time}: ${record.message}'; | ||
logNotifier.setLog(log); | ||
print(log); | ||
// debugPrint(log); | ||
}); | ||
return AppConfig( | ||
businessUrl: env['apiBusiness'] ?? 'http://localhost:8080/api', | ||
heartbeatInterval: int.parse(env['heartbeatInterval'] ?? '2500'), | ||
maxRetries: int.parse(env['maxRetries'] ?? '15'), | ||
socketUrl: dotenv.env['socketUrl'] ?? 'ws://localhost:8082/ext/socket', | ||
logNotifier: logNotifier, | ||
child: const MyApp(), | ||
); | ||
return logNotifier; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class InputField extends StatelessWidget { | ||
const InputField( | ||
{Key? key, | ||
required this.textEditingController, | ||
this.keyboardType = TextInputType.number, | ||
required this.labelText, | ||
this.icon}) | ||
: super(key: key); | ||
|
||
final TextEditingController textEditingController; | ||
final TextInputType? keyboardType; | ||
final String labelText; | ||
final IconData? icon; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return TextField( | ||
controller: textEditingController, | ||
keyboardType: keyboardType, | ||
decoration: InputDecoration( | ||
border: const UnderlineInputBorder(), | ||
icon: Icon(icon), | ||
labelText: labelText, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.