Browse Source

[flutter_example_packages] Add shared_preferences, refactoring

merge-requests/21/head
Vitaliy Zarubin 2 years ago
parent
commit
122feeb205
  1. 20
      example/lib/l10n/app_en.arb
  2. 12
      example/lib/l10n/app_ru.arb
  3. 2
      example/lib/packages/battery_plus/page.dart
  4. 2
      example/lib/packages/cached_network_image/page.dart
  5. 2
      example/lib/packages/device_info_plus/page.dart
  6. 2
      example/lib/packages/flutter_cache_manager/page.dart
  7. 2
      example/lib/packages/flutter_local_notifications/page.dart
  8. 2
      example/lib/packages/flutter_secure_storage/page.dart
  9. 2
      example/lib/packages/package_info_plus/page.dart
  10. 2
      example/lib/packages/path_provider/page.dart
  11. 93
      example/lib/packages/shared_preferences/model.dart
  12. 198
      example/lib/packages/shared_preferences/page.dart
  13. 2
      example/lib/packages/wakelock/page.dart
  14. 2
      example/lib/packages/xdga_directories/page.dart
  15. 252
      example/lib/pages/home/page.dart
  16. 7
      example/lib/pages/home/widgets/package_info_dialog.dart
  17. 31
      example/lib/theme/theme.dart
  18. 5
      example/lib/widgets/layouts/block_layout.dart
  19. 56
      example/pubspec.lock
  20. 12
      example/pubspec.yaml

20
example/lib/l10n/app_en.arb

@ -93,8 +93,24 @@
"pathProviderDescMovies": "There is no concept of External in Aurora OS, but this interface allows you to get the StorageDirectory.movies directory.",
"@_SHARED_PREFERENCES": {},
"sharedPreferencesTitle": "Title",
"sharedPreferencesDesc": "Desc",
"sharedPreferencesTitleState": "State",
"sharedPreferencesTitleUpdate": "Update",
"sharedPreferencesFieldInt": "Int",
"sharedPreferencesFieldBool": "Bool",
"sharedPreferencesFieldDouble": "Double",
"sharedPreferencesFieldString": "String",
"sharedPreferencesFieldList": "List",
"sharedPreferencesFieldBtnClean": "Clean",
"sharedPreferencesFieldBtn": "Save",
"sharedPreferencesFieldError": "Please enter {value} value",
"@sharedPreferencesFieldError": {
"placeholders": {
"value": {
"type": "String",
"example": "int"
}
}
},
"@_WAKELOCK": {},
"wakelockTitle": "Title",

12
example/lib/l10n/app_ru.arb

@ -93,8 +93,16 @@
"pathProviderDescMovies": "В Aurora OS нет концепции External, но этот интерфейс позволяет получить каталог StorageDirectory.movies.",
"@_SHARED_PREFERENCES": {},
"sharedPreferencesTitle": "Заголовок",
"sharedPreferencesDesc": "Описание",
"sharedPreferencesTitleState": "Состояние",
"sharedPreferencesTitleUpdate": "Обновить",
"sharedPreferencesFieldInt": "Int",
"sharedPreferencesFieldBool": "Bool",
"sharedPreferencesFieldDouble": "Double",
"sharedPreferencesFieldString": "String",
"sharedPreferencesFieldList": "Список",
"sharedPreferencesFieldBtnClean": "Очистить",
"sharedPreferencesFieldBtn": "Сохранить",
"sharedPreferencesFieldError": "Пожалуйста, введите {value} значение",
"@_WAKELOCK": {},
"wakelockTitle": "Заголовок",

