repo_id
stringlengths 21
168
| file_path
stringlengths 36
210
| content
stringlengths 1
9.98M
| __index_level_0__
int64 0
0
|
---|---|---|---|
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz1 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz1/flutter7/flutter7.page.dart | // Copyright (c) 2022 foxsofter.
//
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_thrio/flutter_thrio.dart';
import '../../route.dart';
part 'flutter7.context.dart';
part 'flutter7.state.dart';
class Flutter7Page extends NavigatorStatefulPage {
const Flutter7Page({
super.key,
required super.moduleContext,
required super.settings,
});
@override
_Flutter7PageState createState() => _Flutter7PageState();
}
class _Flutter7PageState extends State<Flutter7Page>
with
SingleTickerProviderStateMixin,
NavigatorPageLifecycleMixin,
AutomaticKeepAliveClientMixin {
late final controller = TabController(
initialIndex: Random.secure().nextInt(4), length: 5, vsync: this);
@override
void dispose() {
ThrioLogger.d('page7 dispose: ${widget.settings.index}');
super.dispose();
}
@override
void didAppear(RouteSettings routeSettings) {
super.didAppear(routeSettings);
}
@override
void didDisappear(RouteSettings routeSettings) {
super.didDisappear(routeSettings);
}
@override
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBar(
title: const Text('TabBarView example',
style: TextStyle(color: Colors.black)),
leading: context.showPopAwareWidget(const IconButton(
color: Colors.black,
tooltip: 'back',
icon: Icon(Icons.arrow_back_ios),
onPressed: ThrioNavigator.pop,
)),
bottom: TabBar(
controller: controller,
indicatorColor: Colors.white,
tabs: const <Tab>[
Tab(text: 'flutter5'),
Tab(text: 'flutter1'),
Tab(text: 'flutter2'),
Tab(text: 'flutter3'),
Tab(text: 'flutter8'),
],
),
),
body: NavigatorPageLifecycle(
didAppear: (settings) {
ThrioLogger.v('page7 didAppear -> $settings');
},
didDisappear: (settings) {
ThrioLogger.v('page7 didDisappear -> $settings');
},
child: NavigatorTabBarView(
controller: controller,
routeSettings: <RouteSettings>[
NavigatorRouteSettings.settingsWith(url: biz.biz2.flutter8.url),
NavigatorRouteSettings.settingsWith(
url: biz.biz1.flutter1.home.url),
NavigatorRouteSettings.settingsWith(url: biz.biz1.flutter7.url),
NavigatorRouteSettings.settingsWith(url: biz.biz2.flutter2.url),
NavigatorRouteSettings.settingsWith(url: biz.biz1.flutter3.url),
],
)));
}
@override
bool get wantKeepAlive => true;
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz1 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz1/flutter3/flutter3.context.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
part of 'flutter3.page.dart';
extension Flutter3Context on ModuleContext {}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz1 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz1/flutter3/flutter3.page.dart | // Copyright (c) 2022 foxsofter.
//
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_thrio/flutter_thrio.dart';
import '../../route.dart';
import '../../types/people.dart';
part 'flutter3.context.dart';
part 'flutter3.state.dart';
class Flutter3Page extends NavigatorStatefulPage {
const Flutter3Page({
super.key,
required super.moduleContext,
required super.settings,
});
@override
_Flutter3PageState createState() => _Flutter3PageState();
}
class _Flutter3PageState extends State<Flutter3Page>
with NavigatorPageLifecycleMixin, AutomaticKeepAliveClientMixin {
@override
void dispose() {
ThrioLogger.d('page3 dispose: ${widget.settings.index}');
super.dispose();
}
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
super.build(context);
return WillPopScope(
onWillPop: () async {
final r = await ThrioNavigator.push(url: '/biz/biz2/flutter2');
ThrioLogger.i('page3 WillPopScope: $r');
return true;
},
child: Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
title: const Text('thrio_example',
style: TextStyle(color: Colors.black)),
leading: context.showPopAwareWidget(const IconButton(
color: Colors.black,
tooltip: 'back',
icon: Icon(Icons.arrow_back_ios),
onPressed: ThrioNavigator.maybePop,
)),
systemOverlayStyle: SystemUiOverlayStyle.dark,
),
body: SingleChildScrollView(
child: Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 10, bottom: 20),
alignment: AlignmentDirectional.center,
child: Text(
'flutter3: index is ${widget.settings.index}',
style: const TextStyle(fontSize: 28, color: Colors.blue),
),
),
InkWell(
onTap: () => biz.biz2.flutter4
.push(people: People(name: 'goodman', sex: '女')),
child: Container(
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.all(4),
color: Colors.yellow,
child: const Text(
'push flutter4',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: biz.biz2.flutter2.remove,
child: Container(
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.all(4),
color: Colors.yellow,
child: const Text(
'remove flutter2',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () => ThrioNavigator.pop(params: 'goodman'),
child: Container(
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.all(4),
color: Colors.yellow,
child: const Text(
'pop',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: biz.biz1.flutter1.home.popTo,
child: Container(
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.all(4),
color: Colors.yellow,
child: const Text(
'popTo flutter1',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () => ThrioNavigator.popToFirst(url: '/biz1/native1'),
child: Container(
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.all(4),
color: Colors.yellow,
child: const Text(
'popTo native1',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () => ThrioNavigator.push(
url: '/biz1/native1',
params: {
'1': {'2': '3'}
},
),
child: Container(
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.all(4),
color: Colors.grey,
child: const Text(
'push native1',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () => ThrioNavigator.remove(url: '/biz1/native1'),
child: Container(
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.all(4),
color: Colors.grey,
child: const Text(
'pop native1',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: ThrioNavigator.popFlutter,
child: Container(
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.all(4),
color: Colors.grey,
child: const Text(
'pop flutter',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () async => biz.biz1.flutter1.flutter1(intValue: 9),
child: Container(
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.all(4),
color: Colors.grey,
child: const Text(
'notify flutter1',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const TestNavigatorPage())),
child: Container(
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.all(4),
color: Colors.yellow,
child: const Text(
'Navigator push',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: biz.biz1.flutter7.push,
child: Container(
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.all(4),
color: Colors.yellow,
child: const Text(
'push flutter7',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
Padding(
padding: const EdgeInsets.all(4.0),
child: ElevatedButton(
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all(Colors.indigo)),
onPressed: () {
final r = biz.biz2.flutter8.push();
ThrioLogger.v(r.toString());
},
child: const Text(
'push flutter8',
style: TextStyle(color: Colors.white),
),
),
)
]),
),
));
}
}
class TestPage extends StatefulWidget {
const TestPage({super.key});
@override
_TestPageState createState() => _TestPageState();
}
class _TestPageState extends State<TestPage> {
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: const Text('test page'),
leading: const IconButton(
color: Colors.black,
tooltip: 'back',
icon: Icon(Icons.arrow_back_ios),
onPressed: ThrioNavigator.pop,
),
),
body: Form(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
initialValue: '',
onSaved: (val) => val,
validator: (val) => val == '' ? val : null,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all(Colors.indigo)),
onPressed: () {
Navigator.of(context).pop();
},
child: const Text(
'Navigator pop',
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all(Colors.indigo)),
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
settings: const RouteSettings(name: 'test'),
builder: (context) => const TestPage()),
);
},
child: const Text(
'Navigator push',
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all(Colors.indigo)),
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
settings: const RouteSettings(name: 'test'),
builder: (context) => const TestPage()),
);
},
child: const Text(
'Navigator push 2',
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all(Colors.indigo)),
onPressed: () {
Navigator.of(context).pushReplacement(
MaterialPageRoute(
settings: const RouteSettings(name: 'test'),
builder: (context) => const TestPage()),
);
},
child: const Text(
'Navigator pushReplace',
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all(Colors.indigo)),
onPressed: () async {
final mctx = await biz.biz1.flutter1.home.push();
ThrioLogger.v(mctx.toString());
},
child: const Text(
'push thrio page',
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all(Colors.indigo)),
onPressed: () {
final mctx = NavigatorPage.moduleContextOf(context);
ThrioLogger.v(mctx.toString());
},
child: const Text(
'Get ModuleContext',
style: TextStyle(color: Colors.white),
),
),
)
],
),
),
);
}
class TestNavigatorPage extends StatefulWidget {
const TestNavigatorPage({super.key});
@override
_TestNavigatorPageState createState() => _TestNavigatorPageState();
}
class _TestNavigatorPageState extends State<TestNavigatorPage> {
final navigatorKey = GlobalKey<NavigatorState>();
BuildContext? internalContext;
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: const Text('test page'),
leading: const IconButton(
color: Colors.black,
tooltip: 'back',
icon: Icon(Icons.arrow_back_ios),
onPressed: ThrioNavigator.pop,
),
),
body: NavigatorWillPop(
internalNavigatorKey: navigatorKey,
onWillPop: () async {
final canPop = Navigator.of(internalContext!).canPop();
if (canPop) {
Navigator.of(internalContext!).pop();
return false;
}
return true;
},
child: Navigator(
observers: [
TestObser(),
NavigatorWillPop.navigatorObserverFor(navigatorKey)
],
key: navigatorKey,
initialRoute: 'test',
onGenerateRoute: (settings) {
if (settings.name == 'test') {
return MaterialPageRoute(
builder: (context) {
internalContext = context;
return const TestPage();
},
settings: settings);
}
return null;
},
),
));
}
class TestObser extends NavigatorObserver {
@override
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {}
@override
void didReplace({Route<dynamic>? newRoute, Route<dynamic>? oldRoute}) {}
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz1 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz1/flutter3/module.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
import 'package:flutter_thrio/flutter_thrio.dart';
import 'flutter3.page.dart';
class Module with ThrioModule, ModulePageBuilder {
@override
String get key => 'flutter3';
@override
void onPageBuilderSetting(ModuleContext moduleContext) =>
pageBuilder = (settings) => Flutter3Page(
moduleContext: moduleContext,
settings: settings,
);
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz1 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz1/flutter3/flutter3.route.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
import 'package:flutter_thrio/flutter_thrio.dart';
class Flutter3Route extends NavigatorRouteLeaf {
factory Flutter3Route(NavigatorRouteNode parent) =>
_instance ??= Flutter3Route._(parent);
Flutter3Route._(super.parent);
static Flutter3Route? _instance;
@override
String get name => 'flutter3';
Future<TPopParams?> push<TParams, TPopParams>({
TParams? params,
bool animated = true,
NavigatorIntCallback? result,
}) =>
ThrioNavigator.push<TParams, TPopParams>(
url: url,
params: params,
animated: animated,
result: result,
);
Future<TPopParams?> pushSingle<TParams, TPopParams>({
TParams? params,
bool animated = true,
NavigatorIntCallback? result,
}) =>
ThrioNavigator.pushSingle<TParams, TPopParams>(
url: url,
params: params,
animated: animated,
result: result,
);
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz1 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz1/flutter3/flutter3.state.dart | // Copyright (c) 2023 foxsofter.
//
// ignore_for_file: avoid_as
part of 'flutter3.page.dart';
extension Flutter3 on State<Flutter3Page> {}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/module.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
import 'package:flutter_thrio/flutter_thrio.dart';
import 'flutter10/module.dart' as flutter10;
import 'flutter2/module.dart' as flutter2;
import 'flutter4/module.dart' as flutter4;
import 'flutter6/module.dart' as flutter6;
import 'flutter8/module.dart' as flutter8;
class Module with ThrioModule {
@override
String get key => 'biz2';
@override
void onModuleRegister(ModuleContext moduleContext) {
registerModule(flutter2.Module(), moduleContext);
registerModule(flutter4.Module(), moduleContext);
registerModule(flutter6.Module(), moduleContext);
registerModule(flutter8.Module(), moduleContext);
registerModule(flutter10.Module(), moduleContext);
}
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/biz2.context.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
import 'package:flutter_thrio/flutter_thrio.dart';
extension Biz2Context on ModuleContext {}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/biz2.route.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
import 'package:flutter_thrio/flutter_thrio.dart';
import 'flutter10/flutter10.route.dart';
import 'flutter2/flutter2.route.dart';
import 'flutter4/flutter4.route.dart';
import 'flutter6/flutter6.route.dart';
import 'flutter8/flutter8.route.dart';
class Biz2Route extends NavigatorRouteNode {
factory Biz2Route(NavigatorRouteNode parent) =>
_instance ??= Biz2Route._(parent);
Biz2Route._(super.parent);
static Biz2Route? _instance;
late final flutter2 = Flutter2Route(this);
late final flutter4 = Flutter4Route(this);
late final flutter6 = Flutter6Route(this);
late final flutter8 = Flutter8Route(this);
late final flutter10 = Flutter10Route(this);
@override
String get name => 'biz2';
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter4/flutter4.page.dart | // Copyright (c) 2022 foxsofter.
//
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_thrio/flutter_thrio.dart';
import '../../route.dart';
import '../../types/people.dart';
part 'flutter4.state.dart';
part 'flutter4.context.dart';
class Flutter4Page extends NavigatorStatefulPage {
const Flutter4Page({
super.key,
required super.moduleContext,
required super.settings,
});
@override
_Flutter4PageState createState() => _Flutter4PageState();
}
class _Flutter4PageState extends State<Flutter4Page>
with NavigatorPageLifecycleMixin, AutomaticKeepAliveClientMixin {
@override
void dispose() {
ThrioLogger.d('page4 dispose: ${widget.settings.index}');
super.dispose();
}
@override
bool get wantKeepAlive => true;
@override
void didAppear(RouteSettings routeSettings) {
super.didAppear(routeSettings);
}
@override
void didDisappear(RouteSettings routeSettings) {
super.didDisappear(routeSettings);
}
@override
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
title: const Text('thrio_example',
style: TextStyle(color: Colors.black)),
leading: context.showPopAwareWidget(const IconButton(
color: Colors.black,
tooltip: 'back',
icon: Icon(Icons.arrow_back_ios),
onPressed: ThrioNavigator.pop,
)),
systemOverlayStyle: SystemUiOverlayStyle.dark,
),
body: SingleChildScrollView(
child: Container(
margin: const EdgeInsets.all(24),
child: Column(children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 10, bottom: 20),
alignment: AlignmentDirectional.center,
child: Text(
'flutter4: index is ${widget.settings.index}',
style: const TextStyle(fontSize: 28, color: Colors.blue),
),
),
InkWell(
onTap: () => biz.biz1.flutter1.home
.push(strList: <String>['1', '2', '3']),
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'push flutter1',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: biz.biz1.flutter3.remove,
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'remove flutter3',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: ThrioNavigator.pop,
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'pop',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: ThrioNavigator.popToRoot,
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'popTobiz',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () => ThrioNavigator.popTo(
url: '/biz/biz2/flutter2',
),
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'popTo flutter2',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () => ThrioNavigator.push(
url: '/biz1/native1',
params: {
'1': {'2': '3'}
},
),
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.grey,
child: const Text(
'push native1',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () => ThrioNavigator.remove(url: '/biz1/native1'),
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.grey,
child: const Text(
'pop native1',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () async {
if (!await biz.biz1.flutter1.flutter1(intValue: 33)) {
await ThrioNavigator.push(
url: '/biz/biz1/flutter1/home',
params: {'page1Notify': {}});
}
},
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.grey,
child: const Text(
'open if needed and notify',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
]),
),
));
}
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter4/module.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
import 'package:flutter_thrio/flutter_thrio.dart';
import 'flutter4.page.dart';
class Module with ThrioModule, ModulePageBuilder {
@override
String get key => 'flutter4';
@override
void onPageBuilderSetting(ModuleContext moduleContext) =>
pageBuilder = (settings) => Flutter4Page(
moduleContext: moduleContext,
settings: settings,
);
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter4/flutter4.route.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
import 'package:example/src/biz/types/people.dart';
import 'package:flutter_thrio/flutter_thrio.dart';
class Flutter4Route extends NavigatorRouteLeaf {
factory Flutter4Route(NavigatorRouteNode parent) =>
_instance ??= Flutter4Route._(parent);
Flutter4Route._(super.parent);
static Flutter4Route? _instance;
@override
String get name => 'flutter4';
/// `people` hello, this is a people
///
/// 打开 people 页面
///
Future<TPopParams?> push<TPopParams>({
required People people,
bool animated = true,
NavigatorIntCallback? result,
}) =>
ThrioNavigator.push<Map<String, dynamic>, TPopParams>(
url: url,
params: <String, dynamic>{
'people': people,
},
animated: animated,
result: result,
);
/// `people` hello, this is a people
///
/// 打开 people 页面
///
Future<TPopParams?> pushSingle<TPopParams>({
required People people,
bool animated = true,
NavigatorIntCallback? result,
}) =>
ThrioNavigator.pushSingle<Map<String, dynamic>, TPopParams>(
url: url,
params: <String, dynamic>{
'people': people,
},
animated: animated,
result: result,
);
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter4/flutter4.context.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
part of 'flutter4.page.dart';
extension Flutter4Context on ModuleContext {
/// get a people.
///
People get people =>
get<People>('people') ?? (throw ArgumentError('people not exists'));
bool setPeople(People value) => set<People>('people', value);
/// remove a people.
///
People? removePeople() => remove<People>('people');
Stream<People> get onPeople =>
on<People>('people') ?? (throw ArgumentError('people stream not exists'));
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter4/flutter4.state.dart | // Copyright (c) 2023 foxsofter.
//
// ignore_for_file: avoid_as
part of 'flutter4.page.dart';
extension Flutter4 on State<Flutter4Page> {
/// hello, this is a people
///
People get people => widget.getParam<People>('people');
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter8/flutter8.context.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
part of 'flutter8.page.dart';
extension Flutter8Context on ModuleContext {}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter8/flutter8.page.dart | // Copyright (c) 2023 foxsofter.
//
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_thrio/flutter_thrio.dart';
import '../../route.dart';
part 'flutter8.context.dart';
part 'flutter8.state.dart';
class Flutter8Page extends NavigatorStatefulPage {
const Flutter8Page({
super.key,
required super.moduleContext,
required super.settings,
});
@override
_Flutter8PageState createState() => _Flutter8PageState();
}
class _Flutter8PageState extends State<Flutter8Page>
with NavigatorPageLifecycleMixin, AutomaticKeepAliveClientMixin {
@override
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
title: const Text('thrio_build_example',
style: TextStyle(color: Colors.black)),
leading: context.showPopAwareWidget(const IconButton(
color: Colors.black,
tooltip: 'back',
icon: Icon(Icons.arrow_back_ios),
onPressed: ThrioNavigator.pop,
)),
systemOverlayStyle: SystemUiOverlayStyle.dark,
),
body: SizedBox(
height: 400,
child: Column(
children: <Widget>[
SizedBox(
height: 200,
child: ThrioNavigator.build(url: biz.biz2.flutter10.url) ??
const Text('url not found'),
),
],
)),
);
}
@override
bool get wantKeepAlive => true;
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter8/module.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
import 'package:flutter_thrio/flutter_thrio.dart';
import 'flutter8.page.dart';
class Module with ThrioModule, ModulePageBuilder {
@override
String get key => 'flutter8';
@override
void onPageBuilderSetting(ModuleContext moduleContext) =>
pageBuilder = (settings) => Flutter8Page(
moduleContext: moduleContext,
settings: settings,
);
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter8/flutter8.route.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
import 'package:flutter_thrio/flutter_thrio.dart';
class Flutter8Route extends NavigatorRouteLeaf {
factory Flutter8Route(NavigatorRouteNode parent) =>
_instance ??= Flutter8Route._(parent);
Flutter8Route._(super.parent);
static Flutter8Route? _instance;
@override
String get name => 'flutter8';
Future<TPopParams?> push<TParams, TPopParams>({
TParams? params,
bool animated = true,
NavigatorIntCallback? result,
}) =>
ThrioNavigator.push<TParams, TPopParams>(
url: url,
params: params,
animated: animated,
result: result,
);
Future<TPopParams?> pushSingle<TParams, TPopParams>({
TParams? params,
bool animated = true,
NavigatorIntCallback? result,
}) =>
ThrioNavigator.pushSingle<TParams, TPopParams>(
url: url,
params: params,
animated: animated,
result: result,
);
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter8/flutter8.state.dart | // Copyright (c) 2023 foxsofter.
//
// ignore_for_file: avoid_as
part of 'flutter8.page.dart';
extension Flutter8 on State<Flutter8Page> {}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter10/flutter10.route.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
import 'package:flutter_thrio/flutter_thrio.dart';
class Flutter10Route extends NavigatorRouteLeaf {
factory Flutter10Route(NavigatorRouteNode parent) =>
_instance ??= Flutter10Route._(parent);
Flutter10Route._(super.parent);
static Flutter10Route? _instance;
@override
String get name => 'flutter10';
Future<TPopParams?> push<TParams, TPopParams>({
TParams? params,
bool animated = true,
NavigatorIntCallback? result,
}) =>
ThrioNavigator.push<TParams, TPopParams>(
url: url,
params: params,
animated: animated,
result: result,
);
Future<TPopParams?> pushSingle<TParams, TPopParams>({
TParams? params,
bool animated = true,
NavigatorIntCallback? result,
}) =>
ThrioNavigator.pushSingle<TParams, TPopParams>(
url: url,
params: params,
animated: animated,
result: result,
);
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter10/flutter10.context.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
part of 'flutter10.page.dart';
extension Flutter10Context on ModuleContext {}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter10/flutter10.state.dart | // Copyright (c) 2023 foxsofter.
//
// ignore_for_file: avoid_as
part of 'flutter10.page.dart';
extension Flutter10 on State<Flutter10Page> {}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter10/module.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
import 'package:flutter_thrio/flutter_thrio.dart';
import 'flutter10.page.dart';
class Module with ThrioModule, ModulePageBuilder {
@override
String get key => 'flutter10';
@override
void onPageBuilderSetting(ModuleContext moduleContext) =>
pageBuilder = (settings) => Flutter10Page(
moduleContext: moduleContext,
settings: settings,
);
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter10/flutter10.page.dart | // Copyright (c) 2023 foxsofter.
//
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_thrio/flutter_thrio.dart';
part 'flutter10.context.dart';
part 'flutter10.state.dart';
class Flutter10Page extends NavigatorStatefulPage {
const Flutter10Page({
super.key,
required super.moduleContext,
required super.settings,
});
@override
_Flutter10PageState createState() => _Flutter10PageState();
}
class _Flutter10PageState extends State<Flutter10Page>
with AutomaticKeepAliveClientMixin {
@override
Widget build(BuildContext context) {
super.build(context);
return const _TestConstWidget();
}
@override
bool get wantKeepAlive => true;
}
class _TestConstWidget extends StatefulWidget {
const _TestConstWidget();
@override
State<_TestConstWidget> createState() => __TestConstWidgetState();
}
class __TestConstWidgetState extends State<_TestConstWidget>
with NavigatorPageLifecycleMixin {
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
title: const Text('thrio_build_example',
style: TextStyle(color: Colors.black)),
leading: context.showPopAwareWidget(const IconButton(
color: Colors.black,
tooltip: 'back',
icon: Icon(Icons.arrow_back_ios),
onPressed: ThrioNavigator.pop,
)),
systemOverlayStyle: SystemUiOverlayStyle.dark,
),
body: const SizedBox(
height: 100,
child: Text('flutter 10'),
),
);
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter6/flutter6.route.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
import 'package:flutter/widgets.dart';
import 'package:flutter_thrio/flutter_thrio.dart';
class Flutter6Route extends NavigatorRouteLeaf {
factory Flutter6Route(NavigatorRouteNode parent) =>
_instance ??= Flutter6Route._(parent);
Flutter6Route._(super.parent);
static Flutter6Route? _instance;
@override
String get name => 'flutter6';
Future<TPopParams?> push<TParams, TPopParams>({
TParams? params,
bool animated = true,
NavigatorIntCallback? result,
}) =>
ThrioNavigator.push<TParams, TPopParams>(
url: url,
params: params,
animated: animated,
result: result,
);
Future<TPopParams?> pushSingle<TParams, TPopParams>({
TParams? params,
bool animated = true,
NavigatorIntCallback? result,
}) =>
ThrioNavigator.pushSingle<TParams, TPopParams>(
url: url,
params: params,
animated: animated,
result: result,
);
/// 发送邮箱验证码
///
Future<bool?> sendEmailCode({
BuildContext? context,
required String email,
int? currentFrom,
String? coin,
String? amount,
String? address,
String? tag,
}) =>
ThrioNavigator.act<Map<String, dynamic>, bool>(
url: url,
action:
'sendEmailCode{context?,email,currentFrom?,coin?,amount?,address?,tag?}',
params: {
'context': context,
'email': email,
'currentFrom': currentFrom,
'coin': coin,
'amount': amount,
'address': address,
'tag': tag,
},
);
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter6/module.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
import 'package:flutter/widgets.dart';
import 'package:flutter_thrio/flutter_thrio.dart';
import 'flutter6.page.dart';
import 'flutter6.route_action.dart';
import 'flutter6.route_custom_handler.dart';
class Module
with
ThrioModule,
ModuleRouteCustomHandler,
ModuleRouteAction,
ModulePageBuilder {
@override
void onRouteCustomHandlerRegister(ModuleContext moduleContext) =>
on$RouteCustomHandlerRegister(moduleContext, registerRouteCustomHandler);
@override
void onRouteActionRegister(ModuleContext moduleContext) {
registerRouteAction(
'sendEmailCode{context?,email,currentFrom?,coin?,amount?,address?,tag?}',
<TParams, TResult>(
url,
action,
queryParams, {
params,
}) {
final result = onSendEmailCode(
moduleContext,
url,
action,
queryParams,
context: getValueOrNull<BuildContext>(params, 'context'),
email: getValue<String>(params, 'email'),
currentFrom: getValueOrNull<int>(params, 'currentFrom'),
coin: getValueOrNull<String>(params, 'coin'),
amount: getValueOrNull<String>(params, 'amount'),
address: getValueOrNull<String>(params, 'address'),
tag: getValueOrNull<String>(params, 'tag'),
);
if (result is Future<TResult?>) {
return result as Future<TResult?>;
} else if (result is TResult) {
return result as TResult;
}
return null;
});
}
@override
String get key => 'flutter6';
@override
void onPageBuilderSetting(ModuleContext moduleContext) =>
pageBuilder = (settings) => Flutter6Page(
moduleContext: moduleContext,
settings: settings,
);
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter6/flutter6.page.dart | // Copyright (c) 2022 foxsofter.
//
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_thrio/flutter_thrio.dart';
import '../../route.dart';
part 'flutter6.context.dart';
part 'flutter6.state.dart';
class Flutter6Page extends NavigatorStatefulPage {
const Flutter6Page({
super.key,
required super.moduleContext,
required super.settings,
});
@override
_Flutter6PageState createState() => _Flutter6PageState();
}
class _Flutter6PageState extends State<Flutter6Page> {
@override
void dispose() {
ThrioLogger.d('page6 dispose: ${widget.settings.index}');
super.dispose();
}
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
title: const Text('thrio_deeplink_example',
style: TextStyle(color: Colors.black)),
leading: context.showPopAwareWidget(const IconButton(
color: Colors.black,
tooltip: 'back',
icon: Icon(Icons.arrow_back_ios),
onPressed: ThrioNavigator.pop,
)),
systemOverlayStyle: SystemUiOverlayStyle.dark,
),
body: SingleChildScrollView(
child: Container(
margin: const EdgeInsets.all(24),
child: Column(children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 10, bottom: 20),
alignment: AlignmentDirectional.center,
child: Text(
'flutter6: index is ${widget.settings.index}',
style: const TextStyle(fontSize: 28, color: Colors.blue),
),
),
InkWell(
onTap: () async {
final result = await ThrioNavigator.push(
url: 'justascheme://open/biz2/home?tab=0');
debugPrint(result.toString());
},
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'deeplink with one parameter',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () async {
final result = await biz.biz1.flutter11.push();
debugPrint(result.toString());
},
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'push flutter11',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () async {
final result = await ThrioNavigator.push(
url: 'justascheme://open/biz2/home');
debugPrint(result.toString());
},
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'deeplink without parameter',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () async {
final result = await ThrioNavigator.push(
url:
'anotherScheme://leaderboard/home?hashId=13131973173&product=31fefq');
debugPrint(result.toString());
},
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'deeplink multi parameter',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () async {
final result = await ThrioNavigator.push(
url: 'anotherscheme://leaderboard/home?product=31fefq');
debugPrint(result.toString());
},
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'deeplink optional parameter',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () async {
// final result =
// await ThrioNavigator.push(url: 'https://www.google.com');
// debugPrint(result.toString());
final s = biz.biz2.flutter6.sendEmailCode(email: 'email');
debugPrint(s.toString());
},
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'deeplink with http',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () async {
final result = await ThrioNavigator.pushAndRemoveTo(
url: biz.biz1.flutter7.url,
toUrl: biz.biz1.flutter1.home.url,
);
debugPrint(result.toString());
},
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'push flutter7 and remove to flutter1',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () async {
final result = await ThrioNavigator.pushSingle(
url: biz.biz1.flutter3.url,
);
debugPrint(result.toString());
},
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'push single flutter3',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () async {
final result = await ThrioNavigator.act(
url: biz.biz1.flutter1.home.url,
action: 'getPeople?intValue=12',
params: <String, dynamic>{'intValue': 11});
debugPrint(result.toString());
},
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'act flutter1 getPeople',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () async {
final result =
await biz.biz1.flutter1.getString(boolValue: true);
debugPrint(result);
},
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'act flutter1 get void',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
]),
),
));
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter6/flutter6.route_custom_handler.dart | // Copyright (c) 2022 foxsofter.
//
import 'package:flutter_thrio/flutter_thrio.dart';
import '../../route.dart';
Future<void> on$RouteCustomHandlerRegister(
final ModuleContext moduleContext,
final void Function(String, NavigatorRouteCustomHandler) registerFunc,
) async {
registerFunc(
'https://*',
<TParams, TPopParams>(
url,
queryParams, {
params,
animated = true,
result,
}) =>
'good' as TPopParams);
registerFunc(
'justascheme://open/biz2/home{tab?}',
<TParams, TPopParams>(
url,
queryParams, {
params,
animated = true,
result,
}) =>
ThrioNavigator.push<TParams, TPopParams>(
url: biz.biz1.flutter3.url,
params: params,
animated: animated,
result: result,
));
registerFunc('justascheme://open/biz2/home', <TParams, TPopParams>(
url,
queryParams, {
params,
animated = true,
result,
}) {
result?.call(-1); // 不拦截
return null;
});
registerFunc(
'anotherScheme://leaderboard/home{hashId?,product}',
<TParams, TPopParams>(
url,
queryParams, {
params,
animated = true,
result,
}) =>
ThrioNavigator.push<TParams, TPopParams>(
url: biz.biz1.flutter3.url,
params: params,
animated: animated,
result: result,
));
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter6/flutter6.route_action.dart | // Copyright (c) 2022 foxsofter.
//
import 'dart:async';
import 'package:flutter/widgets.dart';
import 'package:flutter_thrio/flutter_thrio.dart';
/// 发送邮箱验证码
///
FutureOr<bool?> onSendEmailCode(
final ModuleContext moduleContext,
final String url,
final String action,
final Map<String, List<String>> queryParams, {
final BuildContext? context,
required String email,
final int? currentFrom,
final String? coin,
final String? amount,
final String? address,
final String? tag,
}) async {
debugPrint('onSendEmail:$email');
return null;
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter6/flutter6.state.dart | // Copyright (c) 2023 foxsofter.
//
// ignore_for_file: avoid_as
part of 'flutter6.page.dart';
extension Flutter6 on State<Flutter6Page> {}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter6/flutter6.context.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
part of 'flutter6.page.dart';
extension Flutter6Context on ModuleContext {}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter2/flutter2.route.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
import 'package:flutter_thrio/flutter_thrio.dart';
class Flutter2Route extends NavigatorRouteLeaf {
factory Flutter2Route(NavigatorRouteNode parent) =>
_instance ??= Flutter2Route._(parent);
Flutter2Route._(super.parent);
static Flutter2Route? _instance;
@override
String get name => 'flutter2';
Future<TPopParams?> push<TParams, TPopParams>({
TParams? params,
bool animated = true,
NavigatorIntCallback? result,
}) =>
ThrioNavigator.push<TParams, TPopParams>(
url: url,
params: params,
animated: animated,
result: result,
);
Future<TPopParams?> pushSingle<TParams, TPopParams>({
TParams? params,
bool animated = true,
NavigatorIntCallback? result,
}) =>
ThrioNavigator.pushSingle<TParams, TPopParams>(
url: url,
params: params,
animated: animated,
result: result,
);
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter2/flutter2.context.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
part of 'flutter2.page.dart';
extension Flutter2Context on ModuleContext {}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter2/flutter2.page.dart | // Copyright (c) 2022 foxsofter.
//
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_thrio/flutter_thrio.dart';
import '../../route.dart';
import '../../types/people.dart';
part 'flutter2.state.dart';
part 'flutter2.context.dart';
class Flutter2Page extends NavigatorStatefulPage {
const Flutter2Page({
super.key,
required super.moduleContext,
required super.settings,
});
@override
_Flutter2PageState createState() => _Flutter2PageState();
}
class _Flutter2PageState extends State<Flutter2Page>
with NavigatorPageLifecycleMixin, AutomaticKeepAliveClientMixin {
final _channel = ThrioChannel(channel: 'custom_thrio_channel');
@override
void initState() {
super.initState();
_channel.registryMethodCall('sayHello', ([final arguments]) async {
ThrioLogger.v('sayHello from native');
});
}
@override
bool get wantKeepAlive => true;
@override
void dispose() {
ThrioLogger.d('page2 dispose: ${widget.settings.index}');
super.dispose();
}
@override
void didAppear(RouteSettings routeSettings) {
super.didAppear(routeSettings);
}
@override
void didDisappear(RouteSettings routeSettings) {
super.didDisappear(routeSettings);
}
@override
Widget build(BuildContext context) {
super.build(context);
return NavigatorPageNotify(
name: 'page2Notify',
onPageNotify: (params) =>
ThrioLogger.v('flutter2 receive notify:$params'),
child: Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
title: const Text('thrio_example',
style: TextStyle(color: Colors.black)),
leading: context.showPopAwareWidget(const IconButton(
color: Colors.black,
tooltip: 'back',
icon: Icon(Icons.arrow_back_ios),
onPressed: ThrioNavigator.pop,
)),
systemOverlayStyle: SystemUiOverlayStyle.dark,
),
body: SingleChildScrollView(
child: Container(
margin: const EdgeInsets.all(24),
child: Column(children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 10, bottom: 20),
alignment: AlignmentDirectional.center,
child: Text(
'flutter2: index is ${widget.settings.index}',
style: const TextStyle(fontSize: 28, color: Colors.blue),
),
),
InkWell(
onTap: () async {
final r = await ThrioNavigator.push(
url: '/biz/biz1/flutter3',
params: {
'1': {'2': '3'}
},
);
ThrioLogger.v('flutter3 return: $r');
},
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'push flutter3',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () =>
ThrioNavigator.remove(url: '/biz/biz2/flutter2'),
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'remove flutter2',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () => ThrioNavigator.pop(
params: People(name: '大宝剑', age: 0, sex: 'x')),
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.yellow,
child: const Text(
'pop',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () async {
final params = await ThrioNavigator.push(
url: '/biz2/native2',
params: {
'1': {'2': '3'}
});
ThrioLogger.v('/biz1/native1 popped:$params');
},
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.grey,
child: const Text(
'push native2',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () => ThrioNavigator.remove(url: '/biz1/native1'),
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.grey,
child: const Text(
'pop native1',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () {
ThrioNavigator.notify(
url: '/biz/biz1/flutter1/home',
name: 'page1Notify',
params: People(name: '大宝剑', age: 1, sex: 'x'));
},
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.grey,
child: const Text(
'notify flutter1',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () {
ThrioNavigator.notify(
url: '/biz/biz2/flutter2',
name: 'page2Notify',
params: People(name: '大宝剑', age: 2, sex: 'x'));
},
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.grey,
child: const Text(
'notify flutter2',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () {
ThrioNavigator.notifyAll(
name: 'all_page_notify_from_flutter2',
params: People(name: '大宝剑', age: 2, sex: 'x'));
},
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.grey,
child: const Text(
'notify all',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: () {
ThrioNavigator.pushReplace(
url: biz.biz1.flutter1.home.url);
},
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.grey,
child: const Text(
'pushReplace flutter1',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: biz.biz1.flutter5.push,
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.grey,
child: const Text(
'push flutter5',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
InkWell(
onTap: biz.biz2.flutter6.push,
child: Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
color: Colors.grey,
child: const Text(
'push flutter6',
style: TextStyle(fontSize: 22, color: Colors.black),
)),
),
]),
),
)));
}
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter2/module.dart | // Copyright (c) 2023 foxsofter.
//
// Do not edit this file.
//
import 'package:flutter_thrio/flutter_thrio.dart';
import 'flutter2.page.dart';
class Module with ThrioModule, ModulePageBuilder {
@override
String get key => 'flutter2';
@override
void onPageBuilderSetting(ModuleContext moduleContext) =>
pageBuilder = (settings) => Flutter2Page(
moduleContext: moduleContext,
settings: settings,
);
}
| 0 |
mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2 | mirrored_repositories/flutter_thrio/example/lib/src/biz/biz2/flutter2/flutter2.state.dart | // Copyright (c) 2023 foxsofter.
//
// ignore_for_file: avoid_as
part of 'flutter2.page.dart';
extension Flutter2 on State<Flutter2Page> {}
| 0 |
mirrored_repositories/flutter_thrio/example | mirrored_repositories/flutter_thrio/example/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Verify Platform version', (tester) async {});
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App | mirrored_repositories/Inshorts-Clone-The-News-App/lib/aplication_localization.dart | // Dart imports:
import 'dart:async';
import 'dart:convert';
// Flutter imports:
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class AppLocalizations {
final Locale locale;
AppLocalizations(this.locale);
// Helper method to keep the code in the widgets concise
// Localizations are accessed using an InheritedWidget "of" syntax
static AppLocalizations of(BuildContext context) {
return Localizations.of<AppLocalizations>(context, AppLocalizations);
}
Map<String, String> _localizedStrings;
static const LocalizationsDelegate<AppLocalizations> delegate =
_AppLocalizationsDelegate();
Future<bool> load() async {
// Load the language JSON file from the "lang" folder
String jsonString =
await rootBundle.loadString('assets/lang/${locale.languageCode}.json');
Map<String, dynamic> jsonMap = json.decode(jsonString);
_localizedStrings = jsonMap.map((key, value) {
return MapEntry(key, value.toString());
});
return true;
}
// This method will be called from every widget which needs a localized text
String translate(String key) {
return _localizedStrings[key];
}
}
class _AppLocalizationsDelegate
extends LocalizationsDelegate<AppLocalizations> {
// This delegate instance will never change (it doesn't even have fields!)
// It can provide a constant constructor.
const _AppLocalizationsDelegate();
@override
bool isSupported(Locale locale) {
// Include all of your supported language codes here
return ['en', 'hi', 'mr', 'kn'].contains(locale.languageCode);
}
@override
Future<AppLocalizations> load(Locale locale) async {
// AppLocalizations class is where the JSON loading actually runs
AppLocalizations localizations = new AppLocalizations(locale);
await localizations.load();
return localizations;
}
@override
bool shouldReload(_AppLocalizationsDelegate old) => false;
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App | mirrored_repositories/Inshorts-Clone-The-News-App/lib/main.dart | // Flutter imports:
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
// Package imports:
import 'package:hive/hive.dart';
import 'package:path_provider/path_provider.dart';
import 'package:provider/provider.dart';
// Project imports:
import 'package:inshort_clone/controller/provider.dart';
import 'package:inshort_clone/controller/settings.dart';
import 'package:inshort_clone/model/news_model.dart';
import 'app/app.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final docPath = await getApplicationDocumentsDirectory();
Hive.init(docPath.path);
Hive.registerAdapter(ArticlesAdapter());
await Hive.openBox('settingsBox');
await Hive.openBox<Articles>('bookmarks');
await Hive.openBox<Articles>('unreads');
final _isDarkModeOn = await Hive.box('settingsBox').get('isDarkModeOn');
SettingsProvider().darkTheme(_isDarkModeOn ?? false);
final _lang = await Hive.box('settingsBox').get('activeLang');
SettingsProvider().setLang(_lang);
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
systemNavigationBarColor: Colors.black,
statusBarColor: Colors.black,
statusBarBrightness: Brightness.light,
systemNavigationBarIconBrightness: Brightness.light,
),
);
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider<SettingsProvider>(
create: (_) => SettingsProvider()),
ChangeNotifierProvider<FeedProvider>(create: (_) => FeedProvider()),
],
child: App(),
),
);
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib | mirrored_repositories/Inshorts-Clone-The-News-App/lib/global/global.dart | // Flutter imports:
import 'package:flutter/cupertino.dart';
class Global {
static final List<String> lang = [
"English",
"हिंदी",
"मराठी",
"ಕನ್ನಡ",
];
static height(context) => MediaQuery.of(context).size.height;
static width(context) => MediaQuery.of(context).size.width;
static String apikey = "paste your key here";
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib | mirrored_repositories/Inshorts-Clone-The-News-App/lib/app/app.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:provider/provider.dart';
// Project imports:
import 'package:inshort_clone/bloc/feed/news_feed_bloc.dart';
import 'package:inshort_clone/bloc/serach_feed/search_feed_bloc.dart';
import 'package:inshort_clone/controller/settings.dart';
import 'package:inshort_clone/routes/rouut.dart';
import 'package:inshort_clone/services/news/news_service.dart';
import 'package:inshort_clone/style/theme.dart';
import '../aplication_localization.dart';
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
//
return MultiBlocProvider(
providers: [
BlocProvider<NewsFeedBloc>(
create: (context) =>
NewsFeedBloc(repository: NewsFeedRepositoryImpl(context)),
),
BlocProvider<SearchFeedBloc>(
create: (context) =>
SearchFeedBloc(repository: NewsFeedRepositoryImpl(context)),
),
],
child: MaterialApp(
debugShowCheckedModeBanner: false,
title: "Inshorts Clone",
theme: kLightThemeData,
darkTheme: kDarkThemeData,
themeMode:
Provider.of<SettingsProvider>(context, listen: true).isDarkThemeOn
? ThemeMode.dark
: ThemeMode.light,
onGenerateRoute: Rouut.onGenerateRoute,
navigatorKey: Rouut.navigatorKey,
supportedLocales: [
Locale('en', 'US'),
Locale('hi', 'IN'),
Locale('mr', 'IN'),
Locale('kn', 'IN'),
],
localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
localeResolutionCallback: (locale, supportedLocales) {
// Check if the current device locale is supported
for (var supportedLocale in supportedLocales) {
if (supportedLocale.languageCode == locale.languageCode &&
supportedLocale.countryCode == locale.countryCode) {
return supportedLocale;
}
}
return supportedLocales.first;
},
locale: Locale(
Provider.of<SettingsProvider>(context, listen: true)
.getActiveLanguageCode(),
"IN")),
);
//
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/app | mirrored_repositories/Inshorts-Clone-The-News-App/lib/app/dio/dio.dart | // Package imports:
import 'package:dio/dio.dart';
// Project imports:
import 'package:inshort_clone/global/global.dart';
class GetDio {
bool loggedIn;
GetDio._();
static Dio getDio() {
Dio dio = new Dio();
dio.interceptors.add(
InterceptorsWrapper(
onRequest: (RequestOptions options) async {
options.connectTimeout = 90000;
options.receiveTimeout = 90000;
options.sendTimeout = 90000;
options.followRedirects = true;
options.baseUrl = "http://newsapi.org/v2/";
options.headers["X-Api-Key"] = "${Global.apikey}";
return options;
},
onResponse: (Response response) async {
return response;
},
onError: (DioError dioError) async {
if (dioError.type == DioErrorType.DEFAULT) {
if (dioError.message.contains('SocketException')) {
print("no internet");
}
}
return dioError.response; //continue
},
),
);
return dio;
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/view | mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/feed_screen/feed.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:provider/provider.dart';
// Project imports:
import 'package:inshort_clone/common/widgets/news_appbar.dart';
import 'package:inshort_clone/common/widgets/news_card/news_card.dart';
import 'package:inshort_clone/controller/provider.dart';
import 'package:inshort_clone/model/news_model.dart';
import 'package:inshort_clone/view/web_screen/web.dart';
class FeedScreen extends StatefulWidget {
final List<Articles> articals;
final int articalIndex;
final bool isFromSearch;
const FeedScreen(
{Key key,
@required this.articalIndex,
@required this.articals,
@required this.isFromSearch})
: super(key: key);
@override
_FeedScreenState createState() => _FeedScreenState();
}
class _FeedScreenState extends State<FeedScreen>
with AutomaticKeepAliveClientMixin {
@override
Widget build(BuildContext context) {
super.build(context);
PageController _pageController =
PageController(initialPage: widget.articalIndex);
PageController _searchPageController = PageController();
int lastPage = 0;
final provider = Provider.of<FeedProvider>(context, listen: false);
provider.setfeedPageController(_pageController);
return Scaffold(
backgroundColor: Colors.black,
body: widget.isFromSearch
? PageView(
controller: _searchPageController,
children: [
Stack(
fit: StackFit.expand,
children: [
PageView.builder(
onPageChanged: (page) {
if (page > lastPage) {
provider.setSearchAppBarVisible(false);
provider.setAppBarVisible(false);
} else {
provider.setSearchAppBarVisible(true);
provider.setAppBarVisible(true);
}
provider.setFeedBottomActionbarVisible(false);
lastPage = page;
provider.setCurentArticalIndex(page);
},
controller: _pageController,
itemCount: widget.articals.length,
scrollDirection: Axis.vertical,
itemBuilder: (_, index) {
return NewsCard(
article: widget.articals[index],
isFromSearch: widget.isFromSearch,
);
},
),
widget.isFromSearch
? Consumer<FeedProvider>(
builder: (context, value, child) =>
value.getSearchAppBarVisible
? Align(
alignment: Alignment.topCenter,
child: NewsCardAppBar(),
)
: Container(),
)
: Container()
],
),
WebScreen(
url: provider.getNewsURL,
isFromBottom: false,
pageController: _searchPageController,
)
],
)
: Stack(
fit: StackFit.expand,
children: [
PageView.builder(
allowImplicitScrolling: false,
onPageChanged: (page) {
if (page > lastPage) {
provider.setSearchAppBarVisible(false);
provider.setAppBarVisible(false);
} else {
provider.setSearchAppBarVisible(true);
provider.setAppBarVisible(true);
}
lastPage = page;
provider.setCurentArticalIndex(page);
provider.setFeedBottomActionbarVisible(false);
},
controller: _pageController,
itemCount: widget.articals.length,
scrollDirection: Axis.vertical,
itemBuilder: (_, index) {
return NewsCard(
article: widget.articals[index],
isFromSearch: widget.isFromSearch,
);
},
),
widget.isFromSearch
? Consumer<FeedProvider>(
builder: (context, value, child) =>
value.getSearchAppBarVisible
? Align(
alignment: Alignment.topCenter,
child: NewsCardAppBar(),
)
: Container(),
)
: Container()
],
),
);
}
@override
bool get wantKeepAlive => true;
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/view | mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/settings_screen/settings.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:feather_icons_flutter/feather_icons_flutter.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
// Project imports:
import 'package:inshort_clone/controller/settings.dart';
import 'package:inshort_clone/global/global.dart';
import 'package:inshort_clone/style/colors.dart';
import 'package:inshort_clone/style/text_style.dart';
import '../../aplication_localization.dart';
class SettingsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 1,
title: Text(
AppLocalizations.of(context).translate('settings'),
style: AppTextStyle.appBarTitle.copyWith(
fontSize: 18,
color: Provider.of<SettingsProvider>(context, listen: false)
.isDarkThemeOn
? AppColor.background
: AppColor.onBackground,
),
),
),
body: Consumer<SettingsProvider>(
builder: (context, settingsProvider, child) => ListView(
children: <Widget>[
ListTile(
leading: Icon(FeatherIcons.sunset),
title: Text(AppLocalizations.of(context).translate('dark_theme')),
subtitle: Text(
AppLocalizations.of(context).translate('darktheme_message')),
onTap: () {
settingsProvider.darkTheme(!settingsProvider.isDarkThemeOn);
},
trailing: Switch(
activeColor: AppColor.accent,
value: settingsProvider.isDarkThemeOn,
onChanged: (status) {
settingsProvider.darkTheme(status);
}),
),
ListTile(
leading: Icon(FontAwesomeIcons.language),
title: Text(AppLocalizations.of(context).translate('language')),
onTap: () {},
trailing: DropdownButton(
underline: Container(),
value: settingsProvider.activeLanguge,
items: Global.lang.map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (v) {
settingsProvider.setLang(v);
}),
)
],
),
),
);
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/view | mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/web_screen/web.dart | // Dart imports:
import 'dart:async';
// Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:feather_icons_flutter/feather_icons_flutter.dart';
import 'package:provider/provider.dart';
import 'package:webview_flutter/webview_flutter.dart';
// Project imports:
import 'package:inshort_clone/controller/feed_controller.dart';
import 'package:inshort_clone/controller/provider.dart';
class WebScreen extends StatefulWidget {
final String url;
final bool isFromBottom;
final PageController pageController;
WebScreen(
{@required this.url, @required this.isFromBottom, this.pageController});
@override
_WebScreenState createState() => _WebScreenState();
}
class _WebScreenState extends State<WebScreen> {
bool loading = true;
final Completer<WebViewController> _webViewController =
Completer<WebViewController>();
@override
Widget build(BuildContext context) {
String url = Provider.of<FeedProvider>(context, listen: false).getNewsURL;
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
elevation: 0,
centerTitle: true,
backgroundColor: Colors.black,
leading: IconButton(
icon: Icon(FeatherIcons.chevronLeft),
onPressed: () {
widget.isFromBottom
? Navigator.pop(context)
: widget.pageController != null
? widget.pageController.jumpToPage(0)
: FeedController.addCurrentPage(1);
}),
actions: <Widget>[
FutureBuilder<WebViewController>(
future: _webViewController.future,
builder: (BuildContext context,
AsyncSnapshot<WebViewController> snapshot) {
final bool webViewReady =
snapshot.connectionState == ConnectionState.done;
final WebViewController controller = snapshot.data;
return IconButton(
icon: const Icon(Icons.replay),
onPressed: !webViewReady
? null
: () {
setState(() {
loading = true;
});
controller.reload();
},
);
}),
],
title: Text(
url.split("/")[2],
style: TextStyle(fontWeight: FontWeight.w300, fontSize: 12),
),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
loading
? SizedBox(height: 3, child: LinearProgressIndicator())
: Container(),
Expanded(
child: WebView(
initialUrl: url,
debuggingEnabled: true,
javascriptMode: JavascriptMode.unrestricted,
gestureNavigationEnabled: true,
onPageFinished: (d) {
setState(() {
loading = false;
});
},
onWebViewCreated: (WebViewController webViewController) {
_webViewController.complete(webViewController);
},
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/view | mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/discover_screen/discover.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:provider/provider.dart';
// Project imports:
import 'package:inshort_clone/aplication_localization.dart';
import 'package:inshort_clone/bloc/feed/news_feed_bloc.dart';
import 'package:inshort_clone/bloc/feed/news_feed_event.dart';
import 'package:inshort_clone/controller/feed_controller.dart';
import 'package:inshort_clone/controller/provider.dart';
import 'package:inshort_clone/view/discover_screen/widgets/category_card.dart';
import 'package:inshort_clone/view/discover_screen/widgets/headline.dart';
import 'package:inshort_clone/view/discover_screen/widgets/topics_card.dart';
import 'widgets/app_bar.dart';
class DiscoverScreen extends StatefulWidget {
@override
_DiscoverScreenState createState() => _DiscoverScreenState();
}
class _DiscoverScreenState extends State<DiscoverScreen> {
var bloc;
@override
void initState() {
bloc = BlocProvider.of<NewsFeedBloc>(context);
super.initState();
}
@override
Widget build(BuildContext context) {
final provider = Provider.of<FeedProvider>(context, listen: false);
provider.setAppBarVisible(true);
return Scaffold(
appBar: appSearchBar(context),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
height: 16,
),
headLine(AppLocalizations.of(context).translate("categories")),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Consumer<FeedProvider>(
builder: (context, value, child) => Row(
children: <Widget>[
CategoryCard(
title:
AppLocalizations.of(context).translate("my_feed"),
icon: "all",
active: provider.getActiveCategory == 1,
onTap: () {
provider.setActiveCategory(1);
provider.setAppBarTitle(AppLocalizations.of(context)
.translate("my_feed"));
bloc.add(
FetchNewsByCategoryEvent(category: "general"),
);
},
),
CategoryCard(
title:
AppLocalizations.of(context).translate("trending"),
icon: "trending",
active: provider.getActiveCategory == 2,
onTap: () {
provider.setActiveCategory(2);
provider.setAppBarTitle(AppLocalizations.of(context)
.translate("trending"));
bloc.add(
FetchNewsByTopicEvent(topic: "trending"),
);
},
),
CategoryCard(
title:
AppLocalizations.of(context).translate("bookmark"),
icon: "bookmark",
active: provider.getActiveCategory == 3,
onTap: () {
provider.setActiveCategory(3);
provider.setAppBarTitle(AppLocalizations.of(context)
.translate("bookmark"));
bloc.add(
FetchNewsFromLocalStorageEvent(box: 'bookmarks'),
);
},
),
CategoryCard(
title:
AppLocalizations.of(context).translate("unreads"),
icon: "unread",
active: provider.getActiveCategory == 4,
onTap: () {
provider.setActiveCategory(4);
provider.setAppBarTitle(AppLocalizations.of(context)
.translate("unreads"));
bloc.add(
FetchNewsFromLocalStorageEvent(box: 'unreads'),
);
},
),
],
),
),
),
),
SizedBox(
height: 16,
),
headLine(AppLocalizations.of(context).translate("sugested_topics")),
Padding(
padding: const EdgeInsets.all(4.0),
child: GridView.count(
shrinkWrap: true,
childAspectRatio: (1 / 1.4),
physics: NeverScrollableScrollPhysics(),
crossAxisCount: 3,
children: <Widget>[
TopicCard(
title:
AppLocalizations.of(context).translate("coronavirus"),
icon: "coronavirus",
onTap: () {
provider.setAppBarTitle(AppLocalizations.of(context)
.translate("coronavirus"));
FeedController.addCurrentPage(1);
bloc.add(
FetchNewsByTopicEvent(topic: "coronavirus"),
);
},
),
TopicCard(
title: AppLocalizations.of(context).translate("india"),
icon: "india",
onTap: () {
provider.setAppBarTitle(
AppLocalizations.of(context).translate("india"));
FeedController.addCurrentPage(1);
bloc.add(
FetchNewsByTopicEvent(topic: "india"),
);
},
),
TopicCard(
title: AppLocalizations.of(context).translate("business"),
icon: "business",
onTap: () {
provider.setAppBarTitle(
AppLocalizations.of(context).translate("business"));
FeedController.addCurrentPage(1);
bloc.add(
FetchNewsByCategoryEvent(category: "business"),
);
},
),
TopicCard(
title: AppLocalizations.of(context).translate("politics"),
icon: "politics",
onTap: () {
provider.setAppBarTitle(
AppLocalizations.of(context).translate("politics"));
FeedController.addCurrentPage(1);
bloc.add(
FetchNewsByTopicEvent(topic: "politics"),
);
},
),
TopicCard(
title: AppLocalizations.of(context).translate("sports"),
icon: "sports",
onTap: () {
provider.setAppBarTitle(
AppLocalizations.of(context).translate("sports"));
FeedController.addCurrentPage(1);
bloc.add(
FetchNewsByCategoryEvent(category: "sports"),
);
},
),
TopicCard(
title: AppLocalizations.of(context).translate("technology"),
icon: "technology",
onTap: () {
provider.setAppBarTitle(
AppLocalizations.of(context).translate("technology"));
FeedController.addCurrentPage(1);
bloc.add(
FetchNewsByCategoryEvent(category: "technology"),
);
},
),
TopicCard(
title: AppLocalizations.of(context).translate("startups"),
icon: "startups",
onTap: () {
provider.setAppBarTitle(
AppLocalizations.of(context).translate("startups"));
FeedController.addCurrentPage(1);
bloc.add(
FetchNewsByTopicEvent(topic: "startups"),
);
},
),
TopicCard(
title:
AppLocalizations.of(context).translate("entertainment"),
icon: "entertainment",
onTap: () {
provider.setAppBarTitle(AppLocalizations.of(context)
.translate("entertainment"));
FeedController.addCurrentPage(1);
bloc.add(
FetchNewsByCategoryEvent(category: "entertainment"),
);
},
),
TopicCard(
title: AppLocalizations.of(context).translate("education"),
icon: "education",
onTap: () {
provider.setAppBarTitle(
AppLocalizations.of(context).translate("education"));
FeedController.addCurrentPage(1);
bloc.add(
FetchNewsByTopicEvent(topic: "education"),
);
},
),
TopicCard(
title: AppLocalizations.of(context).translate("automobile"),
icon: "automobile",
onTap: () {
provider.setAppBarTitle(
AppLocalizations.of(context).translate("automobile"));
FeedController.addCurrentPage(1);
bloc.add(
FetchNewsByTopicEvent(topic: "automobile"),
);
},
),
TopicCard(
title: AppLocalizations.of(context).translate("science"),
icon: "science",
onTap: () {
provider.setAppBarTitle(
AppLocalizations.of(context).translate("science"));
FeedController.addCurrentPage(1);
bloc.add(
FetchNewsByCategoryEvent(category: "science"),
);
},
),
TopicCard(
title: AppLocalizations.of(context).translate("travel"),
icon: "travel",
onTap: () {
provider.setAppBarTitle(
AppLocalizations.of(context).translate("travel"));
FeedController.addCurrentPage(1);
bloc.add(
FetchNewsByTopicEvent(topic: "travel"),
);
},
),
TopicCard(
title: AppLocalizations.of(context).translate("fashion"),
icon: "fashion",
onTap: () {
provider.setAppBarTitle(
AppLocalizations.of(context).translate("fashion"));
FeedController.addCurrentPage(1);
bloc.add(
FetchNewsByTopicEvent(topic: "fashion"),
);
},
),
],
),
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/discover_screen | mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/discover_screen/widgets/category_card.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Project imports:
import 'package:inshort_clone/controller/feed_controller.dart';
import 'package:inshort_clone/global/global.dart';
import 'package:inshort_clone/style/colors.dart';
import 'package:inshort_clone/style/text_style.dart';
class CategoryCard extends StatelessWidget {
final String icon;
final String title;
final Function onTap;
final bool active;
const CategoryCard(
{Key key, this.icon, this.title, this.onTap, this.active = false})
: super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
onTap();
FeedController.addCurrentPage(1);
},
child: Container(
margin: const EdgeInsets.all(8),
height: Global.height(context) * 0.14,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Opacity(
opacity: active ? 1 : 0.5,
child: Image.asset(
"assets/icons/$icon.png",
height: 70,
width: 70,
fit: BoxFit.contain,
),
),
Text(
title,
style: active
? AppTextStyle.categoryTitle.copyWith(
color: AppColor.accent,
fontSize: 16,
fontWeight: FontWeight.w500)
: AppTextStyle.categoryTitle,
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/discover_screen | mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/discover_screen/widgets/topics_card.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Project imports:
import 'package:inshort_clone/controller/feed_controller.dart';
import 'package:inshort_clone/global/global.dart';
import 'package:inshort_clone/style/colors.dart';
import 'package:inshort_clone/style/text_style.dart';
class TopicCard extends StatelessWidget {
final String icon;
final String title;
final Function onTap;
const TopicCard({Key key, this.icon, this.title, this.onTap})
: super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
FeedController.addCurrentPage(1);
onTap();
},
child: Container(
margin: const EdgeInsets.all(8),
height: Global.height(context) * 0.2,
decoration: BoxDecoration(
border: Border.all(
color: AppColor.accent,
),
// color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
child: Stack(
fit: StackFit.expand,
children: <Widget>[
Align(
alignment: Alignment.center,
child: Image.asset(
"assets/icons/$icon.png",
fit: BoxFit.contain,
),
),
Align(
alignment: Alignment.bottomLeft,
child: Padding(
padding: const EdgeInsets.all(6.0),
child: Text(
title,
style: AppTextStyle.topiccardTitle,
overflow: TextOverflow.ellipsis,
),
),
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/discover_screen | mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/discover_screen/widgets/headline.dart | // Flutter imports:
import 'package:flutter/cupertino.dart';
// Project imports:
import 'package:inshort_clone/style/colors.dart';
import 'package:inshort_clone/style/text_style.dart';
Widget headLine(String title) {
return Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
title,
style: AppTextStyle.headline,
),
SizedBox(
height: 8,
),
Container(
width: 36,
height: 2.5,
color: AppColor.iconGrey,
),
],
),
);
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/discover_screen | mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/discover_screen/widgets/app_bar.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:feather_icons_flutter/feather_icons_flutter.dart';
// Project imports:
import 'package:inshort_clone/aplication_localization.dart';
import 'package:inshort_clone/routes/rouut.dart';
import 'package:inshort_clone/style/colors.dart';
appSearchBar(context) {
return PreferredSize(
child: Material(
elevation: 1,
// color: Colors.white,
child: GestureDetector(
onTap: () {
Rouut.navigator.pushNamed(Rouut.searchScreen);
},
child: Container(
margin: const EdgeInsets.fromLTRB(16, 98, 16, 16),
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: AppColor.surface,
borderRadius: BorderRadius.circular(10),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
FeatherIcons.search,
color: AppColor.iconGrey,
),
SizedBox(width: 16),
Text(
AppLocalizations.of(context).translate("search_message"),
style: TextStyle(
color: AppColor.iconGrey,
fontWeight: FontWeight.w500,
fontSize: 16,
),
),
],
),
),
),
),
preferredSize: Size.fromHeight(142),
);
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/view | mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/photo_view/photo_expanded_screen.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:feather_icons_flutter/feather_icons_flutter.dart';
import 'package:photo_view/photo_view.dart';
class ExpandedImageView extends StatelessWidget {
final image;
ExpandedImageView({@required this.image});
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Stack(
children: [
Positioned.fill(
child: PhotoView(
imageProvider: NetworkImage(image),
// heroAttributes: PhotoViewHeroAttributes(
// transitionOnUserGestures: true,
// ),
),
),
Align(
alignment: Alignment.topLeft,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: IconButton(
icon: Icon(
FeatherIcons.x,
size: 30,
color: Colors.white,
),
onPressed: () => Navigator.pop(context)),
),
)
],
),
),
);
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/view | mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/search_screen/search.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:feather_icons_flutter/feather_icons_flutter.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
// Project imports:
import 'package:inshort_clone/aplication_localization.dart';
import 'package:inshort_clone/bloc/serach_feed/search_feed_bloc.dart';
import 'package:inshort_clone/bloc/serach_feed/search_feed_event.dart';
import 'package:inshort_clone/bloc/serach_feed/search_feed_state.dart';
import 'package:inshort_clone/style/text_style.dart';
import 'package:inshort_clone/view/search_screen/widget/search_news_card.dart';
class SearchScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
TextEditingController _searchController = TextEditingController();
return SafeArea(
bottom: false,
child: Scaffold(
appBar: AppBar(
elevation: 1,
backgroundColor: Theme.of(context).cardColor,
title: TextField(
autofocus: true,
controller: _searchController,
textInputAction: TextInputAction.search,
style: AppTextStyle.searchbar,
decoration: InputDecoration(
hintText:
AppLocalizations.of(context).translate("search_message"),
border: InputBorder.none,
suffixIcon: IconButton(
icon: Icon(
FeatherIcons.x,
),
onPressed: () => _searchController.clear(),
),
hintStyle: AppTextStyle.searchbar.copyWith(),
),
onSubmitted: (s) {
BlocProvider.of<SearchFeedBloc>(context)
..add(
FetchNewsBySearchQueryEvent(query: _searchController.text));
},
),
leading: IconButton(
icon: Icon(
FeatherIcons.arrowLeft,
),
onPressed: () {
Navigator.pop(context);
},
),
),
body: BlocBuilder<SearchFeedBloc, SearchFeedState>(
builder: (context, state) {
if (state is SearchFeedInitialState) {
return Container();
} else if (state is SearchFeedLoadingState) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularProgressIndicator(),
SizedBox(height: 16),
Text(
AppLocalizations.of(context).translate("loading_message"),
style: AppTextStyle.searchbar,
)
]));
} else if (state is SearchFeedLoadedState) {
if (state.news.length == 0) {
return Center(
child: Text(
"${AppLocalizations.of(context).translate("not_found")}\n",
style: AppTextStyle.newsTitle,
));
}
return ListView.builder(
itemCount: state.news.length,
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) {
return SearchNewsCard(
articles: state.news,
index: index,
);
},
);
} else if (state is SearchFeedErrorState) {
return Container(
padding: const EdgeInsets.all(16),
height: double.maxFinite,
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
AppLocalizations.of(context).translate('error'),
style: AppTextStyle.newsTitle,
),
SizedBox(height: 8),
Text(
AppLocalizations.of(context).translate('error_message'),
style: AppTextStyle.searchbar,
textAlign: TextAlign.center,
)
],
),
);
}
return Container();
},
),
),
);
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/search_screen | mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/search_screen/widget/search_news_card.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:intl/intl.dart';
// Project imports:
import 'package:inshort_clone/global/global.dart';
import 'package:inshort_clone/model/news_model.dart';
import 'package:inshort_clone/routes/rouut.dart';
import 'package:inshort_clone/style/colors.dart';
class SearchNewsCard extends StatelessWidget {
final List<Articles> articles;
final int index;
const SearchNewsCard({Key key, this.articles, this.index}) : super(key: key);
@override
Widget build(BuildContext context) {
var article = articles[index];
return GestureDetector(
onTap: () => Rouut.navigator.pushNamed(
Rouut.feedScreen,
arguments: FeedScreenArguments(
articalIndex: index, articals: articles, isFromSearch: true),
),
child: Padding(
padding: const EdgeInsets.only(
right: 16,
),
child: Column(
children: <Widget>[
Container(
height: Global.width(context) * 0.18,
child: Row(
children: <Widget>[
Container(
width: Global.width(context) * 0.18,
height: Global.width(context) * 0.18,
color: AppColor.surface,
child: article.urlToImage != null
? Image.network(
article.urlToImage,
fit: BoxFit.cover,
)
: Container(),
),
Expanded(
child: Padding(
padding:
const EdgeInsets.only(left: 16.0, top: 8, bottom: 8),
child: Text(
article.title,
overflow: TextOverflow.fade,
style: TextStyle(
// color: AppColor.onBackground,
fontSize: 14,
height: 1.2,
fontWeight: FontWeight.w300),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Align(
alignment: Alignment.bottomCenter,
child: Text(
DateFormat("MMMM d").format(
DateTime.parse(article.publishedAt),
),
style: TextStyle(
color: Colors.grey,
fontSize: 12,
fontWeight: FontWeight.w300),
),
),
),
],
),
),
Padding(
padding: EdgeInsets.only(
left: Global.width(context) * 0.22,
),
child: Divider(
height: 1,
color: AppColor.grey,
),
)
],
),
),
);
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/view | mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/app_base/app_base.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:provider/provider.dart';
// Project imports:
import 'package:inshort_clone/bloc/feed/news_feed_bloc.dart';
import 'package:inshort_clone/bloc/feed/news_feed_event.dart';
import 'package:inshort_clone/bloc/feed/news_feed_state.dart';
import 'package:inshort_clone/common/loading_shorts.dart';
import 'package:inshort_clone/common/widgets/appbar.dart';
import 'package:inshort_clone/controller/feed_controller.dart';
import 'package:inshort_clone/controller/provider.dart';
import 'package:inshort_clone/style/text_style.dart';
import 'package:inshort_clone/view/feed_screen/feed.dart';
import 'package:inshort_clone/view/web_screen/web.dart';
import '../../aplication_localization.dart';
class AppBase extends StatefulWidget {
@override
_AppBaseState createState() => _AppBaseState();
}
class _AppBaseState extends State<AppBase> with AutomaticKeepAliveClientMixin {
int currentPage = 1;
PageController _pageController;
FeedProvider provider;
@override
void initState() {
provider = Provider.of<FeedProvider>(context, listen: false);
BlocProvider.of<NewsFeedBloc>(context)
..add(
FetchNewsByCategoryEvent(category: "general"),
);
_pageController = PageController(
initialPage: currentPage,
);
provider.setScreenController(_pageController);
FeedController.getCurrentPage((page) {
_pageController.jumpToPage(page);
});
super.initState();
}
@override
Widget build(BuildContext context) {
super.build(context);
return Consumer<FeedProvider>(
builder: (context, value, child) => Scaffold(
resizeToAvoidBottomInset: false,
body: Stack(
fit: StackFit.expand,
children: <Widget>[
PageView(
controller: _pageController,
onPageChanged: (page) {
currentPage = _pageController.page.round();
if (currentPage == 2) {
value.setAppBarVisible(false);
} else {
value.setAppBarVisible(true);
}
},
children: provider.getBaseScreenList,
),
value.getAppBarVisible
? Align(
alignment: Alignment.topCenter,
child: CustomAppBar(
index: currentPage,
),
)
: Container(),
],
),
),
);
}
@override
bool get wantKeepAlive => true;
}
class BuildNewsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final provider = Provider.of<FeedProvider>(context, listen: false);
return BlocBuilder<NewsFeedBloc, NewsFeedState>(
builder: (context, state) {
if (state is NewsFeedInitialState) {
return Container();
} else if (state is NewsFeedLoadingState) {
return LoadingShorts();
} else if (state is NewsFeedLoadedState) {
if (state.news.length == 0) {
return Center(
child: Text(
"${AppLocalizations.of(context).translate('not_found')}\n",
style: AppTextStyle.newsTitle,
),
);
}
if (provider.webviwAdded == false) {
provider.addWebScren(
WebScreen(
url: provider.getNewsURL,
isFromBottom: false,
),
);
}
return FeedScreen(
isFromSearch: false,
articalIndex: 0,
articals: state.news,
);
} else if (state is NewsFeedErrorState) {
provider.setDataLoaded(true);
print(state.message);
return Container(
height: double.maxFinite,
width: double.maxFinite,
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
AppLocalizations.of(context).translate('error'),
style: AppTextStyle.newsTitle,
),
SizedBox(height: 8),
Text(
AppLocalizations.of(context).translate('error_message'),
style: AppTextStyle.searchbar,
textAlign: TextAlign.center,
)
],
),
);
}
return Container();
},
);
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/view | mirrored_repositories/Inshorts-Clone-The-News-App/lib/view/bookmarked_screen/bookmark.dart | // Flutter imports:
import 'package:flutter/material.dart';
class BookmarkScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container();
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib | mirrored_repositories/Inshorts-Clone-The-News-App/lib/routes/routes.dart | // Package imports:
import 'package:auto_route/auto_route_annotations.dart';
// Project imports:
import 'package:inshort_clone/view/app_base/app_base.dart';
import 'package:inshort_clone/view/bookmarked_screen/bookmark.dart';
import 'package:inshort_clone/view/discover_screen/discover.dart';
import 'package:inshort_clone/view/feed_screen/feed.dart';
import 'package:inshort_clone/view/photo_view/photo_expanded_screen.dart';
import 'package:inshort_clone/view/search_screen/search.dart';
import 'package:inshort_clone/view/settings_screen/settings.dart';
import 'package:inshort_clone/view/web_screen/web.dart';
@autoRouter
class $Router {
SearchScreen searchScreen;
SettingsScreen settingsScreen;
BookmarkScreen bookmarkScreen;
WebScreen webScreen;
DiscoverScreen discoverScreen;
FeedScreen feedScreen;
ExpandedImageView expandedView;
@initial
AppBase appBase;
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib | mirrored_repositories/Inshorts-Clone-The-News-App/lib/routes/rouut.dart | // Flutter imports:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// Package imports:
import 'package:auto_route/router_utils.dart';
// Project imports:
import 'package:inshort_clone/model/news_model.dart';
import 'package:inshort_clone/view/app_base/app_base.dart';
import 'package:inshort_clone/view/bookmarked_screen/bookmark.dart';
import 'package:inshort_clone/view/discover_screen/discover.dart';
import 'package:inshort_clone/view/feed_screen/feed.dart';
import 'package:inshort_clone/view/photo_view/photo_expanded_screen.dart';
import 'package:inshort_clone/view/search_screen/search.dart';
import 'package:inshort_clone/view/settings_screen/settings.dart';
import 'package:inshort_clone/view/web_screen/web.dart';
class Rouut {
static const searchScreen = '/search-screen';
static const settingsScreen = '/settings-screen';
static const bookmarkScreen = '/bookmark-screen';
static const webScreen = '/web-screen';
static const discoverScreen = '/discover-screen';
static const feedScreen = '/feed-screen';
static const appBase = '/';
static const expandedImageView = '/expandedImageView';
static GlobalKey<NavigatorState> get navigatorKey =>
getNavigatorKey<Rouut>();
static NavigatorState get navigator => navigatorKey.currentState;
static Route<dynamic> onGenerateRoute(RouteSettings settings) {
final args = settings.arguments;
switch (settings.name) {
case Rouut.searchScreen:
return MaterialPageRoute(
builder: (_) => SearchScreen(),
settings: settings,
);
case Rouut.settingsScreen:
return MaterialPageRoute(
builder: (_) => SettingsScreen(),
settings: settings,
);
case Rouut.bookmarkScreen:
return MaterialPageRoute(
builder: (_) => BookmarkScreen(),
settings: settings,
);
case Rouut.webScreen:
if (hasInvalidArgs<WebViewArguments>(args, isRequired: true)) {
return misTypedArgsRoute<WebViewArguments>(args);
}
final typedArgs = args as WebViewArguments;
return MaterialPageRoute(
builder: (_) => WebScreen(
url: typedArgs.url,
isFromBottom: typedArgs.isFromBottom,
),
settings: settings,
);
case Rouut.discoverScreen:
return MaterialPageRoute(
builder: (_) => DiscoverScreen(),
settings: settings,
);
case Rouut.expandedImageView:
if (hasInvalidArgs<ExpandedImageViewArguments>(args,
isRequired: true)) {
return misTypedArgsRoute<ExpandedImageViewArguments>(args);
}
final typedArgs = args as ExpandedImageViewArguments;
return MaterialPageRoute(
builder: (_) => ExpandedImageView(
image: typedArgs.image,
),
settings: settings,
);
case Rouut.feedScreen:
if (hasInvalidArgs<FeedScreenArguments>(args, isRequired: true)) {
return misTypedArgsRoute<FeedScreenArguments>(args);
}
final typedArgs = args as FeedScreenArguments;
return MaterialPageRoute(
builder: (_) => FeedScreen(
key: typedArgs.key,
articalIndex: typedArgs.articalIndex,
articals: typedArgs.articals,
isFromSearch: typedArgs.isFromSearch),
settings: settings,
);
case Rouut.appBase:
return MaterialPageRoute(
builder: (_) => AppBase(),
settings: settings,
);
default:
return unknownRoutePage(settings.name);
}
}
}
//**************************************************************************
// Arguments holder classes
//***************************************************************************
//FeedScreen arguments holder class
class FeedScreenArguments {
final Key key;
final int articalIndex;
final List<Articles> articals;
final bool isFromSearch;
FeedScreenArguments(
{this.key,
@required this.articalIndex,
@required this.articals,
@required this.isFromSearch});
}
class ExpandedImageViewArguments {
final String image;
ExpandedImageViewArguments({
@required this.image,
});
}
class WebViewArguments {
final String url;
final bool isFromBottom;
WebViewArguments({@required this.url, @required this.isFromBottom});
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/bloc | mirrored_repositories/Inshorts-Clone-The-News-App/lib/bloc/serach_feed/search_feed_state.dart | // Package imports:
import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';
// Project imports:
import 'package:inshort_clone/model/news_model.dart';
abstract class SearchFeedState extends Equatable {}
class SearchFeedInitialState extends SearchFeedState {
@override
List<Object> get props => [];
}
class SearchFeedLoadingState extends SearchFeedState {
@override
List<Object> get props => [];
}
class SearchFeedLoadedState extends SearchFeedState {
final List<Articles> news;
SearchFeedLoadedState({@required this.news});
get moviesList => news;
@override
List<Object> get props => null;
}
class SearchFeedErrorState extends SearchFeedState {
final String message;
SearchFeedErrorState({@required this.message});
@override
List<Object> get props => null;
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/bloc | mirrored_repositories/Inshorts-Clone-The-News-App/lib/bloc/serach_feed/search_feed_event.dart | // Flutter imports:
import 'package:flutter/foundation.dart';
// Package imports:
import 'package:equatable/equatable.dart';
abstract class SearchFeedEvent extends Equatable {}
class FetchNewsBySearchQueryEvent extends SearchFeedEvent {
final String query;
FetchNewsBySearchQueryEvent({@required this.query});
List<Object> get props => [query];
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/bloc | mirrored_repositories/Inshorts-Clone-The-News-App/lib/bloc/serach_feed/search_feed_bloc.dart | // Flutter imports:
import 'package:flutter/cupertino.dart';
// Package imports:
import 'package:bloc/bloc.dart';
// Project imports:
import 'package:inshort_clone/model/news_model.dart';
import 'package:inshort_clone/services/news/news_service.dart';
import 'search_feed_event.dart';
import 'search_feed_state.dart';
class SearchFeedBloc extends Bloc<SearchFeedEvent, SearchFeedState> {
NewsFeedRepository repository;
SearchFeedBloc({@required this.repository});
@override
SearchFeedState get initialState => SearchFeedInitialState();
@override
Stream<SearchFeedState> mapEventToState(SearchFeedEvent event) async* {
if (event is FetchNewsBySearchQueryEvent) {
yield SearchFeedLoadingState();
try {
List<Articles> news =
await repository.getNewsBySearchQuery(event.query);
yield SearchFeedLoadedState(news: news);
} catch (e) {
yield SearchFeedErrorState(message: e.toString());
}
}
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/bloc | mirrored_repositories/Inshorts-Clone-The-News-App/lib/bloc/feed/news_feed_bloc.dart | // Flutter imports:
import 'package:flutter/cupertino.dart';
// Package imports:
import 'package:bloc/bloc.dart';
// Project imports:
import 'package:inshort_clone/bloc/feed/news_feed_event.dart';
import 'package:inshort_clone/bloc/feed/news_feed_state.dart';
import 'package:inshort_clone/model/news_model.dart';
import 'package:inshort_clone/services/news/news_service.dart';
class NewsFeedBloc extends Bloc<NewsFeedEvent, NewsFeedState> {
NewsFeedRepository repository;
NewsFeedBloc({@required this.repository});
@override
NewsFeedState get initialState => NewsFeedInitialState();
@override
Stream<NewsFeedState> mapEventToState(NewsFeedEvent event) async* {
if (event is FetchNewsByCategoryEvent) {
yield NewsFeedLoadingState();
try {
List<Articles> news =
await repository.getNewsByCategory(event.category);
yield NewsFeedLoadedState(news: news);
} catch (e) {
yield NewsFeedErrorState(message: e.toString());
}
} else if (event is FetchNewsByTopicEvent) {
yield NewsFeedLoadingState();
try {
List<Articles> news = await repository.getNewsByTopic(event.topic);
yield NewsFeedLoadedState(news: news);
} catch (e) {
yield NewsFeedErrorState(message: e.toString());
}
} else if (event is FetchNewsFromLocalStorageEvent) {
yield NewsFeedLoadingState();
try {
List<Articles> news = repository.getNewsFromLocalStorage(event.box);
yield NewsFeedLoadedState(news: news);
} catch (e) {
yield NewsFeedErrorState(message: e.toString());
}
}
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/bloc | mirrored_repositories/Inshorts-Clone-The-News-App/lib/bloc/feed/news_feed_event.dart | // Flutter imports:
import 'package:flutter/foundation.dart';
// Package imports:
import 'package:equatable/equatable.dart';
abstract class NewsFeedEvent extends Equatable {}
class FetchNewsByCategoryEvent extends NewsFeedEvent {
final String category;
FetchNewsByCategoryEvent({@required this.category});
List<Object> get props => [category];
}
class FetchNewsByTopicEvent extends NewsFeedEvent {
final String topic;
FetchNewsByTopicEvent({@required this.topic});
List<Object> get props => [topic];
}
class FetchNewsFromLocalStorageEvent extends NewsFeedEvent {
final String box;
FetchNewsFromLocalStorageEvent({@required this.box});
List<Object> get props => [box];
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/bloc | mirrored_repositories/Inshorts-Clone-The-News-App/lib/bloc/feed/news_feed_state.dart | // Package imports:
import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';
// Project imports:
import 'package:inshort_clone/model/news_model.dart';
abstract class NewsFeedState extends Equatable {}
class NewsFeedInitialState extends NewsFeedState {
@override
List<Object> get props => [];
}
class NewsFeedLoadingState extends NewsFeedState {
@override
List<Object> get props => [];
}
class NewsFeedLoadedState extends NewsFeedState {
final List<Articles> news;
NewsFeedLoadedState({@required this.news});
get moviesList => news;
@override
List<Object> get props => null;
}
class NewsFeedErrorState extends NewsFeedState {
final String message;
NewsFeedErrorState({@required this.message});
@override
List<Object> get props => null;
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib | mirrored_repositories/Inshorts-Clone-The-News-App/lib/model/news_model.dart | // Package imports:
import 'package:hive/hive.dart';
part 'news_model.g.dart';
class NewsModel {
String status;
int totalResults;
List<Articles> articles;
NewsModel({this.status, this.totalResults, this.articles});
NewsModel.fromJson(Map<String, dynamic> json) {
status = json['status'];
totalResults = json['totalResults'];
if (json['articles'] != null) {
articles = new List<Articles>();
json['articles'].forEach((v) {
articles.add(new Articles.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['status'] = this.status;
data['totalResults'] = this.totalResults;
if (this.articles != null) {
data['articles'] = this.articles.map((v) => v.toJson()).toList();
}
return data;
}
}
@HiveType(typeId: 101)
class Articles {
@HiveField(0)
String sourceName;
@HiveField(1)
String author;
@HiveField(2)
String title;
@HiveField(3)
String description;
@HiveField(4)
String url;
@HiveField(5)
String urlToImage;
@HiveField(6)
String publishedAt;
@HiveField(7)
String content;
Articles(
{this.sourceName,
this.author,
this.title,
this.description,
this.url,
this.urlToImage,
this.publishedAt,
this.content});
Articles.fromJson(Map<String, dynamic> json) {
sourceName = json['source'] != null
? new Source.fromJson(json['source']).name
: null;
author = json['author'];
title = json['title'];
description = json['description'];
url = json['url'];
urlToImage = json['urlToImage'];
publishedAt = json['publishedAt'];
content = json['content'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.sourceName != null) {
data['sourceName'] = this.sourceName;
}
data['author'] = this.author;
data['title'] = this.title;
data['description'] = this.description;
data['url'] = this.url;
data['urlToImage'] = this.urlToImage;
data['publishedAt'] = this.publishedAt;
data['content'] = this.content;
return data;
}
}
class Source {
String id;
String name;
Source({this.id, this.name});
Source.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
return data;
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib | mirrored_repositories/Inshorts-Clone-The-News-App/lib/model/news_model.g.dart | // GENERATED CODE - DO NOT MODIFY BY HAND
part of 'news_model.dart';
// **************************************************************************
// TypeAdapterGenerator
// **************************************************************************
class ArticlesAdapter extends TypeAdapter<Articles> {
@override
Articles read(BinaryReader reader) {
var numOfFields = reader.readByte();
var fields = <int, dynamic>{
for (var i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return Articles(
sourceName: fields[0] as String,
author: fields[1] as String,
title: fields[2] as String,
description: fields[3] as String,
url: fields[4] as String,
urlToImage: fields[5] as String,
publishedAt: fields[6] as String,
content: fields[7] as String,
);
}
@override
void write(BinaryWriter writer, Articles obj) {
writer
..writeByte(8)
..writeByte(0)
..write(obj.sourceName)
..writeByte(1)
..write(obj.author)
..writeByte(2)
..write(obj.title)
..writeByte(3)
..write(obj.description)
..writeByte(4)
..write(obj.url)
..writeByte(5)
..write(obj.urlToImage)
..writeByte(6)
..write(obj.publishedAt)
..writeByte(7)
..write(obj.content);
}
@override
int get typeId => 101;
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib | mirrored_repositories/Inshorts-Clone-The-News-App/lib/common/loading_shorts.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Project imports:
import 'package:inshort_clone/global/global.dart';
import 'package:inshort_clone/style/text_style.dart';
import '../aplication_localization.dart';
class LoadingShorts extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: Colors.black,
child: SafeArea(
child: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: Container(
constraints: BoxConstraints(
minHeight: Global.height(context),
minWidth: double.maxFinite,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
border: Border.all(width: 0.3),
color: Theme.of(context).scaffoldBackgroundColor,
),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Image.asset(
"assets/icons/loading.png",
fit: BoxFit.contain,
width: double.maxFinite,
height: Global.height(context) * 0.5,
),
SizedBox(
height: 8,
),
Text(
AppLocalizations.of(context).translate('loading_message'),
style: AppTextStyle.loading,
),
],
),
),
),
),
),
);
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/common | mirrored_repositories/Inshorts-Clone-The-News-App/lib/common/widgets/appbar.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:feather_icons_flutter/feather_icons_flutter.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:provider/provider.dart';
// Project imports:
import 'package:inshort_clone/aplication_localization.dart';
import 'package:inshort_clone/bloc/feed/news_feed_bloc.dart';
import 'package:inshort_clone/bloc/feed/news_feed_event.dart';
import 'package:inshort_clone/controller/feed_controller.dart';
import 'package:inshort_clone/controller/provider.dart';
import 'package:inshort_clone/global/global.dart';
import 'package:inshort_clone/routes/rouut.dart';
import 'package:inshort_clone/style/colors.dart';
import 'package:inshort_clone/style/text_style.dart';
class CustomAppBar extends StatelessWidget {
final int index;
const CustomAppBar({Key key, this.index = 1}) : super(key: key);
@override
Widget build(BuildContext context) {
return Consumer<FeedProvider>(
builder: (context, value, child) => SafeArea(
child: Material(
// color: Colors.white,
child: Container(
height: 52,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: Align(
alignment: Alignment.centerLeft,
child: index != 1
? IconButton(
icon: Icon(
FeatherIcons.settings,
),
onPressed: () {
// Router.navigator
// .pushNamed(Router.settingsScreen);
},
)
: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
IconButton(
icon: Icon(FeatherIcons.chevronLeft),
onPressed: () {
FeedController.addCurrentPage(0);
},
),
Text(
AppLocalizations.of(context)
.translate("discover"),
style: AppTextStyle.appBarTitle,
)
],
),
)),
Expanded(
child: Text(
index == 1
? value.getAppBarTitle != null
? value.getAppBarTitle
: AppLocalizations.of(context)
.translate("my_feed")
: AppLocalizations.of(context)
.translate("discover"),
style: AppTextStyle.appBarTitle.copyWith(
fontWeight: FontWeight.w600,
fontSize: 16,
),
textAlign: TextAlign.center,
),
),
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
index != 1
? Text(
value.getAppBarTitle != null
? value.getAppBarTitle
: AppLocalizations.of(context)
.translate("my_feed"),
style: AppTextStyle.appBarTitle,
overflow: TextOverflow.ellipsis,
textDirection: TextDirection.rtl,
)
: Container(),
getIcon(context)
],
),
),
)
],
),
Container(
width: Global.width(context) * 0.1,
height: 3,
color: AppColor.accent,
)
],
),
),
),
),
);
}
void bringToTop(PageController pageController) {
pageController.animateToPage(0,
duration: Duration(milliseconds: 700), curve: Curves.ease);
}
IconButton getIcon(context) {
final provider = Provider.of<FeedProvider>(context, listen: false);
if (index != 1) {
return IconButton(
icon: Icon(FeatherIcons.chevronRight),
onPressed: () {
FeedController.addCurrentPage(1);
});
} else {
if (provider.gethasDataLoaded) {
return provider.getCurentArticalIndex == 0
? IconButton(
icon: Icon(FeatherIcons.rotateCw),
onPressed: () {
reloade(context);
})
: IconButton(
icon: Icon(FeatherIcons.arrowUp),
onPressed: () => bringToTop(provider.getfeedPageController));
} else {
return IconButton(icon: Icon(FeatherIcons.loader), onPressed: null);
}
}
}
void reloade(context) {
final provider = Provider.of<FeedProvider>(context, listen: false);
print(provider.getLastGetRequest.elementAt(0));
switch (provider.getLastGetRequest.elementAt(0)) {
case "getNewsByTopic":
BlocProvider.of<NewsFeedBloc>(context)
..add(
FetchNewsByTopicEvent(
topic: provider.getLastGetRequest.elementAt(1)),
);
break;
case "getNewsByCategory":
BlocProvider.of<NewsFeedBloc>(context)
..add(
FetchNewsByCategoryEvent(
category: provider.getLastGetRequest.elementAt(1)),
);
break;
case "getNewsFromLocalStorage":
BlocProvider.of<NewsFeedBloc>(context)
..add(
FetchNewsFromLocalStorageEvent(
box: provider.getLastGetRequest.elementAt(1)),
);
break;
default:
return;
}
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/common | mirrored_repositories/Inshorts-Clone-The-News-App/lib/common/widgets/news_appbar.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:feather_icons_flutter/feather_icons_flutter.dart';
import 'package:provider/provider.dart';
// Project imports:
import 'package:inshort_clone/controller/provider.dart';
import 'package:inshort_clone/style/colors.dart';
import 'package:inshort_clone/style/text_style.dart';
class NewsCardAppBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SafeArea(
child: Material(
// color: Colors.white,
child: Container(
height: 52,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: Align(
alignment: Alignment.centerLeft,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
IconButton(
icon: Icon(FeatherIcons.chevronLeft),
color: AppColor.accent,
onPressed: () {
Navigator.pop(context);
},
),
Text(
"Search",
style: AppTextStyle.appBarTitle,
)
],
),
),
),
Spacer(),
Consumer<FeedProvider>(
builder: (context, value, child) =>
value.getCurentArticalIndex != 0
? IconButton(
icon: Icon(FeatherIcons.arrowUp),
onPressed: () {
value.getfeedPageController.animateToPage(0,
duration: Duration(milliseconds: 700),
curve: Curves.easeInBack);
})
: Container(),
)
],
),
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/common/widgets | mirrored_repositories/Inshorts-Clone-The-News-App/lib/common/widgets/news_card/bottom_bar.dart | // Dart imports:
import 'dart:ui';
// Flutter imports:
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
// Package imports:
import 'package:cached_network_image/cached_network_image.dart';
// Project imports:
import 'package:inshort_clone/model/news_model.dart';
import 'package:inshort_clone/style/colors.dart';
import 'package:inshort_clone/style/text_style.dart';
import 'package:inshort_clone/view/web_screen/web.dart';
import '../../../aplication_localization.dart';
class BottomBar extends StatelessWidget {
final Articles articles;
const BottomBar({Key key, this.articles}) : super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
WebScreen(url: articles.url, isFromBottom: true),
),
),
child: Container(
color: Theme.of(context).cardColor,
// elevation: 0,
child: Stack(
children: <Widget>[
Container(
width: double.maxFinite,
child: articles.urlToImage != null
? CachedNetworkImage(
imageUrl: articles.urlToImage,
fit: BoxFit.cover,
alignment: Alignment.center,
)
: Container(),
),
Positioned(
top: 0,
left: 0,
height: double.maxFinite,
width: double.maxFinite,
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
child: Container(
color: Colors.black.withOpacity(0.2),
),
),
),
Container(
width: double.maxFinite,
color: AppColor.onBackground.withOpacity(0.6),
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
articles.content != null
? articles.content.split(",")[0].replaceAll("\n", "")
: "",
maxLines: 1,
style: AppTextStyle.newsBottomTitle,
),
SizedBox(
height: 4,
),
Text(
AppLocalizations.of(context).translate("tap_message"),
style: AppTextStyle.newsBottomSubtitle,
overflow: TextOverflow.fade,
),
],
),
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/common/widgets | mirrored_repositories/Inshorts-Clone-The-News-App/lib/common/widgets/news_card/bottom_action_bar.dart | // Flutter imports:
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
// Package imports:
import 'package:feather_icons_flutter/feather_icons_flutter.dart';
import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:provider/provider.dart';
// Project imports:
import 'package:inshort_clone/controller/provider.dart';
import 'package:inshort_clone/model/news_model.dart';
import 'package:inshort_clone/services/news/offline_service.dart';
import 'package:inshort_clone/services/news/share_service.dart';
import 'package:inshort_clone/style/colors.dart';
import 'package:inshort_clone/style/text_style.dart';
import '../../../aplication_localization.dart';
class BottomActionBar extends StatelessWidget {
final containerKey;
final Articles articles;
const BottomActionBar({
Key key,
this.containerKey,
this.articles,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
width: double.maxFinite,
color: Theme.of(context).cardColor,
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
actionButton(
title: AppLocalizations.of(context).translate("share"),
icon: FeatherIcons.share2,
onTap: () {
Provider.of<FeedProvider>(context, listen: false)
.setWatermarkVisible(true);
Future.delayed(Duration(seconds: 2),
() => convertWidgetToImageAndShare(context, containerKey));
},
),
WatchBoxBuilder(
box: Hive.box<Articles>('bookmarks'),
builder: (context, snap) => actionButton(
title: AppLocalizations.of(context).translate("bookmark"),
icon: snap.containsKey(articles.url)
? Icons.bookmark
: FeatherIcons.bookmark,
onTap: () {
handleBookmarks(articles);
},
),
)
],
),
);
}
Widget actionButton({
@required String title,
@required IconData icon,
@required Function onTap,
}) {
return InkWell(
onTap: onTap,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
icon,
color: AppColor.accent,
),
SizedBox(
height: 8,
),
Text(
title,
style: AppTextStyle.bottomActionbar,
),
],
),
);
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/common/widgets | mirrored_repositories/Inshorts-Clone-The-News-App/lib/common/widgets/news_card/news_card.dart | // Dart imports:
import 'dart:ui';
// Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:cached_network_image/cached_network_image.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
// Project imports:
import 'package:inshort_clone/aplication_localization.dart';
import 'package:inshort_clone/controller/provider.dart';
import 'package:inshort_clone/controller/settings.dart';
import 'package:inshort_clone/global/global.dart';
import 'package:inshort_clone/model/news_model.dart';
import 'package:inshort_clone/routes/rouut.dart';
import 'package:inshort_clone/services/news/offline_service.dart';
import 'package:inshort_clone/style/colors.dart';
import 'package:inshort_clone/style/text_style.dart';
import 'bottom_action_bar.dart';
import 'bottom_bar.dart';
class NewsCard extends StatelessWidget {
final Articles article;
final bool isFromSearch;
const NewsCard({Key key, this.article, this.isFromSearch}) : super(key: key);
@override
build(BuildContext context) {
final provider = Provider.of<FeedProvider>(context, listen: false);
provider.setNewsURL(article.url);
removeArticleFromUnreads(article);
print(article.url);
return GestureDetector(
onTap: () {
provider.setAppBarVisible(!provider.getAppBarVisible);
provider.setSearchAppBarVisible(!provider.getSearchAppBarVisible);
provider.setFeedBottomActionbarVisible(
!provider.getFeedBottomActionbarVisible);
},
child: SafeArea(
bottom: false,
child: _buildCard(context, provider),
),
);
}
Widget _buildCard(BuildContext context, provider) {
GlobalKey _containerKey = GlobalKey();
return Consumer<FeedProvider>(builder: (context, value, _) {
return ClipRRect(
borderRadius: BorderRadius.circular(12),
child: Container(
constraints: BoxConstraints(
minHeight: Global.height(context),
minWidth: double.maxFinite,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
border: Border.all(width: 0.3),
),
child: RepaintBoundary(
key: _containerKey,
child: Container(
color: Theme.of(context).scaffoldBackgroundColor,
child: Stack(
fit: StackFit.expand,
children: <Widget>[
FractionallySizedBox(
alignment: Alignment.topCenter,
heightFactor: 0.4,
child: Stack(
fit: StackFit.expand,
children: <Widget>[
article.urlToImage != null
? Container(
decoration: BoxDecoration(
color: AppColor.surface,
image: DecorationImage(
image: NetworkImage(
article.urlToImage,
),
fit: BoxFit.cover,
),
),
)
: Container(
color: AppColor.surface,
),
Positioned(
top: 0,
left: 0,
height: double.maxFinite,
width: double.maxFinite,
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
child: Container(
color: Colors.black.withOpacity(0.8),
),
),
),
article.urlToImage != null
? GestureDetector(
// onTap: () => Router.navigator.pushNamed(
// Router.expandedImageView,
// arguments: ExpandedImageViewArguments(
// image: article.urlToImage,
// ),
// ),
child: Center(
child: CachedNetworkImage(
fit: BoxFit.cover,
alignment: Alignment.topCenter,
imageUrl: article.urlToImage,
),
),
)
: Container(),
],
),
),
FractionallySizedBox(
alignment: Alignment.bottomCenter,
heightFactor: 0.6,
child: Stack(
fit: StackFit.expand,
children: <Widget>[
FractionallySizedBox(
alignment: Alignment.topCenter,
heightFactor: 0.85,
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 25, 16, 16),
child: WatchBoxBuilder(
box: Hive.box<Articles>('bookmarks'),
builder: (context, box) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
GestureDetector(
onTap: () => handleBookmarks(article),
child: Text(
article.title,
style: box.containsKey(article.url)
? AppTextStyle.newsTitle
.copyWith(color: AppColor.accent)
: AppTextStyle.newsTitle,
overflow: TextOverflow.ellipsis,
maxLines: 4,
),
),
SizedBox(
height: 8,
),
Text(
article.description != null
? article.description
: "",
style: AppTextStyle.newsSubtitle,
overflow: TextOverflow.fade,
maxLines: 9,
),
SizedBox(
height: 16,
),
Text(
"${AppLocalizations.of(context).translate("swipe_message")} ${article.sourceName} / ${DateFormat("MMMM d").format(
DateTime.parse(article.publishedAt),
)}",
style: AppTextStyle.newsFooter,
)
],
),
),
),
),
FractionallySizedBox(
alignment: Alignment.bottomCenter,
heightFactor: 0.15,
child: BottomBar(
articles: article,
),
),
value.getFeedBottomActionbarVisible
? FractionallySizedBox(
alignment: Alignment.bottomCenter,
heightFactor: 0.15,
child: BottomActionBar(
containerKey: _containerKey,
articles: article,
))
: Container(),
value.getWatermarkVisible
? FractionallySizedBox(
alignment: Alignment.bottomCenter,
heightFactor: 0.17,
child: Material(
elevation: 0,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: <Widget>[
Consumer<SettingsProvider>(
builder:
(context, theme, child) =>
FaIcon(
FontAwesomeIcons.github,
size: 20,
color: theme.isDarkThemeOn
? Colors.white
: Colors.black,
),
),
SizedBox(width: 8),
Text("github/imSanjaySoni"),
],
),
Row(
children: [
Image.asset(
"assets/icons/logo.png",
height: 20,
width: 20,
),
SizedBox(width: 8),
Text("Inshorts Clone"),
],
),
],
),
),
))
: Container(),
],
),
),
],
),
),
),
),
);
});
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib | mirrored_repositories/Inshorts-Clone-The-News-App/lib/controller/feed_controller.dart | // Dart imports:
import 'dart:async';
class FeedController {
static StreamController _currentPage = StreamController<int>.broadcast();
static StreamController _currentArticleIndex =
StreamController<int>.broadcast();
static Stream<int> get _currentPageStream => _currentPage.stream;
static Stream<int> get _currentArticleIndexStream =>
_currentArticleIndex.stream;
static void addCurrentPage(int page) {
_currentPage.sink.add(page);
}
static void addCurrentArticleIndex(int index) {
_currentArticleIndex.sink.add(index);
}
static int getCurrentPage(Function function) {
int page = 1;
_currentPageStream.listen(
(onData) {
if (onData != null) {
page = onData;
function(onData);
}
},
);
return page;
}
static int getCurrentArticleIndex(Function function) {
int index = 0;
_currentArticleIndexStream.listen(
(onData) {
if (onData != null) {
index = onData;
function(onData);
}
},
);
return index;
}
static void dispos(String stream) {
_currentArticleIndex.close();
_currentPage.close();
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib | mirrored_repositories/Inshorts-Clone-The-News-App/lib/controller/settings.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:hive/hive.dart';
class SettingsProvider extends ChangeNotifier {
bool isDarkThemeOn = Hive.box('settingsBox').get('isDarkModeOn') ?? false;
String activeLanguge = Hive.box('settingsBox').get('activeLang') ?? "English";
String localeCode = "en";
String getActiveLanguageCode() {
final value = Hive.box('settingsBox').get('activeLang');
switch (value) {
case "ಕನ್ನಡ":
return "kn";
break;
case "हिंदी":
return "hi";
break;
case "मराठी":
return "mr";
break;
default:
return "en";
}
}
void darkTheme(bool status) {
isDarkThemeOn = status;
final themeBox = Hive.box('settingsBox');
themeBox.put('isDarkModeOn', status);
print(themeBox.get('isDarkModeOn'));
notifyListeners();
}
void setLang(String value) {
activeLanguge = value;
final langBox = Hive.box('settingsBox');
switch (value) {
case "ಕನ್ನಡ":
langBox.put('activeLang', "ಕನ್ನಡ");
localeCode = "kn";
notifyListeners();
break;
case "हिंदी":
langBox.put('activeLang', "हिंदी");
localeCode = "hi";
notifyListeners();
break;
case "मराठी":
langBox.put('activeLang', "मराठी");
localeCode = "mr";
notifyListeners();
break;
default:
langBox.put('activeLang', "English");
localeCode = "en";
notifyListeners();
}
notifyListeners();
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib | mirrored_repositories/Inshorts-Clone-The-News-App/lib/controller/provider.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Project imports:
import 'package:inshort_clone/view/app_base/app_base.dart';
import 'package:inshort_clone/view/discover_screen/discover.dart';
class FeedProvider extends ChangeNotifier {
String _appBarTitle;
int _activeCategory = 1;
bool _hasDataLoaded = false;
bool _searchAppBarVisible = true;
bool _appBarVisible = false;
bool _watermarkVisible = false;
bool _feedBottomActionbarVisible = false;
int _curentArticalIndex = 0;
PageController _feedPageController;
PageController _screenController;
List<Widget> _baseScreen = [
DiscoverScreen(),
BuildNewsScreen(),
];
String _newsURL = "https://google.com/";
bool _webviwAdded = false;
List<String> _lastGetRequest = List<String>();
//
bool get gethasDataLoaded => this._hasDataLoaded;
int get getActiveCategory => this._activeCategory;
String get getAppBarTitle => this._appBarTitle;
bool get getSearchAppBarVisible => this._searchAppBarVisible;
bool get getAppBarVisible => this._appBarVisible;
bool get getWatermarkVisible => this._watermarkVisible;
bool get getFeedBottomActionbarVisible => this._feedBottomActionbarVisible;
int get getCurentArticalIndex => this._curentArticalIndex;
PageController get getfeedPageController => this._feedPageController;
PageController get getScreenController => this._screenController;
List<Widget> get getBaseScreenList => this._baseScreen;
String get getNewsURL => _newsURL;
List<String> get getLastGetRequest => _lastGetRequest;
bool get webviwAdded => _webviwAdded;
///
void setActiveCategory(int activeCategory) {
this._activeCategory = activeCategory;
notifyListeners();
}
void setAppBarTitle(String appBarTitle) {
this._appBarTitle = appBarTitle;
notifyListeners();
}
void setDataLoaded(bool status) {
this._hasDataLoaded = status;
notifyListeners();
}
void setSearchAppBarVisible(bool searchAppBarVisible) {
this._searchAppBarVisible = searchAppBarVisible;
notifyListeners();
}
void setAppBarVisible(bool appBarVisible) {
this._appBarVisible = appBarVisible;
notifyListeners();
}
void setWatermarkVisible(bool visible) {
this._watermarkVisible = visible;
notifyListeners();
}
void setFeedBottomActionbarVisible(bool feedBottomActionbarVisible) {
this._feedBottomActionbarVisible = feedBottomActionbarVisible;
notifyListeners();
}
void setCurentArticalIndex(int curentArticalIndex) {
this._curentArticalIndex = curentArticalIndex;
notifyListeners();
}
void setfeedPageController(PageController pageController) {
this._feedPageController = pageController;
notifyListeners();
}
void setScreenController(PageController pageController) {
this._screenController = pageController;
notifyListeners();
}
void addWebScren(Widget widget) {
_baseScreen.add(widget);
notifyListeners();
}
void setNewsURL(String newsURL) {
this._newsURL = newsURL;
notifyListeners();
}
void setWebViewAdded() {
this._webviwAdded = true;
notifyListeners();
}
void setLastGetRequest(String request, String value) {
_lastGetRequest.clear();
_lastGetRequest.add(request);
_lastGetRequest.add(value);
notifyListeners();
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib | mirrored_repositories/Inshorts-Clone-The-News-App/lib/controller/theme.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:hive/hive.dart';
class ThemeProvider extends ChangeNotifier {
bool isDarkThemeOn = Hive.box('themeMode').get('isDarkModeOn') ?? false;
void darkTheme(bool status) {
isDarkThemeOn = status;
final themeBox = Hive.box('themeMode');
themeBox.put('isDarkModeOn', status);
print(themeBox.get('isDarkModeOn'));
notifyListeners();
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib | mirrored_repositories/Inshorts-Clone-The-News-App/lib/utils/time_format.dart | // String getRealTime(String time) {
// DateTime now = DateTime.now();
// String date;
// return date;
// }
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/services | mirrored_repositories/Inshorts-Clone-The-News-App/lib/services/news/offline_service.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:fluttertoast/fluttertoast.dart';
import 'package:hive/hive.dart';
// Project imports:
import 'package:inshort_clone/model/news_model.dart';
final Box<Articles> bookmarksBox = Hive.box('bookmarks');
final Box<Articles> unreadsBox = Hive.box('unreads');
void handleBookmarks(Articles article) async {
final bool isPresent = bookmarksBox.containsKey(article.url);
if (!isPresent) {
bookmarksBox.put(article.url, article);
print(bookmarksBox.length);
Fluttertoast.showToast(
msg: 'Added to Bookmark',
backgroundColor: Colors.black,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 3,
toastLength: Toast.LENGTH_SHORT,
);
} else {
bookmarksBox.delete(article.url);
print(bookmarksBox.length);
Fluttertoast.showToast(
msg: 'Removed from Bookmarks',
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
timeInSecForIosWeb: 3,
toastLength: Toast.LENGTH_SHORT,
);
}
}
void addArticlesToUnreads(List<Articles> articles) async {
articles.forEach((element) {
if (!unreadsBox.containsKey(element.url)) {
unreadsBox.put(element.url, element);
print('added' + "${unreadsBox.length}");
}
});
}
void removeArticleFromUnreads(Articles articles) {
if (unreadsBox.containsKey(articles.url)) {
unreadsBox.delete(articles.url);
print('removed' + "${unreadsBox.length}");
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/services | mirrored_repositories/Inshorts-Clone-The-News-App/lib/services/news/news_service.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:dio/dio.dart';
import 'package:hive/hive.dart';
import 'package:provider/provider.dart';
// Project imports:
import 'package:inshort_clone/app/dio/dio.dart';
import 'package:inshort_clone/controller/provider.dart';
import 'package:inshort_clone/model/news_model.dart';
import 'package:inshort_clone/services/news/offline_service.dart';
abstract class NewsFeedRepository {
Future<List<Articles>> getNewsByTopic(String topic);
Future<List<Articles>> getNewsByCategory(String category);
Future<List<Articles>> getNewsBySearchQuery(String query);
List<Articles> getNewsFromLocalStorage(String box);
}
class NewsFeedRepositoryImpl implements NewsFeedRepository {
final BuildContext context;
NewsFeedRepositoryImpl(this.context);
@override
Future<List<Articles>> getNewsByTopic(String topic) async {
final String url = "everything?q=$topic";
final provider = Provider.of<FeedProvider>(context, listen: false);
provider.setDataLoaded(false);
provider.setLastGetRequest("getNewsByTopic", topic);
print("getNewsByTopic" + " " + topic);
Response response = await GetDio.getDio().get(url);
if (response.statusCode == 200) {
List<Articles> articles = NewsModel.fromJson(response.data).articles;
provider.setDataLoaded(true);
addArticlesToUnreads(articles);
return articles;
} else {
provider.setDataLoaded(true);
throw Exception();
}
}
@override
Future<List<Articles>> getNewsByCategory(String category) async {
final String url = "top-headlines?country=in&category=$category";
final provider = Provider.of<FeedProvider>(context, listen: false);
provider.setDataLoaded(false);
provider.setLastGetRequest("getNewsByTopic", category);
Response response = await GetDio.getDio().get(url);
if (response.statusCode == 200) {
List<Articles> articles = NewsModel.fromJson(response.data).articles;
provider.setDataLoaded(true);
addArticlesToUnreads(articles);
return articles;
} else {
provider.setDataLoaded(true);
throw Exception();
}
}
@override
Future<List<Articles>> getNewsBySearchQuery(String query) async {
final provider = Provider.of<FeedProvider>(context, listen: false);
provider.setDataLoaded(false);
final String url = "everything?q=$query";
Response response = await GetDio.getDio().get(url);
if (response.statusCode == 200) {
List<Articles> articles = NewsModel.fromJson(response.data).articles;
addArticlesToUnreads(articles);
provider.setDataLoaded(true);
return articles;
} else {
provider.setDataLoaded(true);
throw Exception();
}
}
@override
List<Articles> getNewsFromLocalStorage(String fromBox) {
List<Articles> articles = [];
final Box<Articles> hiveBox = Hive.box<Articles>(fromBox);
final provider = Provider.of<FeedProvider>(context, listen: false);
provider.setLastGetRequest("getNewsFromLocalStorage", fromBox);
print(fromBox);
if (hiveBox.length > 0) {
for (int i = 0; i < hiveBox.length; i++) {
Articles article = hiveBox.getAt(i);
articles.add(article);
}
provider.setDataLoaded(true);
return articles;
} else {
provider.setDataLoaded(true);
List<Articles> articles = [];
return articles;
}
}
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib/services | mirrored_repositories/Inshorts-Clone-The-News-App/lib/services/news/share_service.dart | // Dart imports:
import 'dart:typed_data';
import 'dart:ui' as ui;
// Flutter imports:
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
// Package imports:
import 'package:esys_flutter_share/esys_flutter_share.dart';
import 'package:provider/provider.dart';
// Project imports:
import 'package:inshort_clone/controller/provider.dart';
void convertWidgetToImageAndShare(BuildContext context, containerKey) async {
RenderRepaintBoundary renderRepaintBoundary =
containerKey.currentContext.findRenderObject();
ui.Image boxImage = await renderRepaintBoundary.toImage(pixelRatio: 1);
ByteData byteData = await boxImage.toByteData(format: ui.ImageByteFormat.png);
Uint8List uInt8List = byteData.buffer.asUint8List();
try {
await Share.file(
'imsanjaysoni/InshortClone', 'inshortClone.png', uInt8List, 'image/png',
text:
'This message sent from *inshorts Clone* made by *Sanjay Soni*\nFork this repository on *Github*\n\n https://github.com/imSanjaySoni/Inshorts-Clone.');
} catch (e) {
print('error: $e');
}
Provider.of<FeedProvider>(context, listen: false).setWatermarkVisible(false);
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib | mirrored_repositories/Inshorts-Clone-The-News-App/lib/style/text_style.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Project imports:
import 'colors.dart';
class AppTextStyle {
AppTextStyle._();
static final TextStyle appBarTitle = TextStyle(
// color: AppColor.onBackground,
fontSize: 14,
fontWeight: FontWeight.w400,
);
static final TextStyle newsTitle = TextStyle(
// color: AppColor.onBackground,
fontSize: 18,
fontWeight: FontWeight.w500,
);
static final TextStyle newsSubtitle = TextStyle(
// color: AppColor.grey2,
fontSize: 15,
height: 1.5,
fontWeight: FontWeight.w300,
);
static final TextStyle newsFooter = TextStyle(
color: AppColor.grey,
fontSize: 12,
fontWeight: FontWeight.w400,
);
static final TextStyle newsBottomTitle = TextStyle(
color: AppColor.onPrimary,
fontSize: 15,
fontWeight: FontWeight.w400,
);
static final TextStyle newsBottomSubtitle = TextStyle(
color: AppColor.onPrimary,
fontSize: 12,
fontWeight: FontWeight.w300,
);
static final TextStyle headline = TextStyle(
// color: AppColor.onBackground,
fontSize: 16,
fontWeight: FontWeight.w500,
);
static final TextStyle topiccardTitle = TextStyle(
// color: AppColor.onBackground,
fontSize: 14,
fontWeight: FontWeight.w600,
);
static final TextStyle categoryTitle = TextStyle(
color: AppColor.iconGrey,
fontSize: 14,
fontWeight: FontWeight.w400,
);
static final TextStyle searchbar = TextStyle(
// color: AppColor.onBackground,
fontSize: 16,
fontWeight: FontWeight.w300,
);
static final TextStyle bottomActionbar = TextStyle(
color: AppColor.iconGrey,
fontSize: 12,
fontWeight: FontWeight.w400,
);
static final TextStyle loading = TextStyle(
// color: AppColor.onBackground,
fontSize: 24,
fontWeight: FontWeight.bold,
);
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib | mirrored_repositories/Inshorts-Clone-The-News-App/lib/style/colors.dart | // Dart imports:
import 'dart:ui' show Color;
class AppColor {
AppColor._();
static Color primary = Color(0xff002752);
static Color primaryVariant = Color(0xff003A86);
static Color accent = Color(0xff0079FD);
static Color surface = Color(0xffF0f0f0);
static Color surfaceDark = Color(0xffBEC8D2);
static Color background = Color(0xffffffff);
static Color onPrimary = Color(0xffFFFFFF);
static Color onBackground = Color(0xff000000);
static Color error = Color(0xffF44E3B);
static Color sucsses = Color(0xff27AE61);
static Color icon = Color(0xff01071D);
static Color iconGrey = Color(0xff8192A3);
static Color grey = Color(0xffcccccc);
static Color grey2 = Color(0xff555555);
static Color grey3 = Color(0xff777777);
}
| 0 |
mirrored_repositories/Inshorts-Clone-The-News-App/lib | mirrored_repositories/Inshorts-Clone-The-News-App/lib/style/theme.dart | // Flutter imports:
import 'package:flutter/material.dart';
// Project imports:
import 'package:inshort_clone/style/colors.dart';
final ThemeData kDarkThemeData = ThemeData(
brightness: Brightness.dark,
scaffoldBackgroundColor: Color(0xff222222),
accentColorBrightness: Brightness.dark,
primaryColor: AppColor.accent,
accentIconTheme: IconThemeData(
color: AppColor.accent,
),
accentColor: AppColor.accent,
appBarTheme: AppBarTheme(
color: Color(0xff333333),
brightness: Brightness.dark,
iconTheme: IconThemeData(
color: AppColor.accent,
),
),
iconTheme: IconThemeData(
color: AppColor.accent,
),
fontFamily: "Montserrat",
);
final ThemeData kLightThemeData = ThemeData(
canvasColor: AppColor.background,
accentColor: AppColor.accent,
errorColor: AppColor.error,
cursorColor: AppColor.primaryVariant,
scaffoldBackgroundColor: Colors.white,
brightness: Brightness.light,
iconTheme: IconThemeData(
color: AppColor.accent,
),
appBarTheme: AppBarTheme(
color: Colors.white,
brightness: Brightness.light,
iconTheme: IconThemeData(
color: AppColor.accent,
),
),
fontFamily: "Montserrat",
);
| 0 |
mirrored_repositories/doctor_app_ui | mirrored_repositories/doctor_app_ui/lib/main.dart | import 'package:device_preview/device_preview.dart';
import 'package:doctor_app_ui/constants/constants.dart';
import 'package:doctor_app_ui/screens/home_screen.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp()
// DevicePreview(
// enabled: !kReleaseMode,
// builder: (context) => const MyApp(), // Wrap your app
// ),
);
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return ScreenUtilInit(
designSize: const Size(411, 823),
minTextAdapt: true,
splitScreenMode: true,
builder: (child) => MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Doctor App UI',
theme: AppTheme.appTheme,
home: const HomeScreen(),
),
);
}
}
| 0 |
mirrored_repositories/doctor_app_ui/lib | mirrored_repositories/doctor_app_ui/lib/constants/text.dart | class AppText {
AppText._();
//Coffee pics
static const String findDoctor = 'Find your doctor';
static const String searchDoctor = "Search doctor, medicines etc";
static const String open = "Open";
static const String closed = "Closed";
static const String consultation = "Consultation";
static const String dental = "Dental";
static const String heart = "Heart";
static const String hospitals = "Hospitals";
static const String medicines = "Medicines";
static const String physician = "Physician";
static const String skin = "Skin";
static const String surgeon = "Surgeon";
static const String topDoctors = "Top Doctors";
static const String viewAll = "View all";
static const String doctor1 = "Dr Ayan Mondal";
static const String doctor2 = "Dr Manira Tasneem";
static const String doctor3 = "Dr Anupam Sammadar";
static const String doctor4 = "Dr Yasmin Ahmed";
static const String eye = "Eye";
static const String ears = "Ears";
static const String hospital1 = "Patna Hospital";
static const String hospital2 = "Kolkata Hospital";
static const String hospital3 = "Banglore Hospital";
static const String hospital4 = "Mumbai Hospital";
static const String doctorDescription =
'''dr. Gilang is one of the best doctors in the Persahabatan Hospital. He has saved more than 1000 patients in the past 3 years. He has also received many awards from domestic and abroad as the best doctors. He is available on a private or schedule. ''';
static const String experience = "Experience";
static const String patient = "Patient";
static const String rating = "Rating";
static const String makeAppointment = "Make an Appointment";
}
| 0 |
mirrored_repositories/doctor_app_ui/lib | mirrored_repositories/doctor_app_ui/lib/constants/images.dart | class AppImages {
AppImages._();
//Profile pic
static const String profile = "assets/images/profile.jpg";
//Doctor pics
static const String doctor1 = "assets/images/doctor1.png";
static const String doctor2 = "assets/images/doctor2.png";
static const String doctor3 = "assets/images/doctor3.png";
static const String doctor4 = "assets/images/doctor4.png";
//Icons
static const String backarrow = "assets/icons/backarrow.png";
static const String bandage = "assets/icons/bandage.png";
static const String bookmark = "assets/icons/bookmark.png";
static const String care = "assets/icons/care.png";
static const String clinic = "assets/icons/clinic.png";
static const String comments = "assets/icons/comments.png";
static const String heart = "assets/icons/heart.png";
static const String medicine = "assets/icons/medicine.png";
static const String menu = "assets/icons/menu.png";
static const String search = "assets/icons/search.png";
static const String star = "assets/icons/star.png";
static const String stethoscope = "assets/icons/stethoscope.png";
static const String syringe = "assets/icons/syringe.png";
static const String teeth = "assets/icons/teeth.png";
}
| 0 |
mirrored_repositories/doctor_app_ui/lib | mirrored_repositories/doctor_app_ui/lib/constants/constants.dart | export 'colors.dart';
export 'images.dart';
export 'text.dart';
export 'theme.dart';
export 'package:flutter_screenutil/flutter_screenutil.dart';
| 0 |
mirrored_repositories/doctor_app_ui/lib | mirrored_repositories/doctor_app_ui/lib/constants/colors.dart | import 'package:flutter/material.dart';
class AppColors {
AppColors._();
static const Color blue = Color(0xff4485FD);
static const Color purple = Color(0xffA584FF);
static const Color green = Color(0xff00CC6A);
static const Color boxGreen = Color(0xffCCF5E1);
static const Color red = Color(0xffCC4900);
static const Color boxRed = Color(0xffF7E4D9);
static const Color white = Color(0xffffffff);
static const Color black = Color(0xFF000000);
static const Color grey = Color(0xFFF6F6F6);
static const Color textGrey = Color(0xFFCACCCF);
static const Color orange = Color(0xffFF7854);
static const Color dullYellow = Color(0xffFEA725);
static const Color cyan = Color(0xff00C9E4);
static const Color pink = Color(0xffFD44B3);
static const Color dullOrange = Color(0xffFD4444);
static const Color lightGreen = Color(0xffCCF5E1);
static const Color yellow = Color(0xffFFE848);
static const Color dullRed = Color(0xffF7E4D9);
}
| 0 |
mirrored_repositories/doctor_app_ui/lib | mirrored_repositories/doctor_app_ui/lib/constants/theme.dart | import 'package:doctor_app_ui/constants/constants.dart';
import 'package:flutter/material.dart';
class AppTheme {
static final ThemeData appTheme = ThemeData(
backgroundColor: AppColors.white,
scaffoldBackgroundColor: AppColors.white,
textTheme: darkTextTheme,
);
static final TextTheme darkTextTheme = TextTheme(
headline1: _headline1, //34px
headline2: _headline2, //24px
headline3: _headline3, //18px
headline4: _headline4, //16px
headline5: _headline5, //14px
headline6: _headline6, //12px
subtitle1: _subtitle1, //10px
// subtitle2: _subtitle2, //13px
bodyText1: _bodyText1, //16px
// bodyText2: _bodyText2, //14px //normal
// button: _button, //14px
// caption: _caption, //12px
// overline: _overline, //10px
);
static final TextStyle _headline1 = TextStyle(
fontFamily: "Roboto",
fontWeight: FontWeight.normal,
color: AppColors.black,
fontSize: 34.sp,
);
static final TextStyle _headline2 = TextStyle(
fontFamily: "Roboto",
color: AppColors.black,
fontWeight: FontWeight.bold,
fontSize: 24.sp,
);
static final TextStyle _headline3 = TextStyle(
fontFamily: "Roboto",
color: AppColors.black,
fontWeight: FontWeight.bold,
fontSize: 18.sp,
);
static final TextStyle _headline4 = TextStyle(
fontFamily: "Roboto",
color: AppColors.black,
fontWeight: FontWeight.bold,
fontSize: 16.sp,
);
static final TextStyle _headline5 = TextStyle(
fontFamily: "Roboto",
color: AppColors.black,
fontWeight: FontWeight.normal,
fontSize: 14.sp,
);
static final TextStyle _headline6 = TextStyle(
fontFamily: "Roboto",
color: AppColors.black,
fontWeight: FontWeight.normal,
fontSize: 12.sp,
);
static final TextStyle _subtitle1 = TextStyle(
fontFamily: "Roboto",
color: AppColors.black,
fontWeight: FontWeight.normal,
fontSize: 10.sp,
);
static final TextStyle _bodyText1 = TextStyle(
fontFamily: "Roboto",
color: AppColors.grey,
fontWeight: FontWeight.normal,
fontSize: 16.sp,
);
// static final TextStyle _bodyText2 = TextStyle(
// fontFamily: "RedHatDisplay",
// color: AppColors.textColor,
// fontWeight: FontWeight.w400,
// fontSize: 14.sp,
// );
}
| 0 |
mirrored_repositories/doctor_app_ui/lib | mirrored_repositories/doctor_app_ui/lib/widgets/doctor_image.dart | import 'package:doctor_app_ui/constants/constants.dart';
import 'package:doctor_app_ui/model/model.dart';
import 'package:doctor_app_ui/widgets/widgets.dart';
import 'package:flutter/material.dart';
class DoctorImage extends StatelessWidget {
final DoctorInformationModel doctorInformationModel;
const DoctorImage({
Key? key,
required this.doctorInformationModel,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return SizedBox(
height: 375.h,
child: Stack(
children: [
Hero(
tag: "doctor-hero-${doctorInformationModel.id}",
child: Container(
height: 350,
width: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
doctorInformationModel.image,
),
fit: BoxFit.cover,
),
),
child: const SizedBox(height: 20),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20),
child: CustomAppBar(
backButton: true,
profile: false,
icon: Icons.arrow_back_ios_new_rounded,
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/doctor_app_ui/lib | mirrored_repositories/doctor_app_ui/lib/widgets/detail_info.dart | import 'package:doctor_app_ui/constants/constants.dart';
import 'package:flutter/material.dart';
class DetailInfo extends StatelessWidget {
final String text;
final String number;
final String? subtitle;
const DetailInfo({
Key? key,
required this.text,
required this.number,
this.subtitle,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
text,
style: Theme.of(context).textTheme.headline4,
),
Text.rich(
TextSpan(
children: [
TextSpan(
text: number,
style: Theme.of(context).textTheme.headline2!.copyWith(
color: AppColors.blue,
),
),
TextSpan(
text: subtitle,
style: Theme.of(context)
.textTheme
.headline5!
.copyWith(color: AppColors.textGrey),
),
],
),
),
],
);
}
}
| 0 |
mirrored_repositories/doctor_app_ui/lib | mirrored_repositories/doctor_app_ui/lib/widgets/doctor_description.dart | import 'package:doctor_app_ui/constants/constants.dart';
import 'package:doctor_app_ui/model/model.dart';
import 'package:doctor_app_ui/widgets/widgets.dart';
import 'package:flutter/material.dart';
class DoctorDescription extends StatelessWidget {
const DoctorDescription({
Key? key,
required this.doctorInformationModel,
}) : super(key: key);
final DoctorInformationModel doctorInformationModel;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
doctorInformationModel.title,
style: Theme.of(context).textTheme.headline2,
),
SizedBox(height: 10.h),
Row(
children: [
Text.rich(
TextSpan(
style: Theme.of(context).textTheme.headline5,
children: [
TextSpan(text: doctorInformationModel.specialist),
const TextSpan(text: ' • '),
TextSpan(text: doctorInformationModel.hospital),
],
),
),
],
),
SizedBox(height: 20.h),
Text(
'${doctorInformationModel.title} is one of the best doctors in the ${doctorInformationModel.hospital}. He has saved more than 1000 patients in the past 3 years. He has also received many awards from domestic and abroad as the best doctors. He is available on a private or schedule. '),
SizedBox(height: 20.h),
const DoctorDetails(),
SizedBox(height: 20.h),
Row(
children: [
Container(
height: 56,
width: 56,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: AppColors.blue,
),
child: Image.asset(
AppImages.comments,
color: AppColors.white,
),
),
SizedBox(width: 20.h),
Expanded(
child: Container(
height: 56,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: AppColors.green,
),
child: Center(
child: Text(
AppText.makeAppointment,
style: Theme.of(context)
.textTheme
.headline5!
.copyWith(color: AppColors.white),
),
),
),
),
],
),
SizedBox(height: 20.h),
],
),
);
}
}
| 0 |
mirrored_repositories/doctor_app_ui/lib | mirrored_repositories/doctor_app_ui/lib/widgets/widgets.dart | export 'custom_appbar.dart';
export 'detail_info.dart';
export 'doctor_description.dart';
export 'doctor_details.dart';
export 'doctor_image.dart';
export 'doctors_information.dart';
export 'medical_services.dart';
export 'textbox.dart';
| 0 |
mirrored_repositories/doctor_app_ui/lib | mirrored_repositories/doctor_app_ui/lib/widgets/custom_appbar.dart | import 'package:doctor_app_ui/constants/constants.dart';
import 'package:flutter/material.dart';
class CustomAppBar extends StatelessWidget {
final IconData icon;
late bool backButton;
late bool profile;
CustomAppBar({
Key? key,
required this.icon,
required this.backButton,
required this.profile,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return SizedBox(
height: 56,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconButton(
onPressed: () {
backButton ? Navigator.pop(context) : {};
},
icon: Icon(
icon,
color: AppColors.black,
size: 25,
),
),
profile
? Container(
height: 40,
width: 40,
decoration: const BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: AssetImage(AppImages.profile),
fit: BoxFit.cover,
),
),
)
: Container(
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(10.0),
),
height: 40,
width: 40,
child: const Icon(
Icons.bookmark,
color: AppColors.black,
size: 25,
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/doctor_app_ui/lib | mirrored_repositories/doctor_app_ui/lib/widgets/medical_services.dart | import 'package:doctor_app_ui/constants/constants.dart';
import 'package:doctor_app_ui/model/model.dart';
import 'package:flutter/material.dart';
class MedicalServices extends StatelessWidget {
const MedicalServices({
Key? key,
required this.medicalServices,
}) : super(key: key);
final List<MedicalServicesModel> medicalServices;
@override
Widget build(BuildContext context) {
return GridView.count(
physics: const ClampingScrollPhysics(),
shrinkWrap: true,
crossAxisCount: 4,
mainAxisSpacing: 10,
children: List.generate(
medicalServices.length,
(index) {
return Column(
children: [
Container(
height: 60,
width: 60,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: medicalServices[index].color,
),
child: Image.asset(
medicalServices[index].image,
color: AppColors.white,
),
),
const SizedBox(height: 5),
Text(
medicalServices[index].title,
style: Theme.of(context).textTheme.headline6,
),
],
);
},
),
);
}
}
| 0 |
mirrored_repositories/doctor_app_ui/lib | mirrored_repositories/doctor_app_ui/lib/widgets/doctors_information.dart | import 'package:doctor_app_ui/constants/constants.dart';
import 'package:doctor_app_ui/model/doctor_information_model.dart';
import 'package:doctor_app_ui/screens/doctor_screen.dart';
import 'package:flutter/material.dart';
class DoctorInformation extends StatelessWidget {
final List<DoctorInformationModel> doctorInformations;
const DoctorInformation({
Key? key,
required this.doctorInformations,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return ListView.builder(
shrinkWrap: true,
physics: const ClampingScrollPhysics(),
itemCount: doctorInformations.length,
itemBuilder: (context, index) => GestureDetector(
onTap: () {
Navigator.of(context).push(
PageRouteBuilder(
pageBuilder: (_, __, ___) => DoctorScreen(
doctorInformationModel: doctorInformations[index]),
transitionsBuilder:
(context, animation, secondaryAnimation, child) =>
FadeTransition(opacity: animation, child: child),
),
);
},
child: Container(
color: Colors.transparent,
margin: EdgeInsets.only(bottom: 15.h),
child: SizedBox(
height: 80,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 80,
width: 80,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
image: DecorationImage(
image: AssetImage(doctorInformations[index].image),
),
),
),
SizedBox(width: 15.w),
Expanded(
child: SizedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
doctorInformations[index].title,
style: Theme.of(context).textTheme.headline4,
),
Row(
children: [
Text.rich(
TextSpan(
style: Theme.of(context)
.textTheme
.headline5,
children: [
TextSpan(
text: doctorInformations[index]
.specialist),
const TextSpan(text: ' • '),
TextSpan(
text: doctorInformations[index]
.hospital),
],
),
),
],
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: List.generate(
5,
(index) => Row(
children: const [
Icon(
Icons.star_rounded,
color: AppColors.yellow,
size: 20,
),
],
),
),
),
],
),
Container(
height: 25.h,
width: 56.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
color: AppColors.boxGreen,
),
child: Center(
child: Text(
AppText.open,
style: Theme.of(context)
.textTheme
.headline6!
.copyWith(
color: AppColors.green,
),
),
),
),
],
),
),
),
],
),
),
),
),
);
}
}
| 0 |
mirrored_repositories/doctor_app_ui/lib | mirrored_repositories/doctor_app_ui/lib/widgets/textbox.dart | import 'package:doctor_app_ui/constants/constants.dart';
import 'package:flutter/material.dart';
class CustomTextBox extends StatelessWidget {
const CustomTextBox({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return TextField(
keyboardAppearance: Brightness.dark,
style: const TextStyle(color: AppColors.black),
decoration: InputDecoration(
suffixIcon: const Icon(
Icons.search,
color: AppColors.black,
),
hintText: AppText.searchDoctor,
hintStyle: Theme.of(context)
.textTheme
.headline5!
.copyWith(color: AppColors.textGrey),
fillColor: AppColors.grey,
filled: true,
border: OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.circular(10.0),
),
),
);
}
}
| 0 |
mirrored_repositories/doctor_app_ui/lib | mirrored_repositories/doctor_app_ui/lib/widgets/doctor_details.dart | import 'package:doctor_app_ui/constants/constants.dart';
import 'package:doctor_app_ui/widgets/widgets.dart';
import 'package:flutter/material.dart';
class DoctorDetails extends StatelessWidget {
const DoctorDetails({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 20),
height: 100,
width: double.infinity,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: const [
DetailInfo(
text: AppText.experience,
number: '3',
subtitle: ' yr',
),
VerticalDivider(
indent: 20,
endIndent: 20,
thickness: 1,
color: AppColors.textGrey,
),
DetailInfo(
text: AppText.patient,
number: '1121',
subtitle: ' ps',
),
VerticalDivider(
indent: 20,
endIndent: 20,
thickness: 1,
color: AppColors.textGrey,
),
DetailInfo(
text: AppText.rating,
number: '5.0',
),
],
),
);
}
}
| 0 |
mirrored_repositories/doctor_app_ui/lib | mirrored_repositories/doctor_app_ui/lib/data/doctor_information_data.dart | import 'package:doctor_app_ui/constants/constants.dart';
import 'package:doctor_app_ui/model/model.dart';
List<DoctorInformationModel> doctorInformation = [
DoctorInformationModel(
id: '1',
image: AppImages.doctor1,
title: AppText.doctor1,
specialist: AppText.heart,
hospital: AppText.hospital1,
star: '50',
),
DoctorInformationModel(
id: '2',
image: AppImages.doctor2,
title: AppText.doctor2,
specialist: AppText.eye,
hospital: AppText.hospital2,
star: '60',
),
DoctorInformationModel(
id: '3',
image: AppImages.doctor3,
title: AppText.doctor3,
specialist: AppText.ears,
hospital: AppText.hospital3,
star: '80',
),
DoctorInformationModel(
id: '4',
image: AppImages.doctor4,
title: AppText.doctor4,
specialist: AppText.skin,
hospital: AppText.hospital4,
star: '20',
),
];
| 0 |
mirrored_repositories/doctor_app_ui/lib | mirrored_repositories/doctor_app_ui/lib/data/data.dart | export 'doctor_information_data.dart';
export 'medical_services_data.dart';
| 0 |
mirrored_repositories/doctor_app_ui/lib | mirrored_repositories/doctor_app_ui/lib/data/medical_services_data.dart | import 'package:doctor_app_ui/constants/constants.dart';
import 'package:doctor_app_ui/model/model.dart';
List<MedicalServicesModel> medicalService = [
MedicalServicesModel(
color: AppColors.blue,
title: AppText.consultation,
image: AppImages.stethoscope,
),
MedicalServicesModel(
color: AppColors.purple,
title: AppText.dental,
image: AppImages.teeth,
),
MedicalServicesModel(
color: AppColors.red,
title: AppText.heart,
image: AppImages.heart,
),
MedicalServicesModel(
color: AppColors.orange,
title: AppText.hospitals,
image: AppImages.clinic,
),
MedicalServicesModel(
color: AppColors.green,
title: AppText.medicines,
image: AppImages.medicine,
),
MedicalServicesModel(
color: AppColors.cyan,
title: AppText.physician,
image: AppImages.care,
),
MedicalServicesModel(
color: AppColors.pink,
title: AppText.skin,
image: AppImages.bandage,
),
MedicalServicesModel(
color: AppColors.dullOrange,
title: AppText.surgeon,
image: AppImages.syringe,
),
];
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.