2
example/lib/packages/battery_plus/page.dart

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_example_packages/base/di/app_di.dart';
import 'package:flutter_example_packages/base/package/package.dart';
import 'package:flutter_example_packages/packages/battery_plus/model.dart';
import 'package:flutter_example_packages/packages/battery_plus/package.dart';
@ -28,6 +29,7 @@ class _BatteryPlusPageState extends AppState<BatteryPlusPage> {
AppLocalizations l10n,
) {
return BlockLayout<BatteryPlusModel>(
model: getIt<BatteryPlusModel>(),
title: widget.package.key,
builder: (context, child, model) {
return SingleChildScrollView(

2
example/lib/packages/cached_network_image/page.dart

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_example_packages/base/di/app_di.dart';
import 'package:flutter_example_packages/base/package/package.dart';
import 'package:flutter_example_packages/packages/cached_network_image/model.dart';
import 'package:flutter_example_packages/packages/cached_network_image/package.dart';
@ -28,6 +29,7 @@ class _CachedNetworkImagePageState extends AppState<CachedNetworkImagePage> {
AppLocalizations l10n,
) {
return BlockLayout<CachedNetworkImageModel>(
model: getIt<CachedNetworkImageModel>(),
title: widget.package.key,
builder: (context, child, model) {
return SingleChildScrollView(

2
example/lib/packages/device_info_plus/page.dart

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_example_packages/base/di/app_di.dart';
import 'package:flutter_example_packages/base/package/package.dart';
import 'package:flutter_example_packages/packages/device_info_plus/model.dart';
import 'package:flutter_example_packages/packages/device_info_plus/package.dart';
@ -28,6 +29,7 @@ class _DeviceInfoPlusPageState extends AppState<DeviceInfoPlusPage> {
AppLocalizations l10n,
) {
return BlockLayout<DeviceInfoPlusModel>(
model: getIt<DeviceInfoPlusModel>(),
title: widget.package.key,
builder: (context, child, model) {
return SingleChildScrollView(

2
example/lib/packages/flutter_cache_manager/page.dart

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_example_packages/base/di/app_di.dart';
import 'package:flutter_example_packages/base/package/package.dart';
import 'package:flutter_example_packages/packages/flutter_cache_manager/model.dart';
import 'package:flutter_example_packages/packages/flutter_cache_manager/package.dart';
@ -29,6 +30,7 @@ class _FlutterCacheManagerPageState extends AppState<FlutterCacheManagerPage> {
AppLocalizations l10n,
) {
return BlockLayout<FlutterCacheManagerModel>(
model: getIt<FlutterCacheManagerModel>(),
title: widget.package.key,
builder: (context, child, model) {
return SingleChildScrollView(

2
example/lib/packages/flutter_local_notifications/page.dart

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_example_packages/base/di/app_di.dart';
import 'package:flutter_example_packages/base/package/package.dart';
import 'package:flutter_example_packages/packages/flutter_local_notifications/model.dart';
import 'package:flutter_example_packages/packages/flutter_local_notifications/package.dart';
@ -33,6 +34,7 @@ class _FlutterLocalNotificationsPageState
AppLocalizations l10n,
) {
return BlockLayout<FlutterLocalNotificationsModel>(
model: getIt<FlutterLocalNotificationsModel>(),
title: widget.package.key,
builder: (context, child, model) {
return SingleChildScrollView(

2
example/lib/packages/flutter_secure_storage/page.dart

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_example_packages/base/di/app_di.dart';
import 'package:flutter_example_packages/base/package/package.dart';
import 'package:flutter_example_packages/packages/flutter_secure_storage/model.dart';
import 'package:flutter_example_packages/packages/flutter_secure_storage/package.dart';
@ -55,6 +56,7 @@ class _FlutterSecureStoragePageState
AppLocalizations l10n,
) {
return BlockLayout<FlutterSecureStorageModel>(
model: getIt<FlutterSecureStorageModel>(),
title: widget.package.key,
builder: (context, child, model) {
// update read only value

2
example/lib/packages/package_info_plus/page.dart

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_example_packages/base/di/app_di.dart';
import 'package:flutter_example_packages/base/package/package.dart';
import 'package:flutter_example_packages/packages/package_info_plus/model.dart';
import 'package:flutter_example_packages/packages/package_info_plus/package.dart';
@ -28,6 +29,7 @@ class _PackageInfoPlusPageState extends AppState<PackageInfoPlusPage> {
AppLocalizations l10n,
) {
return BlockLayout<PackageInfoPlusModel>(
model: getIt<PackageInfoPlusModel>(),
title: widget.package.key,
builder: (context, child, model) {
return SingleChildScrollView(

2
example/lib/packages/path_provider/page.dart

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_example_packages/base/di/app_di.dart';
import 'package:flutter_example_packages/base/package/package.dart';
import 'package:flutter_example_packages/packages/path_provider/model.dart';
import 'package:flutter_example_packages/packages/path_provider/package.dart';
@ -26,6 +27,7 @@ class _PathProviderPageState extends AppState<PathProviderPage> {
AppLocalizations l10n,
) {
return BlockLayout<PathProviderModel>(
model: getIt<PathProviderModel>(),
title: widget.package.key,
builder: (context, child, model) {
return SingleChildScrollView(

93
example/lib/packages/shared_preferences/model.dart

@ -1,10 +1,16 @@
import 'package:flutter/widgets.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:shared_preferences/shared_preferences.dart';
/// Model for [SharedPreferencesPage]
class SharedPreferencesModel extends Model {
/// Get [ScopedModel]
static SharedPreferencesModel of(BuildContext context) => ScopedModel.of<SharedPreferencesModel>(context);
static SharedPreferencesModel of(BuildContext context) =>
ScopedModel.of<SharedPreferencesModel>(context);
/// Get Aurora info
Future<SharedPreferences> get _prefs async =>
await SharedPreferences.getInstance();
/// Error
String? _error;
@ -14,4 +20,87 @@ class SharedPreferencesModel extends Model {
/// Public is error
bool get isError => _error != null;
}
/// Read shared preferences
Map<String, dynamic>? _readValues;
/// Public values
Map<String, dynamic>? get readValues => _readValues;
/// Save int value
Future<void> setValueInt(int value) async {
try {
await (await _prefs).setInt('int', value);
} catch (e) {
_error = e.toString();
}
notifyListeners();
}
/// Save bool value
Future<void> setValueBool(bool value) async {
try {
await (await _prefs).setBool('bool', value);
} catch (e) {
_error = e.toString();
}
notifyListeners();
}
/// Save double value
Future<void> setValueDouble(double value) async {
try {
await (await _prefs).setDouble('double', value);
} catch (e) {
_error = e.toString();
}
notifyListeners();
}
/// Save string value
Future<void> setValueString(String value) async {
try {
await (await _prefs).setString('string', value);
} catch (e) {
_error = e.toString();
}
notifyListeners();
}
/// Save list value
Future<void> setValueList(List<String> value) async {
try {
await (await _prefs).setStringList('list', value);
} catch (e) {
_error = e.toString();
}
notifyListeners();
}
/// Clear all data
Future<void> clear() async {
try {
await (await _prefs).clear();
} catch (e) {
_error = e.toString();
}
notifyListeners();
}
/// Read values
Future<void> reloadValues() async {
try {
final prefs = await _prefs;
_readValues = {
'int': prefs.getInt('int'),
'bool': prefs.getBool('bool'),
'double': prefs.getDouble('double'),
'string': prefs.getString('string'),
'list': prefs.getStringList('list'),
};
} catch (e) {
_error = e.toString();
}
notifyListeners();
}
}

198
example/lib/packages/shared_preferences/page.dart

@ -1,12 +1,17 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_example_packages/base/di/app_di.dart';
import 'package:flutter_example_packages/base/package/package.dart';
import 'package:flutter_example_packages/packages/shared_preferences/model.dart';
import 'package:flutter_example_packages/packages/shared_preferences/package.dart';
import 'package:flutter_example_packages/theme/colors.dart';
import 'package:flutter_example_packages/theme/radius.dart';
import 'package:flutter_example_packages/widgets/base/export.dart';
import 'package:flutter_example_packages/widgets/blocks/block_alert.dart';
import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart';
import 'package:flutter_example_packages/widgets/blocks/block_item.dart';
import 'package:flutter_example_packages/widgets/layouts/block_layout.dart';
import 'package:flutter_example_packages/widgets/texts/export.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class SharedPreferencesPage extends AppStatefulWidget {
@ -21,6 +26,29 @@ class SharedPreferencesPage extends AppStatefulWidget {
}
class _SharedPreferencesPageState extends AppState<SharedPreferencesPage> {
final ScrollController _scrollController = ScrollController();
final model = getIt<SharedPreferencesModel>();
bool _formIsValid = true;
final _formKey = GlobalKey<FormState>();
final TextEditingController _intController =
TextEditingController(text: '100');
final TextEditingController _boolController =
TextEditingController(text: 'true');
final TextEditingController _doubleController =
TextEditingController(text: '100.5');
final TextEditingController _stringController =
TextEditingController(text: 'My text');
final TextEditingController _listController =
TextEditingController(text: 'First, Second, Third');
@override
void initState() {
super.initState();
model.reloadValues();
}
@override
Widget buildWide(
BuildContext context,
@ -28,9 +56,11 @@ class _SharedPreferencesPageState extends AppState<SharedPreferencesPage> {
AppLocalizations l10n,
) {
return BlockLayout<SharedPreferencesModel>(
model: model,
title: widget.package.key,
builder: (context, child, model) {
return SingleChildScrollView(
controller: _scrollController,
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
@ -39,15 +69,163 @@ class _SharedPreferencesPageState extends AppState<SharedPreferencesPage> {
BlockInfoPackage(widget.package),
BlockAlert(model.error),
if (!model.isError)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
BlockItem(
title: l10n.sharedPreferencesTitle,
desc: l10n.sharedPreferencesDesc,
value: null,
),
],
Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextTitleLarge(l10n.sharedPreferencesTitleState),
const SizedBox(height: 14),
Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.blue.shade50,
borderRadius: AppRadius.small,
),
child: Padding(
padding: const EdgeInsets.all(10),
child: TextBodyMedium(
const JsonEncoder.withIndent(' ')
.convert(model.readValues),
),
),
),
const SizedBox(height: 20),
SizedBox(
width: double.infinity,
child: OutlinedButton(
onPressed: () async {
// reload data
await model.clear();
// reload data
await model.reloadValues();
// disable keyboard
FocusManager.instance.primaryFocus?.unfocus();
// scroll to top
_scrollController.animateTo(
0,
duration: const Duration(milliseconds: 500),
curve: Curves.ease,
);
},
child: TextBodyLarge(
l10n.sharedPreferencesFieldBtnClean,
color: AppColors.secondary,
),
),
),
const SizedBox(height: 20),
TextTitleLarge(l10n.sharedPreferencesTitleUpdate),
const SizedBox(height: 14),
TextFormField(
controller: _intController,
keyboardType: TextInputType.number,
decoration: InputDecoration(
labelText: l10n.sharedPreferencesFieldInt,
),
validator: (value) {
if (int.tryParse(value ?? '') == null) {
return l10n.sharedPreferencesFieldError('int');
}
return null;
},
onChanged: (_) => setState(() {
_formIsValid =
_formKey.currentState?.validate() ?? true;
}),
),
const SizedBox(height: 16),
TextFormField(
controller: _boolController,
decoration: InputDecoration(
labelText: l10n.sharedPreferencesFieldBool,
),
validator: (value) {
if (value != 'true' && value != 'false') {
return l10n.sharedPreferencesFieldError('bool');
}
return null;
},
onChanged: (_) => setState(() {
_formIsValid =
_formKey.currentState?.validate() ?? true;
}),
),
const SizedBox(height: 16),
TextFormField(
controller: _doubleController,
keyboardType: TextInputType.number,
decoration: InputDecoration(
labelText: l10n.sharedPreferencesFieldDouble,
),
validator: (value) {
if (double.tryParse(value ?? '') == null) {
return l10n.sharedPreferencesFieldError('double');
}
return null;
},
onChanged: (_) => setState(() {
_formIsValid =
_formKey.currentState?.validate() ?? true;
}),
),
const SizedBox(height: 16),
TextFormField(
controller: _stringController,
decoration: InputDecoration(
labelText: l10n.sharedPreferencesFieldString,
),
),
const SizedBox(height: 16),
TextFormField(
controller: _listController,
decoration: InputDecoration(
labelText: l10n.sharedPreferencesFieldList,
),
),
const SizedBox(height: 20),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: _formIsValid
? () async {
// add int
await model.setValueInt(
int.parse(_intController.text));
// add bool
await model.setValueBool(
_boolController.text == 'true');
// add double
await model.setValueDouble(
double.parse(_doubleController.text));
// add string
await model
.setValueString(_stringController.text);
// add list
await model.setValueList(
_listController.text.split(', '));
// reload data
await model.reloadValues();
// disable keyboard
FocusManager.instance.primaryFocus
?.unfocus();
// scroll to top
_scrollController.animateTo(
0,
duration:
const Duration(milliseconds: 500),
curve: Curves.ease,
);
}
: null,
child: TextBodyLarge(
l10n.sharedPreferencesFieldBtn,
color: Colors.white,
),
),
),
],
),
),
],
),

2
example/lib/packages/wakelock/page.dart

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_example_packages/base/di/app_di.dart';
import 'package:flutter_example_packages/base/package/package.dart';
import 'package:flutter_example_packages/packages/wakelock/model.dart';
import 'package:flutter_example_packages/packages/wakelock/package.dart';
@ -28,6 +29,7 @@ class _WakelockPageState extends AppState<WakelockPage> {
AppLocalizations l10n,
) {
return BlockLayout<WakelockModel>(
model: getIt<WakelockModel>(),
title: widget.package.key,
builder: (context, child, model) {
return SingleChildScrollView(

2
example/lib/packages/xdga_directories/page.dart

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_example_packages/base/di/app_di.dart';
import 'package:flutter_example_packages/base/package/package.dart';
import 'package:flutter_example_packages/packages/xdga_directories/model.dart';
import 'package:flutter_example_packages/packages/xdga_directories/package.dart';
@ -28,6 +29,7 @@ class _XdgaDirectoriesPageState extends AppState<XdgaDirectoriesPage> {
AppLocalizations l10n,
) {
return BlockLayout<XdgaDirectoriesModel>(
model: getIt<XdgaDirectoriesModel>(),
title: widget.package.key,
builder: (context, child, model) {
return SingleChildScrollView(

252
example/lib/pages/home/page.dart

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_example_packages/base/di/app_di.dart';
import 'package:flutter_example_packages/base/package/package.dart';
import 'package:flutter_example_packages/extensions/keys_ext.dart';
import 'package:flutter_example_packages/packages/packages.dart';
@ -67,142 +68,147 @@ class _HomePageState extends AppState<HomePage> {
AppLocalizations l10n,
) {
final packagesFilter = filterPackages(_search, _filter);
return BlockLayout<HomeModel>(builder: (context, child, model) {
return Scaffold(
backgroundColor: Colors.blueGrey,
appBar: HomeAppBar(
onChangeSearch: (String text) {
if (packagesFilter.isNotEmpty) {
_controllerListView.jumpTo(0);
}
setState(() {
_search = text;
});
},
onChangeFilter: (PlatformFilter filter) {
if (packagesFilter.isNotEmpty) {
_controllerListView.jumpTo(0);
}
setState(() {
_filter = filter;
});
},
),
body: GestureDetector(
onTap: () {
FocusScope.of(context).requestFocus(FocusNode());
},
child: Stack(
children: [
Visibility(
visible: _search.isEmpty,
child: Container(
height: _hH > 0 ? _hH : 0,
color: AppColors.primary,
width: double.infinity,
child: Center(
child: Align(
alignment: FractionalOffset.bottomRight,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 40,
),
child: Opacity(
opacity: 0.2,
child: Image.asset(
'assets/images/logo-head.png',
width: 250,
return BlockLayout<HomeModel>(
model: getIt<HomeModel>(),
builder: (context, child, model) {
return Scaffold(
backgroundColor: Colors.blueGrey,
appBar: HomeAppBar(
onChangeSearch: (String text) {
if (packagesFilter.isNotEmpty) {
_controllerListView.jumpTo(0);
}
setState(() {
_search = text;
});
},
onChangeFilter: (PlatformFilter filter) {
if (packagesFilter.isNotEmpty) {
_controllerListView.jumpTo(0);
}
setState(() {
_filter = filter;
});
},
),
body: GestureDetector(
onTap: () {
FocusScope.of(context).requestFocus(FocusNode());
},
child: Stack(
children: [
Visibility(
visible: _search.isEmpty,
child: Container(
height: _hH > 0 ? _hH : 0,
color: AppColors.primary,
width: double.infinity,
child: Center(
child: Align(
alignment: FractionalOffset.bottomRight,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 40,
),
child: Opacity(
opacity: 0.2,
child: Image.asset(
'assets/images/logo-head.png',
width: 250,
),
),
),
),
),
),
),
),
),
Visibility(
visible: _search.isEmpty,
child: Container(
key: _header,
width: double.infinity,
padding: EdgeInsets.only(
left: 20,
right: 20,
top: media.orientation == Orientation.portrait ? 30 : 10,
bottom: media.orientation == Orientation.portrait ? 90 : 70,
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextHeadlineMedium(
l10n.homeWelcomeTitle,
color: Colors.white,
Visibility(
visible: _search.isEmpty,
child: Container(
key: _header,
width: double.infinity,
padding: EdgeInsets.only(
left: 20,
right: 20,
top:
media.orientation == Orientation.portrait ? 30 : 10,
bottom:
media.orientation == Orientation.portrait ? 90 : 70,
),
SizedBox(
height:
media.orientation == Orientation.portrait ? 40 : 20,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextHeadlineMedium(
l10n.homeWelcomeTitle,
color: Colors.white,
),
SizedBox(
height: media.orientation == Orientation.portrait
? 40
: 20,
),
TextTitleMedium(
l10n.homeWelcomeText(packages.length),
color: Colors.white,
)
],
),
TextTitleMedium(
l10n.homeWelcomeText(packages.length),
color: Colors.white,
)
],
),
),
),
),
if (packagesFilter.isNotEmpty)
ListView.builder(
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior.onDrag,
controller: _controllerListView,
padding: EdgeInsets.only(
top: _hH > 0 && _search.isEmpty ? _hH - 20 : 0),
itemCount: packagesFilter.length,
itemBuilder: (context, index) {
return PackageListItemWidget(
index: index,
item: packagesFilter[index],
);
},
),
if (packagesFilter.isEmpty)
Container(
width: double.infinity,
height: double.infinity,
color: Colors.white,
child: Padding(
padding: const EdgeInsets.only(
left: 20,
right: 20,
top: 20,
bottom: 0,
if (packagesFilter.isNotEmpty)
ListView.builder(
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior.onDrag,
controller: _controllerListView,
padding: EdgeInsets.only(
top: _hH > 0 && _search.isEmpty ? _hH - 20 : 0),
itemCount: packagesFilter.length,
itemBuilder: (context, index) {
return PackageListItemWidget(
index: index,
item: packagesFilter[index],
);
},
),
child: Center(
if (packagesFilter.isEmpty)
Container(
width: double.infinity,
height: double.infinity,
color: Colors.white,
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextTitleSmall(
l10n.homeNotFoundTitle,
textAlign: TextAlign.center,
),
const SizedBox(height: 40),
TextBodyMedium(
l10n.homeNotFoundSubtitle,
textAlign: TextAlign.center,
padding: const EdgeInsets.only(
left: 20,
right: 20,
top: 20,
bottom: 0,
),
child: Center(
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextTitleSmall(
l10n.homeNotFoundTitle,
textAlign: TextAlign.center,
),
const SizedBox(height: 40),
TextBodyMedium(
l10n.homeNotFoundSubtitle,
textAlign: TextAlign.center,
),
],
),
],
),
),
),
),
),
),
],
),
),
);
});
],
),
),
);
});
}
}

7
example/lib/pages/home/widgets/package_info_dialog.dart

@ -27,14 +27,17 @@ class PackageInfoDialog extends AppStatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextTitleSmall(package.key),
TextTitleLarge(package.key),
const SizedBox(height: 15),
TextBodyLarge(package.message),
TextBodyMedium(package.message),
const SizedBox(height: 20),
Row(
children: [
const Spacer(),
OutlinedButton(
style: OutlinedButton.styleFrom(
fixedSize: const Size.fromHeight(33),
),
onPressed: () {
Navigator.of(context).pop();
},

31
example/lib/theme/theme.dart

@ -3,8 +3,10 @@ import 'package:flutter_example_packages/theme/colors.dart';
import 'package:flutter_example_packages/theme/radius.dart';
import 'package:google_fonts/google_fonts.dart';
final theme = ThemeData.light();
final appTheme = ThemeData(
colorScheme: ThemeData().colorScheme.copyWith(
colorScheme: theme.colorScheme.copyWith(
primary: AppColors.primary,
secondary: AppColors.secondary,
),
@ -21,12 +23,12 @@ final appTheme = ThemeData(
),
/// [TextField]
inputDecorationTheme: const InputDecorationTheme(
contentPadding: EdgeInsets.symmetric(
inputDecorationTheme: theme.inputDecorationTheme.copyWith(
contentPadding: const EdgeInsets.symmetric(
vertical: 14,
horizontal: 16,
),
border: OutlineInputBorder(),
border: const OutlineInputBorder(),
),
/// [ElevatedButton]
@ -39,23 +41,10 @@ final appTheme = ThemeData(
/// [OutlinedButton]
outlinedButtonTheme: OutlinedButtonThemeData(
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return AppColors.secondary.withOpacity(0.4);
} else {
return AppColors.secondary;
}
}),
side: MaterialStateProperty.resolveWith<BorderSide>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return BorderSide(color: AppColors.secondary.withOpacity(0.4));
} else {
return const BorderSide(color: AppColors.secondary);
}
}),
style: OutlinedButton.styleFrom(
foregroundColor: AppColors.secondary,
fixedSize: const Size.fromHeight(45),
side: const BorderSide(color: AppColors.secondary),
),
),

5
example/lib/widgets/layouts/block_layout.dart

@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_example_packages/base/di/app_di.dart';
import 'package:flutter_example_packages/theme/colors.dart';
import 'package:flutter_example_packages/widgets/base/export.dart';
import 'package:flutter_example_packages/widgets/texts/export.dart';
@ -10,9 +9,11 @@ class BlockLayout<T extends Model> extends AppStatelessWidget {
const BlockLayout({
super.key,
this.title,
required this.model,
required this.builder,
});
final T model;
final String? title;
final Widget Function(BuildContext context, Widget? child, T model) builder;
@ -23,7 +24,7 @@ class BlockLayout<T extends Model> extends AppStatelessWidget {
AppLocalizations l10n,
) {
return ScopedModel<T>(
model: getIt<T>(),
model: model,
child: ScopedModelDescendant<T>(
builder: (context, child, model) {
return Scaffold(

56
example/pubspec.lock

@ -623,6 +623,62 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
shared_preferences_aurora:
dependency: "direct main"
description:
path: "../packages/shared_preferences/shared_preferences_aurora"
relative: true
source: path
version: "0.0.1"
shared_preferences_foundation:
dependency: transitive
description:
name: shared_preferences_foundation
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.2"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
shelf:
dependency: transitive
description:

12
example/pubspec.yaml

@ -67,12 +67,12 @@ dependencies:
## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/path_provider/path_provider_aurora
path_provider_aurora:
path: ../packages/path_provider/path_provider_aurora
#
# ## https://pub.dev/packages/shared_preferences
# shared_preferences: ^2.1.2
# ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/shared_preferences/shared_preferences_aurora
# shared_preferences_aurora:
# path: ../packages/shared_preferences/shared_preferences_aurora
## https://pub.dev/packages/shared_preferences
shared_preferences: ^2.1.2
## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/shared_preferences/shared_preferences_aurora
shared_preferences_aurora:
path: ../packages/shared_preferences/shared_preferences_aurora
# ## https://pub.dev/packages/wakelock
# wakelock: ^0.6.2

Loading…
Cancel
Save