repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/Shoe-Commerce/lib/core
mirrored_repositories/Shoe-Commerce/lib/core/utils/dimesions.dart
import 'package:get/get.dart'; class Dimensions { static double screenHeight = Get.context!.height; static double screenWidth = Get.context!.width; static double height5 = screenHeight / 173.4; static double height10 = screenHeight / 86.7; static double height15 = screenHeight / 57.8; static double height20 = screenHeight / 43.35; static double height30 = screenHeight / 28.9; static double height35 = screenHeight / 24.77; static double height40 = screenHeight / 21.67; static double height45 = screenHeight / 19.2; static double height50 = screenHeight / 17.34; static double height100 = screenHeight / 8.67; static double width5 = screenWidth / 82.2; static double width10 = screenWidth / 41.1; static double width15 = screenWidth / 27.4; static double width20 = screenWidth / 27.4; static double width30 = screenWidth / 13.7; static double width40 = screenWidth / 10.27; static double width45 = screenWidth / 9.1; static double width60 = screenWidth / 6.85; static double width100 = screenWidth / 4.11; static double font12 = screenHeight / 72.12; static double font14 = screenHeight / 61.92; static double font16 = screenHeight / 54.18; static double font20 = screenHeight / 43.5; static double font24 = screenHeight / 36.12; static double font26 = screenHeight / 33.3; static double iconSize16 = screenHeight / 54.18; static double iconSize24 = screenHeight / 36.12; static double iconSize26 = screenHeight / 33.34; static double bottomAppBar = screenHeight / 8.5; static double searchBoxHeight = screenHeight / 17.34; static double carousel = screenHeight / 5.31; static double bannerHeight = screenHeight / 6.02; static double bannerWidth = screenWidth / 1.35; static double coverHeight = screenHeight / 7.74; static double cardHeight = screenHeight / 3.46; static double detailCoverHeight = screenHeight / 3.03; static double radius8 = screenHeight / 108.375; }
0
mirrored_repositories/chrishub
mirrored_repositories/chrishub/lib/sizes.dart
import 'package:flutter/material.dart'; Size screenSize(BuildContext context) { return MediaQuery.of(context).size; } double screenHeight(BuildContext context, {double mulBy = 1}) { return screenSize(context).height * mulBy; } double screenWidth(BuildContext context, {double mulBy = 1}) { return screenSize(context).width * mulBy; }
0
mirrored_repositories/chrishub
mirrored_repositories/chrishub/lib/widgets.dart
import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:mac_dt/providers.dart'; import 'package:provider/provider.dart'; import 'package:flutter/foundation.dart'; /// A [Nothing] instance, you can use in your layouts. const nil = Nothing(); /// A widget which is not in the layout and does nothing. /// It is useful when you have to return a widget and can't return null. class Nothing extends Widget { /// Creates a [Nothing] widget. const Nothing({Key? key}) : super(key: key); @override Element createElement() => _NilElement(this); } class _NilElement extends Element { _NilElement(Nothing widget) : super(widget); @override void mount(Element? parent, dynamic newSlot) { assert(parent is! MultiChildRenderObjectElement, """ You are using Nil under a MultiChildRenderObjectElement. This suggests a possibility that the Nil is not needed or is being used improperly. Make sure it can't be replaced with an inline conditional or omission of the target widget from a list. """); super.mount(parent, newSlot); } @override bool get debugDoingBuild => false; @override void performRebuild() {} } class MBPText extends StatelessWidget { final Color color; final String? text; final double size; final FontWeight? weight; final String fontFamily; final int maxLines; final TextOverflow overflow; final bool softWrap; const MBPText({this.color= Colors.black,this.text, this.size=12, this.weight, this.fontFamily="SF", this.maxLines=1, this.softWrap=true, this.overflow= TextOverflow.fade, Key? key}) : super(key: key); @override Widget build(BuildContext context) { return FittedBox( fit: BoxFit.scaleDown, child: Text(text!, style: TextStyle( fontWeight: weight==null?Theme.of(context).textTheme.headline4!.fontWeight:weight, fontFamily: fontFamily, color: color, fontSize: size, ), textAlign: TextAlign.center, maxLines: maxLines, overflow: overflow, softWrap: softWrap, ), ); } } class CustomBoxShadow extends BoxShadow { final BlurStyle blurStyle; final double spreadRadius; const CustomBoxShadow({ Color color = const Color(0xFF000000), Offset offset = Offset.zero, double blurRadius = 0.0, this.blurStyle = BlurStyle.normal, this.spreadRadius = 0.0, }) : super(color: color, offset: offset, blurRadius: blurRadius); @override Paint toPaint() { final Paint result = Paint() ..color = color ..maskFilter = MaskFilter.blur(this.blurStyle, blurSigma); assert(() { if (debugDisableShadows) result.maskFilter = null; return true; }()); return result; } } class Scaler extends StatelessWidget { Widget? child; Scaler({this.child, Key? key}) : super(key: key); @override Widget build(BuildContext context) { var scale= Provider.of<DataBus>(context).getScale; return Transform.scale( scale: scale, alignment: Alignment.topCenter, child: child ); } } BoxConstraints constraints({double? height, width}){ return BoxConstraints( minHeight: height==null?0:height*800, ///800 is the safe height factor minWidth: width==null?0:width*1312 ); } extension StringExtension on String { String capitalize() { return this.split(" ").map((element) => "${element[0].toUpperCase()}${element.substring(1)}").join(" "); } String getInitials() => this.isNotEmpty ? this.trim().split(' ').map((l) => l[0]).take(2).join() : ''; } showAlertDialog(BuildContext context) { Widget okButton = TextButton( child: Text("OK"), onPressed: () { }, ); AlertDialog alert = AlertDialog( title: Text("My title"), content: Text("This is my message."), actions: [ okButton, ], ); showDialog( context: context, builder: (BuildContext context) { return alert; }, ); } // class Minimiser extends StatefulWidget { // Minimiser({Key? key, this.minimise=false, this.child}) : super(key: key); // // bool minimise; // Widget? child; // @override // _MinimiserState createState() => _MinimiserState(); // } // // class _MinimiserState extends State<Minimiser> { // @override // Widget build(BuildContext context) { // return Transform( // // // transform: Matrix4.translation(0000,0,0,0), // child: widget.child, // ); // } // } ///Night Shift Blender class BlendMask extends SingleChildRenderObjectWidget { final BlendMode blendMode; final double opacity; BlendMask({ required this.blendMode, this.opacity = 1.0, Key? key, Widget? child, }) : super(key: key, child: child); @override RenderObject createRenderObject(context) { return RenderBlendMask(blendMode, opacity); } @override void updateRenderObject(BuildContext context, RenderBlendMask renderObject) { renderObject.blendMode = blendMode; renderObject.opacity = opacity; } } class RenderBlendMask extends RenderProxyBox { BlendMode blendMode; double opacity; RenderBlendMask(this.blendMode, this.opacity); @override void paint(context, offset) { context.canvas.saveLayer( offset & size, Paint() ..blendMode = blendMode ..color = Color.fromARGB((opacity * 255).round(), 255, 255, 255), ); super.paint(context, offset); context.canvas.restore(); } }
0
mirrored_repositories/chrishub
mirrored_repositories/chrishub/lib/providers.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mac_dt/components/wallpaper/wallpaper.dart'; import 'package:provider/provider.dart'; import 'data/system_data_CRUD.dart'; import 'system/componentsOnOff.dart'; import 'system/folders/folders.dart'; // var finderOpen = Provider.of<OnOff>(context).getFinder; // Provider.of<OnOff>(context, listen: false).toggleFinder(); class DataBus extends ChangeNotifier{ String onTop="finder"; String fs=""; double? brightness =95.98; Offset pointerPos = new Offset(0, 0); bool nightShift= false; double scale= 1; //TODO: Have to change default notification according to device Map<String, String> notification= { "notification":"Welcome to Chrisbin's MacBook Pro", "url":"https://github.com/chrisbinsunny", "app":"apple", "head":"Welcome" }; WallData wallpaper= SystemDataCRUD.getWallpaper(); double? get getBrightness { return brightness; } void setBrightness(double? val) { brightness= val; notifyListeners(); } Offset get getPos { return pointerPos; } void setPos(Offset val) { pointerPos= val; notifyListeners(); } void setNotification(String noti, url, app, head){ notification["notification"]=noti; notification["url"]=url; notification["app"]=app; notification["head"]=head; notifyListeners(); } get getNotification => notification; void toggleNS(){ nightShift=!nightShift; notifyListeners(); } get getNS => nightShift; void changeScale(double height){ if(height<0) scale=0; else if(height>1) scale=1; else scale=height; scale=1-((1-scale)*0.08); notifyListeners(); } get getScale=>scale; WallData get getWallpaper { return wallpaper; } void setWallpaper(WallData val) { wallpaper= val; SystemDataCRUD.setWallpaper(val); notifyListeners(); } } void tapFunctions(BuildContext context){ Provider.of<Folders>(context, listen: false).deSelectAll(); Provider.of<OnOff>(context, listen: false).offNotifications(); Provider.of<OnOff>(context, listen: false).offFRCM(); Provider.of<OnOff>(context, listen: false).offRCM(); Provider.of<OnOff>(context, listen: false).offLaunchPad(); } void tapFunctionsIpad(BuildContext context){ Provider.of<DataBus>(context, listen: false).changeScale(1); Provider.of<OnOff>(context, listen: false).toggleAppOpen(); }
0
mirrored_repositories/chrishub
mirrored_repositories/chrishub/lib/firebase_options.dart
// File generated by FlutterFire CLI. // ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform; /// Default [FirebaseOptions] for use with your Firebase apps. /// /// Example: /// ```dart /// import 'firebase_options.dart'; /// // ... /// await Firebase.initializeApp( /// options: DefaultFirebaseOptions.currentPlatform, /// ); /// ``` class DefaultFirebaseOptions { static FirebaseOptions get currentPlatform { if (kIsWeb) { return web; } switch (defaultTargetPlatform) { case TargetPlatform.android: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for android - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); case TargetPlatform.iOS: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for ios - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); case TargetPlatform.macOS: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for macos - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); case TargetPlatform.windows: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for windows - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); case TargetPlatform.linux: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for linux - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); default: throw UnsupportedError( 'DefaultFirebaseOptions are not supported for this platform.', ); } } static const FirebaseOptions web = FirebaseOptions( apiKey: 'AIzaSyCfob0NKq-2PccCqjnTqDJZrAgrzj9xCG0', appId: '1:589924309907:web:0215ccaae6b587b722a666', messagingSenderId: '589924309907', projectId: 'chrishub', authDomain: 'chrishub.firebaseapp.com', storageBucket: 'chrishub.appspot.com', measurementId: 'G-WDTCDNEJ74', ); }
0
mirrored_repositories/chrishub
mirrored_repositories/chrishub/lib/main.dart
import 'dart:developer'; import 'dart:html' as html; import 'dart:js'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import 'package:hive_flutter/adapters.dart'; import 'package:mac_dt/components/wallpaper/wallpaper.dart'; import 'package:mac_dt/data/system_data.dart'; import 'package:mac_dt/data/system_data_CRUD.dart'; import 'package:mac_dt/system/folders/folders.dart'; import 'package:mac_dt/providers.dart'; import 'package:mac_dt/sizes.dart'; import 'apps/systemPreferences.dart'; import 'data/analytics.dart'; import 'firebase_options.dart'; import 'system/openApps.dart'; import 'theme/theme.dart'; import 'package:mac_dt/system/componentsOnOff.dart'; import 'package:provider/provider.dart'; import 'package:flutter/foundation.dart'; import 'system/desktop.dart'; Future<void> main() async { WidgetsFlutterBinding.ensureInitialized(); html.window.document.onContextMenu.listen((evt) => evt.preventDefault()); ///Firebase await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform,); ///Hive await Hive.initFlutter(); Hive.registerAdapter(SystemDataAdapter()); Hive.registerAdapter(WallDataAdapter()); Hive.registerAdapter(FolderPropsAdapter()); await Hive.openBox<SystemData>('systemData'); await Hive.openBox<FolderProps>('folders'); runApp(ChangeNotifierProvider<ThemeNotifier>( create: (_) => ThemeNotifier(SystemDataCRUD.getTheme()), child: MyApp())); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MultiProvider( providers: [ ChangeNotifierProvider<OnOff>( create: (context) => OnOff(), ), ChangeNotifierProvider<DataBus>( create: (context) => DataBus(), ), ChangeNotifierProvider<Apps>( create: (context) => Apps(), ), ChangeNotifierProvider<Folders>( create: (context) => Folders(), ), ChangeNotifierProvider<AnalyticsService>( create: (context) => AnalyticsService(), ), ], child: Home(), ); } } class Home extends StatelessWidget { const Home({Key? key}) : super(key: key); @override Widget build(BuildContext context) { final themeNotifier = Provider.of<ThemeNotifier>(context); return MaterialApp( debugShowCheckedModeBanner: false, title: 'Chrisbin\'s MacBook Pro', navigatorObservers: [ Provider.of<AnalyticsService>(context, listen: false) .getAnalyticsObserver() ], theme: themeNotifier.getTheme(), home: MacOS(), ); } } void fullscreenWorkaround(Element element) { var elem = new JsObject.fromBrowserObject(element); if (elem.hasProperty("requestFullscreen")) { elem.callMethod("requestFullscreen"); } else { List<String> vendors = ['moz', 'webkit', 'ms', 'o']; for (String vendor in vendors) { String vendorFullscreen = "${vendor}RequestFullscreen"; if (vendor == 'moz') { vendorFullscreen = "${vendor}RequestFullScreen"; } if (elem.hasProperty(vendorFullscreen)) { elem.callMethod(vendorFullscreen); return; } } } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/components/dock.dart
import 'dart:developer' as dev; import 'dart:html' as html; import 'dart:js' as js; import 'dart:math'; import 'dart:ui'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart'; import 'package:intl/intl.dart'; import 'package:mac_dt/apps/messages/messages.dart'; import 'package:provider/provider.dart'; import '../apps/about.dart'; import '../apps/calendar.dart'; import '../apps/systemPreferences.dart'; import '../data/analytics.dart'; import '../system/componentsOnOff.dart'; import '../system/folders/folders.dart'; import '../system/openApps.dart'; import '../providers.dart'; import '../widgets.dart'; import 'finderWindow.dart'; import '../sizes.dart'; import '../apps/feedback/feedback.dart'; import '../apps/spotify.dart'; import '../apps/terminal/terminal.dart'; import '../apps/vscode.dart'; import '../apps/safari/safariWindow.dart'; //TODO: Icons are not clickable outside of Dock. Known issue of framework. Need to find a Workaround. class Docker extends StatefulWidget { const Docker({ Key? key, }) : super(key: key); @override _DockerState createState() => _DockerState(); } class _DockerState extends State<Docker> { late DateTime now; bool _animate = false; var _offsetX = 0.0; var _offsetY = 0.0; bool? safariOpen, vsOpen, messageOpen,spotifyOpen, fbOpen, calendarOpen, terminalOpen; final bool isWebMobile = kIsWeb && (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.android); @override void initState() { now = DateTime.now(); super.initState(); } ///This function gives the path of the arc which the apps should follow. /// x : center of the Dock Item. /// x0 : _getCursor = position of the cursor. /// 2 : we want the animation to affect 4 items centered in x0. double _getPath(double x, double x0, ) { x=(x)/100; if (_offsetX == 0) return 0; var z = (x - x0) * (x - x0) - 2; if (z > 0) return 0; ///Following if has been added to obtain the gradual increase of size when coming from top. if (_offsetY<screenHeight(context, mulBy: 0.06)) return sqrt(-z / 2)*(_offsetY/50); return sqrt(-z / 2); } double _getCursor() { return _offsetX / 100; } double getWidth(){ dev.log((_offsetX).toString()); if(_offsetX<100){ return (screenWidth(context, mulBy: 0.55)+screenWidth(context, mulBy: 0.06*_offsetX/100)); } else{ if(_offsetX>1070){ return (screenWidth(context, mulBy: 0.55)+screenWidth(context, mulBy: 0.06*(1170-_offsetX)/100)); } return screenWidth(context, mulBy: 0.61); } } @override Widget build(BuildContext context) { safariOpen = Provider.of<Apps>(context).isOpen(ObjectKey("safari")); vsOpen = Provider.of<Apps>(context).isOpen(ObjectKey("vscode")); messageOpen = Provider.of<Apps>(context).isOpen(ObjectKey("messages")); spotifyOpen = Provider.of<Apps>(context).isOpen(ObjectKey("spotify")); String fs = Provider.of<OnOff>(context).getFS; bool fsAni = Provider.of<OnOff>(context).getFSAni; fbOpen = Provider.of<Apps>(context).isOpen(ObjectKey("feedback")); calendarOpen = Provider.of<Apps>(context).isOpen(ObjectKey("calendar")); terminalOpen = Provider.of<Apps>(context).isOpen(ObjectKey("terminal")); return AnimatedPositioned( duration: Duration(milliseconds: (fsAni) ? 400 : 0), top: (fs == "") ? screenHeight(context, mulBy: 0.86) : screenHeight(context, mulBy: 1.05), left: screenWidth(context, mulBy: 0.225), child: Column( children: [ Stack( alignment: Alignment.bottomCenter, children: [ Container( decoration: BoxDecoration( boxShadow: [ CustomBoxShadow( color: Theme.of(context).accentColor, //color: Colors.black.withOpacity(0.2), spreadRadius: 10, blurRadius: 15, offset: Offset(0, 8), blurStyle: BlurStyle.normal), ], ), child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(15)), child: BackdropFilter( filter: new ImageFilter.blur(sigmaX: 70.0, sigmaY: 70.0), child: Container( padding: EdgeInsets.only(bottom: 2), width: screenWidth(context, mulBy: 0.55), height: screenHeight(context, mulBy: 0.06), decoration: BoxDecoration( color: Theme.of(context).focusColor, border: Border.all( color: Colors.white.withOpacity(0.2), ), borderRadius: BorderRadius.all(Radius.circular(15))), ), ), ), ), Container( padding: EdgeInsets.only(bottom: 2), width: screenWidth(context, mulBy: 0.55), height: screenHeight(context, mulBy: 0.06), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ DockerItem( iName: "Finder", on: true, dx: _getPath(screenWidth(context, mulBy: 0.0196), _getCursor(),), onTap: () { setState(() { _animate = !_animate; }); tapFunctions(context); Provider.of<OnOff>(context, listen: false) .maxFinder(); Provider.of<Apps>(context, listen: false).openApp( Finder( key: ObjectKey("finder"), initPos: Offset( screenWidth(context, mulBy: 0.2), screenHeight(context, mulBy: 0.18))), Provider.of<OnOff>(context, listen: false) .maxFinder() ); }, ), DockerItem( iName: "Launchpad", on: false, dx: _getPath(screenWidth(context, mulBy: 0.0588), _getCursor(), ), onTap: () { Provider.of<Folders>(context, listen: false).deSelectAll(); Provider.of<OnOff>(context, listen: false).offNotifications(); Provider.of<OnOff>(context, listen: false).offFRCM(); Provider.of<OnOff>(context, listen: false).offRCM(); Provider.of<OnOff>(context, listen: false).toggleLaunchPad(); Provider.of<AnalyticsService>(context, listen: false) .logCurrentScreen("Launchpad"); }, ), DockerItem( iName: "Safari", on: safariOpen, dx: _getPath(screenWidth(context, mulBy: 0.098), _getCursor(),), onTap: () { tapFunctions(context); Provider.of<OnOff>(context, listen: false) .maxSafari(); Provider.of<Apps>(context, listen: false).openApp( Safari( key: ObjectKey("safari"), initPos: Offset( screenWidth(context, mulBy: 0.21), screenHeight(context, mulBy: 0.14))), Provider.of<OnOff>(context, listen: false) .maxSafari() ); }, ), DockerItem( iName: "Messages", on: messageOpen, dx: _getPath(screenWidth(context, mulBy: 0.1372), _getCursor(), ), onTap: () { tapFunctions(context); Provider.of<OnOff>(context, listen: false) .maxMessages(); Provider.of<Apps>(context, listen: false).openApp( Messages( key: ObjectKey("messages"), initPos: Offset( screenWidth(context, mulBy: 0.27), screenHeight(context, mulBy: 0.2))), Provider.of<OnOff>(context, listen: false) .maxMessages() ); }, ), DockerItem( iName: "assets/apps/about me.png", on: false, dx: _getPath(screenWidth(context, mulBy: 0.1764), _getCursor(), ), onTap: () { tapFunctions(context); Provider.of<OnOff>(context, listen: false) .maxAbout(); Provider.of<Apps>(context, listen: false).openApp( About( key: ObjectKey("about"), initPos: Offset( screenWidth(context, mulBy: 0.2), screenHeight(context, mulBy: 0.12))), Provider.of<OnOff>(context, listen: false) .maxAbout() ); }, ), DockerItem( iName: "Spotify", on: spotifyOpen, dx: _getPath(screenWidth(context, mulBy: 0.2156), _getCursor(), ), onTap: () { tapFunctions(context); Provider.of<OnOff>(context, listen: false) .maxSpotify(); Provider.of<Apps>(context, listen: false).openApp( Spotify( key: ObjectKey("spotify"), initPos: Offset( screenWidth(context, mulBy: 0.24), screenHeight(context, mulBy: 0.15) )), Provider.of<OnOff>(context, listen: false) .maxSpotify() ); }, ), DockerItem( iName: "Terminal", on: terminalOpen, dx: _getPath(screenWidth(context, mulBy: 0.2548), _getCursor(), ), onTap: () { tapFunctions(context); Provider.of<OnOff>(context, listen: false) .maxTerminal(); Provider.of<Apps>(context, listen: false).openApp( Terminal( key: ObjectKey("terminal"), initPos: Offset( screenWidth(context, mulBy: 0.28), screenHeight(context, mulBy: 0.2))), Provider.of<OnOff>(context, listen: false) .maxTerminal() ); }, ), DockerItem( iName: "Visual Studio Code", on: vsOpen, dx: _getPath(screenWidth(context, mulBy: 0.294), _getCursor(), ), onTap: () { tapFunctions(context); Provider.of<OnOff>(context, listen: false).maxVS(); Provider.of<Apps>(context, listen: false).openApp( VSCode( key: ObjectKey("vscode"), initPos: Offset( screenWidth(context, mulBy: 0.24), screenHeight(context, mulBy: 0.15))), Provider.of<OnOff>(context, listen: false).maxVS() ); }, ), DockerItem( iName: "Photos", on: false, dx: _getPath(screenWidth(context, mulBy: 0.3332), _getCursor(), ), onTap: (){ Provider.of<DataBus>(context, listen: false).setNotification( "App has not been installed. Create the app on GitHub.", "https://github.com/chrisbinsunny", "photos", "Not installed" ); Provider.of<OnOff>(context, listen: false).onNotifications(); }, ), InkWell( mouseCursor: SystemMouseCursors.basic, child: AnimatedContainer( duration: const Duration(milliseconds: 80), transform: Matrix4.identity() ..scale((.6*_getPath(screenWidth(context, mulBy: 0.3724), _getCursor(), ))+1,(.6*_getPath(screenWidth(context, mulBy: 0.3724), _getCursor(), ))+1) ..translate(-_getPath(screenWidth(context, mulBy: 0.3724), _getCursor(), )*8, -(_getPath(screenWidth(context, mulBy: 0.3724), _getCursor(), )*18), 0, ), child: Container( margin: EdgeInsets.symmetric( vertical: 3 ), decoration: BoxDecoration( gradient: LinearGradient( colors: [ Color(0xff118bff), Color(0xff1c59a4), ], begin: Alignment.topCenter, end: Alignment.bottomCenter ), shape: BoxShape.circle ), padding: EdgeInsets.symmetric( vertical: 7, horizontal: 10 ), height: 47, width: 47, child: FittedBox( child: Icon( CupertinoIcons.fullscreen, color: Colors.white, size: 30, ), ), )), onTap: (){ if(!isWebMobile){ html.document.documentElement!.requestFullscreen(); } }, ), InkWell( onTap: (){ tapFunctions(context); Provider.of<OnOff>(context, listen: false) .maxCalendar(); Provider.of<Apps>(context, listen: false).openApp( Calendar( key: ObjectKey("calendar"), initPos: Offset( screenWidth(context, mulBy: 0.24), screenHeight(context, mulBy: 0.15)) ), Provider.of<OnOff>(context, listen: false) .maxCalendar() ); }, child: Column( children: [ Expanded( child: AnimatedContainer( duration: const Duration(milliseconds: 80), transform: Matrix4.identity() ..scale((.6*_getPath(screenWidth(context, mulBy: 0.4116), _getCursor(), ))+1,(.6*_getPath(screenWidth(context, mulBy: 0.4116), _getCursor(), ))+1) ..translate(-_getPath(screenWidth(context, mulBy: 0.4116), _getCursor(), )*8, -(_getPath(screenWidth(context, mulBy: 0.4116), _getCursor(), )*18), 0, ), child: Stack( alignment: Alignment.topCenter, children: [ Image.asset( "assets/apps/calendar.png", ), Positioned( top: screenHeight(context, mulBy: 0.006), child: Container( height: screenHeight(context, mulBy: 0.014), width: screenWidth(context, mulBy: 0.025), color: Colors.transparent, child: FittedBox( fit: BoxFit.fitHeight, child: Text( "${DateFormat('LLL').format(now).toUpperCase()}", textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontFamily: 'SF', fontWeight: FontWeight.w400, fontSize: 11, ), ), ), ), ), Positioned( top: screenHeight(context, mulBy: 0.017), child: Container( height: screenHeight(context, mulBy: 0.031), width: screenWidth(context, mulBy: 0.025), color: Colors.transparent, child: FittedBox( fit: BoxFit.fitHeight, child: Text( "${DateFormat('d').format(now).toUpperCase()}", style: TextStyle( color: Colors.black87 .withOpacity(0.8), fontFamily: 'SF', fontWeight: FontWeight.w400, fontSize: 28), ), ), ), ), ], )), ), Container( height: 4, width: 4, decoration: BoxDecoration( color: calendarOpen! ? Theme.of(context) .cardColor .withOpacity(1) : Colors.transparent, shape: BoxShape.circle, ), ), ], ), ), DockerItem( iName: "Notes", on: false, dx: _getPath(screenWidth(context, mulBy: 0.4508), _getCursor(), ), onTap: (){ Provider.of<DataBus>(context, listen: false).setNotification( "App has not been installed. Create the app on GitHub.", "https://github.com/chrisbinsunny", "notes", "Not installed" ); Provider.of<OnOff>(context, listen: false).onNotifications(); }, ), DockerItem( iName: "Feedback", on: fbOpen, dx: _getPath(screenWidth(context, mulBy: 0.49), _getCursor(), ), onTap: () { tapFunctions(context); Provider.of<OnOff>(context, listen: false) .maxFeedBack(); Provider.of<Apps>(context, listen: false).openApp( FeedBack( key: ObjectKey("feedback"), initPos: Offset( screenWidth(context, mulBy: 0.2), screenHeight(context, mulBy: 0.12))), Provider.of<OnOff>(context, listen: false) .maxFeedBack() ); }, ), DockerItem( iName: "System Preferences", on: Provider.of<Apps>(context).isOpen(ObjectKey("systemPreferences")), dx: _getPath(screenWidth(context, mulBy: 0.5292), _getCursor(), ), onTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false) .maxSysPref(); Provider.of<Apps>(context, listen: false).openApp( SystemPreferences( key: ObjectKey("systemPreferences"), initPos: Offset( screenWidth(context, mulBy: 0.27), screenHeight(context, mulBy: 0.13))), Provider.of<OnOff>(context, listen: false) .maxSysPref() ); }); }, ), ] ), ), MouseRegion( opaque: false, onHover: (event) { setState(() { _offsetX = event.localPosition.dx; _offsetY= event.localPosition.dy; }); }, onExit: (event) { setState(() { _offsetX = 0; }); }, child: Container( padding: EdgeInsets.only(bottom: 2), width: screenWidth(context, mulBy: 0.55), height: screenHeight(context, mulBy: 0.135), ), ), ], ), SizedBox( height: screenHeight(context, mulBy: 0.005), ) ], ), ); } } class DockerItem extends StatefulWidget { final String iName; final bool? on; ///change to be applied double dx; VoidCallback? onTap=(){}; DockerItem({ Key? key, required this.iName, required this.dx, this.on = false, this.onTap }) : super(key: key); @override _DockerItemState createState() => _DockerItemState(); } class _DockerItemState extends State<DockerItem> { @override Widget build(BuildContext context) { return InkWell( onTap: widget.onTap, mouseCursor: MouseCursor.defer, child: Column( mainAxisSize: MainAxisSize.min, children: [ Expanded( child: AnimatedContainer( duration: const Duration(milliseconds: 80), transform: Matrix4.identity() ..scale((.5*widget.dx)+1,(.5*widget.dx)+1) ..translate(-widget.dx*8, -(widget.dx*16), 0, ), child: Image.asset( widget.iName.contains("/")?widget.iName:"assets/apps/${widget.iName.toLowerCase()}.png", ))), Container( height: 4, width: 4, decoration: BoxDecoration( color: widget.on! ? Theme.of(context).cardColor.withOpacity(1) : Colors.transparent, shape: BoxShape.circle, ), ) ], ), ); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/components/alertDialog.dart
import 'dart:developer'; import 'dart:html'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import '../sizes.dart'; import 'dart:ui' as ui; import '../widgets.dart'; class MacOSAlertDialog extends StatelessWidget { MacOSAlertDialog({Key? key, }) : super(key: key); @override Widget build(BuildContext context) { log(screenHeight(context, mulBy: 0.37).toString()); ///Checking if the system is running on mobile final bool isWebMobile = kIsWeb && (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.android); return Dialog( backgroundColor: Colors.transparent, elevation: 0, alignment: Alignment.center, child: ClipRRect( borderRadius: BorderRadius.circular(15), child: BackdropFilter( filter: ui.ImageFilter.blur( sigmaX: 70.0, sigmaY: 70.0), child: Container( width: screenWidth(context, mulBy: 0.165), height: screenHeight(context, mulBy: 0.37), constraints: const BoxConstraints( minWidth: 250, minHeight: 340, maxWidth: 317, maxHeight: 356 ), alignment: Alignment.center, decoration: BoxDecoration( color: Theme.of(context).hintColor, borderRadius: BorderRadius.circular(15), border: Border.all( color: Colors.white.withOpacity(0.2), ), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), spreadRadius: 10, blurRadius: 15, offset: Offset(0, 8), // changes position of shadow ), ], ), child: SingleChildScrollView( physics: BouncingScrollPhysics(), child: Padding( padding: const EdgeInsets .symmetric( horizontal: 30, vertical: 5 ), child: Column( mainAxisAlignment: MainAxisAlignment .center, crossAxisAlignment: CrossAxisAlignment .center, children: [ const SizedBox( height: 20, ), Icon( CupertinoIcons.exclamationmark_circle, color: Colors.redAccent, size: 65, //device_desktop ), const SizedBox( height: 20, ), Text( "Chrisbin's MacBook Pro", style: TextStyle( color: Theme.of(context).cardColor.withOpacity(1), fontWeight: FontWeight.w700, fontSize: 20 ), ), const SizedBox( height: 10, ), Padding( padding: const EdgeInsets.symmetric( horizontal: 20 ), child: isWebMobile? Text( "The website is recommended to be used on a computer browser. " "Please use a computer browser for full experience.", style: TextStyle( color: Theme.of(context).cardColor.withOpacity(1), fontWeight: FontWeight.w400, fontSize: 14 ), textAlign: TextAlign.center, ): RichText( text: TextSpan( children: [ TextSpan( text: "The website is recommended to be used in fullscreen. " "Click the button below or the icon(", ), WidgetSpan( child: Icon( CupertinoIcons.fullscreen, size: 14, color: Theme.of(context).cardColor.withOpacity(1), ), ), TextSpan( text: ") on the desktop to toggle fullscreen.", ), ], style: TextStyle( color: Theme.of(context).cardColor.withOpacity(1), fontWeight: FontWeight.w400, fontSize: 14 ), ), textAlign: TextAlign.center, ), ), const SizedBox( height: 20, ), isWebMobile? InkWell( child: Container( padding: EdgeInsets.symmetric( vertical: 7 ), alignment: Alignment.center, child: Text( "Continue", style: TextStyle( color: Colors.white, fontWeight: FontWeight.w500, fontSize: 14 ), ), decoration: BoxDecoration( gradient: LinearGradient( colors: [ Color(0xff118bff), Color(0xff1c59a4), ], begin: Alignment.topCenter, end: Alignment.bottomCenter ), borderRadius: BorderRadius.circular(7) ), ), onTap: (){ Navigator.pop(context); }, mouseCursor: SystemMouseCursors.click, ): InkWell( child: Container( padding: EdgeInsets.symmetric( vertical: 7 ), alignment: Alignment.center, child: Text( "Full Screen", style: TextStyle( color: Colors.white, fontWeight: FontWeight.w500, fontSize: 14 ), ), decoration: BoxDecoration( gradient: LinearGradient( colors: [ Color(0xff107deb), Color(0xff226eca), ], begin: Alignment.topCenter, end: Alignment.bottomCenter ), borderRadius: BorderRadius.circular(7) ), ), onTap: (){ if(!isWebMobile){ document.documentElement!.requestFullscreen(); } Navigator.pop(context); }, mouseCursor: SystemMouseCursors.click, ), const SizedBox( height: 10, ), Visibility( visible: !isWebMobile, child: InkWell( mouseCursor: SystemMouseCursors.click, onTap: (){ Navigator.pop(context); }, child: Container( padding: EdgeInsets.symmetric( vertical: 7 ), alignment: Alignment.center, child: Text( "Cancel", style: TextStyle( color: Colors.white, fontWeight: FontWeight.w500, fontSize: 14 ), ), decoration: BoxDecoration( color: Colors.white.withOpacity(0.4), borderRadius: BorderRadius.circular(7) ), ), ), ), const SizedBox( height: 20, ), ], ), ), ), ), ), ), ); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/components/finderWindow.dart
import 'dart:ui'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:intl/intl.dart'; import 'package:mac_dt/system/componentsOnOff.dart'; import 'package:mac_dt/theme/theme.dart'; import 'package:provider/provider.dart'; import '../apps/about.dart'; import '../apps/calendar.dart'; import '../apps/feedback/feedback.dart'; import '../apps/launchpad.dart'; import '../apps/messages/messages.dart'; import '../apps/safari/safariWindow.dart'; import '../apps/spotify.dart'; import '../apps/systemPreferences.dart'; import '../apps/terminal/terminal.dart'; import '../apps/vscode.dart'; import '../components/windowWidgets.dart'; import '../data/analytics.dart'; import '../providers.dart'; import '../system/folders/folders.dart'; import '../system/folders/folders_CRUD.dart'; import '../system/openApps.dart'; import '../sizes.dart'; import 'dart:html' as html; import '../widgets.dart'; class Finder extends StatefulWidget { final Offset? initPos; const Finder({this.initPos, Key? key}) : super(key: key); @override _FinderState createState() => _FinderState(); } class _FinderState extends State<Finder> { Offset? position = Offset(0.0, 0.0); String selected = "Applications"; late bool finderFS; late bool finderPan; late DateTime now; late List<Folder> folders; final _navigatorKey2 = GlobalKey<NavigatorState>(); final _navigatorKey3 = GlobalKey<NavigatorState>(); getContent(){ switch(selected){ case "Applications": return GridView( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: finderFS?6:4, childAspectRatio: finderFS?3.3:2.5, mainAxisSpacing: screenHeight(context, mulBy: 0.05) ), padding: EdgeInsets.symmetric( vertical: screenHeight(context, mulBy: 0.04), ), shrinkWrap: true, scrollDirection: Axis.vertical, physics: BouncingScrollPhysics(), children: [ LaunchPadItem( iName: "About Me", onTap: () { tapFunctions(context); Provider.of<OnOff>(context, listen: false) .maxAbout(); Provider.of<Apps>(context, listen: false).openApp( About( key: ObjectKey("about"), initPos: Offset( screenWidth(context, mulBy: 0.2), screenHeight(context, mulBy: 0.12))), Provider.of<OnOff>(context, listen: false) .maxAbout() ); }, ), LaunchPadItem( iName: "Safari", folder: true, onDoubleTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false) .maxSafari(); Provider.of<Apps>(context, listen: false).openApp( Safari( key: ObjectKey("safari"), initPos: Offset( screenWidth(context, mulBy: 0.14), screenHeight(context, mulBy: 0.1))), Provider.of<OnOff>(context, listen: false) .maxSafari() ); }); }, ), LaunchPadItem( iName: "Messages", folder: true, onDoubleTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false) .maxMessages(); Provider.of<Apps>(context, listen: false).openApp( Messages( key: ObjectKey("messages"), initPos: Offset( screenWidth(context, mulBy: 0.27), screenHeight(context, mulBy: 0.2))), Provider.of<OnOff>(context, listen: false) .maxMessages() ); }); }, ), LaunchPadItem( iName: "Maps", folder: true, onDoubleTap: (){ Provider.of<DataBus>(context, listen: false).setNotification( "App has not been installed. Create the app on GitHub.", "https://github.com/chrisbinsunny", "maps", "Not installed" ); Provider.of<OnOff>(context, listen: false).onNotifications(); }, ), LaunchPadItem( iName: "Spotify", folder: true, onDoubleTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false) .maxSpotify(); Provider.of<Apps>(context, listen: false).openApp( Spotify( key: ObjectKey("spotify"), initPos: Offset( screenWidth(context, mulBy: 0.24), screenHeight(context, mulBy: 0.15) )), Provider.of<OnOff>(context, listen: false) .maxSpotify() ); }); }, ), LaunchPadItem( iName: "Terminal", folder: true, onDoubleTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false) .maxTerminal(); Provider.of<Apps>(context, listen: false).openApp( Terminal( key: ObjectKey("terminal"), initPos: Offset( screenWidth(context, mulBy: 0.28), screenHeight(context, mulBy: 0.2))), Provider.of<OnOff>(context, listen: false) .maxTerminal() ); }); }, ), LaunchPadItem( iName: "Visual Studio Code", folder: true, onDoubleTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false).maxVS(); Provider.of<Apps>(context, listen: false).openApp( VSCode( key: ObjectKey("vscode"), initPos: Offset( screenWidth(context, mulBy: 0.24), screenHeight(context, mulBy: 0.15))), Provider.of<OnOff>(context, listen: false).maxVS() ); }); }, ), LaunchPadItem( iName: "Photos", folder: true, onDoubleTap: (){ Provider.of<DataBus>(context, listen: false).setNotification( "App has not been installed. Create the app on GitHub.", "https://github.com/chrisbinsunny", "photos", "Not installed" ); Provider.of<OnOff>(context, listen: false).onNotifications(); }, ), LaunchPadItem( iName: "Contacts", folder: true, onDoubleTap: (){ Provider.of<DataBus>(context, listen: false).setNotification( "App has not been installed. Create the app on GitHub.", "https://github.com/chrisbinsunny", "contacts", "Not installed" ); Provider.of<OnOff>(context, listen: false).onNotifications(); }, ), InkWell( onDoubleTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false) .maxCalendar(); Provider.of<Apps>(context, listen: false).openApp( Calendar( key: ObjectKey("calendar"), initPos: Offset( screenWidth(context, mulBy: 0.24), screenHeight(context, mulBy: 0.15) ) ), Provider.of<OnOff>(context, listen: false) .maxCalendar() ); }); }, child: Column( children: [ Expanded( ///For setting the Text on the icon on position. Done by getting relative position. child: LayoutBuilder(builder: (context, cont) { return Stack( alignment: Alignment.topCenter, children: [ Image.asset( "assets/apps/calendar.png", ), Positioned( top: cont.smallest.height * .13, child: Container( height: cont.maxHeight*0.23, width: screenWidth(context, mulBy: 0.03), //color: Colors.green, child: FittedBox( fit: BoxFit.fitHeight, child: Text( "${DateFormat('LLL').format(now).toUpperCase()}", textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontFamily: "SF", fontWeight: FontWeight.w500, fontSize: 11, ), ), ), ), ), Positioned( top: cont.smallest.height * .35, child: Container( height: cont.maxHeight*0.5, width: screenWidth(context, mulBy: 0.03), //color:Colors.green, child: FittedBox( fit: BoxFit.fitHeight, child: Text( "${DateFormat('d').format(now).toUpperCase()}", style: TextStyle( color: Colors.black87 .withOpacity(0.8), fontFamily: 'SF', fontWeight: FontWeight.w400, fontSize: 28), ), ), ), ), ], ); },), ), MBPText( text: "Calendar", color: Theme.of(context).cardColor.withOpacity(1), ) ], ), ), LaunchPadItem( iName: "Notes", folder: true, onDoubleTap: (){ Provider.of<DataBus>(context, listen: false).setNotification( "App has not been installed. Create the app on GitHub.", "https://github.com/chrisbinsunny", "notes", "Not installed" ); Provider.of<OnOff>(context, listen: false).onNotifications(); }, ), LaunchPadItem( iName: "Feedback", folder: true, onDoubleTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false) .maxFeedBack(); Provider.of<Apps>(context, listen: false).openApp( FeedBack( key: ObjectKey("feedback"), initPos: Offset( screenWidth(context, mulBy: 0.2), screenHeight(context, mulBy: 0.12))), Provider.of<OnOff>(context, listen: false) .maxFeedBack() ); }); }, ), LaunchPadItem( iName: "System Preferences", folder: true, onDoubleTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false) .maxSysPref(); Provider.of<Apps>(context, listen: false).openApp( SystemPreferences( key: ObjectKey("systemPreferences"), initPos: Offset( screenWidth(context, mulBy: 0.27), screenHeight(context, mulBy: 0.13))), Provider.of<OnOff>(context, listen: false) .maxSysPref() ); }); }, ), ], ); break; case "Desktop": return GridView( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: finderFS?6:4, childAspectRatio: finderFS?0.9:6/5, mainAxisSpacing: 0 ), padding: EdgeInsets.symmetric( vertical: screenHeight(context, mulBy: 0.04), ), shrinkWrap: true, scrollDirection: Axis.vertical, physics: BouncingScrollPhysics(), children: folders.map((e) => FolderForFinder( name: e.name, renaming: false, ) ).toList(), ); break; case "Documents": return WillPopScope( onWillPop: () async => !await _navigatorKey2.currentState!.maybePop(), child: Navigator( key: _navigatorKey2, onGenerateRoute: (routeSettings) { return MaterialPageRoute( builder: (context) { return Padding( padding: EdgeInsets.symmetric( vertical: screenHeight(context, mulBy: 0.04), ), child: Wrap( spacing: 20, runSpacing: 20, children: [ FinderItems( name: "Cabby: Published Paper.pdf", link: "https://www.transistonline.com/downloads/cabby-the-ride-sharing-platform/", ), FinderItems( name: "Chrisbin Resume.pdf", link: "https://drive.google.com/file/d/1cuIQHOhjvZfM_M74HjsICNpuzvMO0uKX/view", ), FinderItems( name: "Chrisbin Resume Dark long.pdf", link: "https://drive.google.com/file/d/1lPK15gLkNr2Rso3JNr0b-RdmFN245w87/view", ), FinderItems( name: "Chrisbin Resume Light long.pdf", link: "https://drive.google.com/file/d/11j0UCdSXBRA1DPFct1EImmKFpyQu0fiH/view", ), FinderItems( name: "Interests", link: "", nav: (){ Navigator.of(context) .push(PageRouteBuilder( pageBuilder: (_, __, ___) => Interests(), )); }, folder: true, ), FinderItems( name: "Languages", link: "", nav: (){ Navigator.of(context) .push(PageRouteBuilder( pageBuilder: (_, __, ___) => Languages(), )); }, folder: true, ), FinderItems( name: "Projects", link: "", nav: (){ Navigator.of(context) .push(PageRouteBuilder( pageBuilder: (_, __, ___) => Projects(), )); }, folder: true, ), ], ), ); }, ); }, ), ); break; case "Downloads": return Navigator( key: _navigatorKey3, onGenerateRoute: (routeSettings) { return MaterialPageRoute( builder: (context) { return Padding( padding: EdgeInsets.symmetric( vertical: screenHeight(context, mulBy: 0.04), ), child: Wrap( spacing: 20, runSpacing: 20, children: [ FinderItems( name: "Antonn- Game Testing platform.pdf", link: "", ), FinderItems( name: "Cabby final.pdf", link: "", ), FinderItems( name: "Chrisbin seminar.pdf", link: "", ), FinderItems( name: "Flutter Talks.pdf", link: "", ), FinderItems( name: "Ride Sharing platform.pdf", link: "", ), FinderItems( name: "Dream.zip", link: "", nav: null, folder: true, ), FinderItems( name: "Material Icon Pack.zip", link: "", nav: null, folder: true, ), ], ), ); }, ); }, ); return GridView( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 5, childAspectRatio: 6/5.5, mainAxisSpacing: screenHeight(context, mulBy: 0.05) ), padding: EdgeInsets.symmetric( vertical: screenHeight(context, mulBy: 0.04), ), shrinkWrap: true, scrollDirection: Axis.vertical, physics: BouncingScrollPhysics(), children: [ FinderItems( name: "Antonn- Game Testing platform.pdf", link: "", ), FinderItems( name: "Cabby final.pdf", link: "", ), FinderItems( name: "Chrisbin seminar.pdf", link: "", ), FinderItems( name: "Flutter Talks.pdf", link: "", ), FinderItems( name: "Ride Sharing platform.pdf", link: "", ), FinderItems( name: "Dream.zip", link: "", nav: null, folder: true, ), ], ); break; case "Movies": return SizedBox(); break; case "Music": return SizedBox(); break; case "Pictures": return SizedBox(); break; } } @override void initState() { position = widget.initPos; now = DateTime.now(); super.initState(); Provider.of<AnalyticsService>(context, listen: false) .logCurrentScreen("Finder"); } @override Widget build(BuildContext context) { finderFS = Provider.of<OnOff>(context).getFinderFS; finderPan = Provider.of<OnOff>(context).getFinderPan; folders = Provider.of<Folders>(context, listen: true).getFolders; return AnimatedPositioned( duration: Duration(milliseconds: finderPan ? 0 : 200), top: finderFS ? 25 : position!.dy, left: finderFS ? 0 : position!.dx, child: finderWindow(context), ); } AnimatedContainer finderWindow(BuildContext context) { String topApp = Provider.of<Apps>(context).getTop; return AnimatedContainer( duration: Duration(milliseconds: 200), width: finderFS ? screenWidth(context, mulBy: 1) : screenWidth(context, mulBy: 0.55), height: finderFS ? screenHeight(context, mulBy: 0.975) : screenHeight(context, mulBy: 0.65), decoration: BoxDecoration( border: Border.all( color: Colors.white.withOpacity(0.2), ), borderRadius: BorderRadius.all(Radius.circular(15)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), spreadRadius: 10, blurRadius: 15, offset: Offset(0, 8), // changes position of shadow ), ], ), child: Stack( alignment: Alignment.topRight, children: [ Row( children: [ ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(15), bottomLeft: Radius.circular(15)), child: BackdropFilter( filter: ImageFilter.blur(sigmaX: 70.0, sigmaY: 70.0), child: Container( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.013), vertical: screenHeight(context, mulBy: 0.025)), height: screenHeight(context), width: screenWidth(context, mulBy: 0.14), decoration: BoxDecoration( color: Theme.of(context).hintColor, borderRadius: BorderRadius.only( topLeft: Radius.circular(15), bottomLeft: Radius.circular(15))), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.redAccent, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<OnOff>(context, listen: false) .offFinderFS(); Provider.of<Apps>(context, listen: false) .closeApp("finder"); Provider.of<OnOff>(context, listen: false) .toggleFinder(); }, ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( onTap: () { Provider.of<OnOff>(context, listen: false) .toggleFinder(); Provider.of<OnOff>(context, listen: false) .offFinderFS(); }, child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.amber, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.green, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<OnOff>(context, listen: false) .toggleFinderFS(); }, ) ], ), SizedBox( height: screenHeight(context, mulBy: 0.035), ), Text( "Favourites", style: TextStyle( fontWeight: Theme.of(context) .textTheme .headline1! .fontWeight, fontFamily: "SF", color: Theme.of(context).cardColor.withOpacity(.38), fontSize: 12, ), ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), InkWell( onTap: () { setState(() { selected = "Applications"; }); }, child: LeftPaneItems( iName: "Applications", isSelected: (selected == "Applications") ? true : false, )), InkWell( onTap: () { setState(() { selected = "Desktop"; }); }, child: LeftPaneItems( iName: "Desktop", isSelected: (selected == "Desktop") ? true : false, ), ), InkWell( onTap: () { setState(() { selected = "Documents"; }); }, child: LeftPaneItems( iName: "Documents", isSelected: (selected == "Documents") ? true : false, ), ), InkWell( onTap: () { setState(() { selected = "Downloads"; }); }, child: LeftPaneItems( iName: "Downloads", isSelected: (selected == "Downloads") ? true : false, ), ), InkWell( onTap: () { setState(() { selected = "Movies"; }); }, child: LeftPaneItems( iName: "Movies", isSelected: (selected == "Movies") ? true : false, ), ), InkWell( onTap: () { setState(() { selected = "Music"; }); }, child: LeftPaneItems( iName: "Music", isSelected: (selected == "Music") ? true : false, ), ), InkWell( onTap: () { setState(() { selected = "Pictures"; }); }, child: LeftPaneItems( iName: "Pictures", isSelected: (selected == "Pictures") ? true : false, ), ), ], ), ), ), ), Expanded( child: Container( padding: EdgeInsets.only( left: screenWidth(context, mulBy: 0.013), right: screenWidth(context, mulBy: 0.013), top: screenHeight(context, mulBy: 0.03)), decoration: BoxDecoration( color: Theme.of(context).scaffoldBackgroundColor, borderRadius: BorderRadius.only( topRight: Radius.circular(15), bottomRight: Radius.circular(15))), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ InkWell( onTap: () async => !await _navigatorKey2.currentState!.maybePop(), child: Row( children: [ Image.asset("assets/icons/backB.png", height: 18), SizedBox( width: screenWidth(context, mulBy: 0.01), ), Image.asset("assets/icons/forwB.png", height: 18.5), SizedBox( width: screenWidth(context, mulBy: 0.007), ), Container( width: screenWidth(context, mulBy: 0.07), child: MBPText( text: selected, size: 15, weight: Theme.of(context) .textTheme .headline1! .fontWeight, color: Theme.of(context) .cardColor .withOpacity(1), // style: TextStyle( // fontWeight: FontWeight.w700, // color: Colors.black.withOpacity(0.7), // fontSize: 15, // ), ), ), ], ), ), Image.asset("assets/icons/sortB.png", height: 20), Row( children: [ Image.asset("assets/icons/iconB.png", height: 18), SizedBox( width: screenWidth(context, mulBy: 0.015), ), Image.asset("assets/icons/shareB.png", height: 19), SizedBox( width: screenWidth(context, mulBy: 0.015), ), Image.asset("assets/icons/tagB.png", height: 15), ], ), Row( children: [ Image.asset("assets/icons/moreB.png", height: 15), SizedBox( width: screenWidth(context, mulBy: 0.007), ), Image.asset("assets/icons/searchB.png", height: 15), ], ), ], ), SizedBox( height: screenHeight(context, mulBy: 0.01), ), Expanded(child: getContent(),) ], ), ), ) ], ), GestureDetector( onPanUpdate: (tapInfo) { if (!finderFS) { setState(() { position = Offset(position!.dx + tapInfo.delta.dx, position!.dy + tapInfo.delta.dy); }); } }, onPanStart: (details) { Provider.of<OnOff>(context, listen: false).onFinderPan(); }, onPanEnd: (details) { Provider.of<OnOff>(context, listen: false).offFinderPan(); }, onDoubleTap: () { Provider.of<OnOff>(context, listen: false).toggleFinderFS(); }, child: Container( alignment: Alignment.centerRight, width: finderFS ? screenWidth(context, mulBy: 0.95) : screenWidth(context, mulBy: 0.5), height: screenHeight(context, mulBy: 0.04), color: Colors.transparent), ), Visibility( visible: topApp != "Finder", child: InkWell( onTap: (){ Provider.of<Apps>(context, listen: false) .bringToTop(ObjectKey("finder")); }, child: Container( width: screenWidth(context,), height: screenHeight(context,), color: Colors.transparent, ), ), ), ], ), ); } } class FolderForFinder extends StatefulWidget { String? name; bool? renaming; bool selected; late VoidCallback deSelectFolder; late VoidCallback renameFolder; FolderForFinder({Key? key, this.name, this.renaming= false, this.selected=false,}): super(key: key); @override _FolderForFinderState createState() => _FolderForFinderState(); } class _FolderForFinderState extends State<FolderForFinder> { TextEditingController? controller; FocusNode _focusNode = FocusNode(); bool pan= false; bool bgVisible= false; @override void initState() { super.initState(); controller = new TextEditingController(text: widget.name, ); controller!.selection=TextSelection.fromPosition(TextPosition(offset: controller!.text.length)); selectText(); widget.renameFolder=(){ if (!mounted) return; setState(() { widget.renaming=true; }); }; widget.deSelectFolder= (){ if (!mounted) return; setState(() { widget.selected=false; widget.renaming=false; //widget.name=controller.text.toString(); }); }; } void selectText(){ _focusNode.addListener(() { if(_focusNode.hasFocus) { controller!.selection = TextSelection(baseOffset: 0, extentOffset: controller!.text.length); } }); } @override Widget build(BuildContext context) { List<Folder> folders= Provider.of<Folders>(context).getFolders; return Container( height: screenHeight(context), width: screenWidth(context), child: GestureDetector( //TODO ///Gestures are turned off for now. Will have to re-do the gestures for folderforFinder // onTap: (){ // tapFunctions(context); // if (!mounted) return; // setState(() { // widget.selected=true; // }); // }, // // onSecondaryTap: (){ // if (!mounted) return; // setState(() { // widget.selected=true; // }); // Provider.of<OnOff>(context, listen: false).onFRCM(); // }, // onSecondaryTapDown: (details){ // tapFunctions(context); // Provider.of<DataBus>(context, listen: false).setPos(details.globalPosition); // }, child: Container( width: screenWidth(context, mulBy: 0.08), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Container( height: screenHeight(context, mulBy: 0.1), padding: EdgeInsets.symmetric(horizontal: screenWidth(context,mulBy: 0.0005)), decoration: (widget.renaming!||widget.selected)?BoxDecoration( color: Colors.black.withOpacity(0.25), border: Border.all( color: Colors.grey.withOpacity(0.4), width: 2 ), borderRadius: BorderRadius.circular(4) ):BoxDecoration( border: Border.all( color: Colors.grey.withOpacity(0.0), width: 2 ), ), child: Image.asset("assets/icons/folder.png", height: screenHeight(context, mulBy: 0.085), width: screenWidth(context, mulBy: 0.045), ), ), SizedBox(height: screenHeight(context, mulBy: 0.005), ), widget.renaming!? Container( height: screenHeight(context, mulBy: 0.024), width: screenWidth(context, mulBy: 0.06), decoration: BoxDecoration( color: Color(0xff1a6cc4).withOpacity(0.7), border: Border.all( color: Colors.blueAccent ), borderRadius: BorderRadius.circular(3) ), child: Theme( data: ThemeData(textSelectionTheme: TextSelectionThemeData( selectionColor: Colors.transparent)), child: TextField( controller: controller, autofocus: true, focusNode: _focusNode, textAlign: TextAlign.center, inputFormatters: [ LengthLimitingTextInputFormatter(18), ], decoration: InputDecoration( isDense: true, contentPadding: EdgeInsets.only(top: 4.5, bottom: 0, left: 0, right: 0), border: InputBorder.none, focusedBorder: InputBorder.none, enabledBorder: InputBorder.none, errorBorder: InputBorder.none, disabledBorder: InputBorder.none, ), cursorColor: Colors.white60, style: TextStyle( color: Colors.white, fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 12 ), onSubmitted: (s){ if (!mounted) return; setState(() { widget.renaming=false; if(controller!.text=="") ///changes controller to sys found name if empty. controller!.text=widget.name!; int folderNum=0; for(int element=0; element<folders.length; element++) { if(folders[element].name==controller!.text) { if(int.tryParse(folders[element].name!.split(" ").last)!=null) { ///for not changing "untitled folder" to "untitled 1" folderNum = int.parse(folders[element].name!.split(" ").last) ?? folderNum; controller!.text = "${controller!.text.substring(0, controller!.text.lastIndexOf(" "))} ${++folderNum}"; element=0; ///for checking if changed name == name in already checked folders } else{ controller!.text = "${controller!.text} ${++folderNum}"; } } } FoldersDataCRUD.renameFolder(widget.name!, controller!.text.toString()); widget.name=controller!.text.toString(); }); }, ), ), ) :Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( height: screenHeight(context, mulBy: 0.024), padding: EdgeInsets.symmetric(horizontal: screenWidth(context,mulBy: 0.005)), alignment: Alignment.center, decoration: widget.selected?BoxDecoration( color: Color(0xff0058d0), borderRadius: BorderRadius.circular(3) ):BoxDecoration(), child: Text(widget.name??"", textAlign: TextAlign.center, style: TextStyle(color: Theme.of(context).cardColor.withOpacity(1), fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 12,), maxLines: 1, overflow: TextOverflow.ellipsis, ), ), ], ) ], ), ), ), ); } } class FinderItems extends StatelessWidget { const FinderItems({Key? key, required this.name, required this.link, this.folder=false, this.nav}) : super(key: key); final String name, link; final VoidCallback? nav; final bool folder; @override Widget build(BuildContext context) { return SizedBox( height: screenHeight(context, mulBy: 0.11), child: InkWell( onTap: folder?nav:(link=="")?null:(){html.window.open(link, 'new tab');}, child: Container( width: screenWidth(context, mulBy: 0.08), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Expanded( child: Container( height: screenHeight(context, mulBy: 0.1), padding: EdgeInsets.symmetric(horizontal: screenWidth(context,mulBy: 0.0005)), decoration: BoxDecoration(), child: Image.asset(folder?"assets/icons/folder.png":"assets/icons/pdfMac.png", height: screenHeight(context, mulBy: 0.085), width: screenWidth(context, mulBy: 0.045), ), ), ), SizedBox(height: screenHeight(context, mulBy: 0.005), ), Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( padding: EdgeInsets.symmetric(horizontal: screenWidth(context,mulBy: 0.005)), alignment: Alignment.center, decoration: BoxDecoration(), width: screenWidth(context, mulBy: 0.07), child: Text(name+"\n", textAlign: TextAlign.center, style: TextStyle(color: Theme.of(context).cardColor.withOpacity(1), fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 12,), maxLines: 2, overflow: TextOverflow.ellipsis, ), ), ], ) ], ), ), ), ); } } class Interests extends StatelessWidget { const Interests({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Container( color: Theme.of(context).scaffoldBackgroundColor, child: GridView( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 5, childAspectRatio: 6/5.5, mainAxisSpacing: screenHeight(context, mulBy: 0.05) ), padding: EdgeInsets.symmetric( vertical: screenHeight(context, mulBy: 0.04), ), shrinkWrap: true, scrollDirection: Axis.vertical, physics: BouncingScrollPhysics(), children: [ FinderItems( name: "Software Engineering", link: "", folder: true, ), FinderItems( name: "Game Development", link: "", folder: true, ), FinderItems( name: "AI in Games", link: "", folder: true, ), FinderItems( name: "Deep Learning", link: "", folder: true, ), FinderItems( name: "Computer Vision", link: "", folder: true, ), ], ), ); } } class Languages extends StatelessWidget { const Languages({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Container( color: Theme.of(context).scaffoldBackgroundColor, child: GridView( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 5, childAspectRatio: 6/5.5, mainAxisSpacing: screenHeight(context, mulBy: 0.05) ), padding: EdgeInsets.symmetric( vertical: screenHeight(context, mulBy: 0.04), ), shrinkWrap: true, scrollDirection: Axis.vertical, physics: BouncingScrollPhysics(), children: [ FinderItems( name: "Flutter", link: "", folder: true, ), FinderItems( name: "Dart", link: "", folder: true, ), FinderItems( name: "Python", link: "", folder: true, ), FinderItems( name: "GoLang", link: "", folder: true, ), FinderItems( name: "C++", link: "", folder: true, ), FinderItems( name: "Java", link: "", folder: true, ), ], ), ); } } class Projects extends StatelessWidget { const Projects({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Container( color: Theme.of(context).scaffoldBackgroundColor, child: GridView( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 5, childAspectRatio: 6/5.5, mainAxisSpacing: screenHeight(context, mulBy: 0.05) ), padding: EdgeInsets.symmetric( vertical: screenHeight(context, mulBy: 0.04), ), shrinkWrap: true, scrollDirection: Axis.vertical, physics: BouncingScrollPhysics(), children: [ FinderItems( name: "Macbook", link: "", nav: (){html.window.open("https://chrisbinsunny.github.io/chrishub", 'new tab');}, folder: true, ), FinderItems( name: "Dream", link: "", nav: (){html.window.open("https://chrisbinsunny.github.io/dream", 'new tab');}, folder: true, ), FinderItems( name: "Portfolio old", link: "", nav: (){html.window.open("https://chrisbinsunny.github.io", 'new tab');}, folder: true, ), FinderItems( name: "Flutter-Talks", link: "", nav: (){html.window.open("https://chrisbinsunny.github.io/Flutter-Talks", 'new tab');}, folder: true, ), ], ), ); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/components/notification.dart
import 'dart:developer'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mac_dt/system/componentsOnOff.dart'; import 'package:mac_dt/providers.dart'; import 'package:mac_dt/theme/theme.dart'; import 'package:mac_dt/widgets.dart'; import 'package:provider/provider.dart'; import 'dart:ui' as ui; import 'dart:html' as html; import '../sizes.dart'; class Notifications extends StatefulWidget { Notifications({Key? key, }) : super(key: key); @override _NotificationsState createState() => _NotificationsState(); } class _NotificationsState extends State<Notifications> { late var themeNotifier; late Map<String, String> notification; bool notificationOn=false; bool hover=false; @override Widget build(BuildContext context) { themeNotifier = Provider.of<ThemeNotifier>(context); notification = Provider.of<DataBus>(context).getNotification; notificationOn = Provider.of<OnOff>(context).getNotificationOn; return Visibility( visible: true, child: AnimatedPositioned( duration: Duration(milliseconds: 500), right: notificationOn?screenWidth(context, mulBy: 0.01):-272, top: screenHeight(context, mulBy: 0.055), child: MouseRegion( onExit: (p){ setState(() { hover=false; }); }, onEnter: (p){ setState(() { hover=true; }); }, child: Stack( clipBehavior: Clip.none, children: [ InkWell( onTap: (){ html.window.open(notification["url"]!, 'new tab'); }, child: AnimatedContainer( duration: Duration(milliseconds: 200), width: 270.5, height: 75.5, constraints: BoxConstraints( minHeight: 80 ), decoration: BoxDecoration( border: Border.all(color: Theme.of(context).shadowColor, width: 1), borderRadius: BorderRadius.all(Radius.circular(10)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.1), spreadRadius: 5, blurRadius: 10, offset: Offset(0, 3), ), ], ), child: Container( width: 270, height: 75, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(10)), border: Border.all( color: Colors.grey.withOpacity(0.9), width: themeNotifier.isDark()?0.5:0 ), ), child: ClipRRect( borderRadius: BorderRadius.circular(10), child: BackdropFilter( filter: ui.ImageFilter.blur(sigmaX: 30.0, sigmaY: 30.0), child: Container( height: screenHeight(context, mulBy: 0.14), width: screenWidth( context, ), padding: EdgeInsets.only( left: screenWidth(context, mulBy: 0.005), right: screenWidth(context, mulBy: 0.01), top: screenHeight(context, mulBy: 0.007), bottom: screenHeight(context, mulBy: 0.01) ), decoration: BoxDecoration( color: Theme.of(context).focusColor ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Container( height: screenHeight(context, mulBy: 0.027), child: Image.asset( "assets/appsMac/${notification["app"]}.png", ), ), SizedBox( width: 3, ), MBPText( text: notification["app"]!.toUpperCase(), color: Theme.of(context).cardColor.withOpacity(0.5), size: 11, fontFamily: "SF", ), Spacer(), Center( child: MBPText(text: "now", color: Theme.of(context).cardColor.withOpacity(1), size: 11, ), ) ], ), Text( notification["head"]!, style: TextStyle( color: Theme.of(context).cardColor.withOpacity(1), fontSize: 11.5, fontWeight: Theme.of(context).textTheme.headline3!.fontWeight, ), maxLines: 1, ), MBPText( text: notification["notification"], color: Theme.of(context).cardColor.withOpacity(1), size: 11.5, weight: Theme.of(context).textTheme.headline2!.fontWeight, maxLines: 1, ), ], ) ), ), ), ), ), ), Visibility( visible: hover, child: Positioned( left: -screenHeight(context, mulBy: 0.007), top: -screenHeight(context, mulBy: 0.007), child: InkWell( onTap: (){ Provider.of<OnOff>(context, listen: false).offNotifications(); }, child: Container( height: screenHeight(context, mulBy: 0.025)+0.7, width: screenHeight(context, mulBy: 0.025)+0.7, decoration: BoxDecoration( border: Border.all(color: Theme.of(context).shadowColor, width: 1), borderRadius: BorderRadius.all(Radius.circular(10)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.1), spreadRadius: 5, blurRadius: 10, offset: Offset(0, 3), ), ], ), child: Container( height: screenHeight(context, mulBy: 0.025), width: screenHeight(context, mulBy: 0.025), decoration: BoxDecoration( shape: BoxShape.circle, border: Border.all( color: Colors.grey.withOpacity(0.9), width: themeNotifier.isDark()?0.7:0 ), ), child: ClipRRect( borderRadius: BorderRadius.circular(10), child: BackdropFilter( filter: ui.ImageFilter.blur(sigmaX: 30.0, sigmaY: 30.0), child: Container( height: screenHeight(context, mulBy: 0.025), width: screenHeight(context, mulBy: 0.025), decoration: BoxDecoration( color: Theme.of(context).focusColor, shape: BoxShape.circle, ), child: Icon( CupertinoIcons.clear, color: Theme.of(context).cardColor.withOpacity(.8), size: 10, ), ), ), ), ), ), ), ), ) ], ), ), ), ); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/components/desktopItems.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../providers.dart'; import '../sizes.dart'; import '../system/componentsOnOff.dart'; import '../system/folders/folders.dart'; class DesktopItem extends StatefulWidget { String? name; Offset? initPos; bool selected; late VoidCallback deSelectFolder; VoidCallback onDoubleTap; DesktopItem({Key? key, this.name, this.initPos, this.selected=false, required this.onDoubleTap}): super(key: key); @override _DesktopItemState createState() => _DesktopItemState(); } class _DesktopItemState extends State<DesktopItem> { Offset? position= Offset(135, 150); TextEditingController? controller; FocusNode _focusNode = FocusNode(); bool pan= false; bool bgVisible= false; @override void initState() { super.initState(); controller = new TextEditingController(text: widget.name, ); controller!.selection=TextSelection.fromPosition(TextPosition(offset: controller!.text.length)); position=widget.initPos; selectText(); widget.deSelectFolder= (){ if (!mounted) return; setState(() { widget.selected=false; //widget.name=controller.text.toString(); }); }; } void selectText(){ _focusNode.addListener(() { if(_focusNode.hasFocus) { controller!.selection = TextSelection(baseOffset: 0, extentOffset: controller!.text.length); } }); } @override Widget build(BuildContext context) { if(!pan) position=Offset(screenWidth(context, mulBy: widget.initPos!.dx),screenHeight(context, mulBy: widget.initPos!.dy)); return Container( height: screenHeight(context), width: screenWidth(context), child: Stack( children: [ Visibility( visible: bgVisible, child: Positioned( top: screenHeight(context, mulBy: widget.initPos!.dy), left: screenWidth(context, mulBy: widget.initPos!.dx), child: Container( width: screenWidth(context, mulBy: 0.08), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Container( height: screenHeight(context, mulBy: 0.1), padding: EdgeInsets.symmetric(horizontal: screenWidth(context,mulBy: 0.0005)), decoration: BoxDecoration( color: Colors.black.withOpacity(0.25), border: Border.all( color: Colors.grey.withOpacity(0.4), width: 2 ), borderRadius: BorderRadius.circular(4) ), child: Image.asset("assets/icons/server.png", height: screenHeight(context, mulBy: 0.085), width: screenWidth(context, mulBy: 0.045), ), ), SizedBox(height: screenHeight(context, mulBy: 0.005), ), Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( height: screenHeight(context, mulBy: 0.024), padding: EdgeInsets.symmetric(horizontal: screenWidth(context,mulBy: 0.005)), alignment: Alignment.center, decoration:BoxDecoration( color: Color(0xff0058d0), borderRadius: BorderRadius.circular(3) ), child: Text(widget.name??"", textAlign: TextAlign.center, style: TextStyle(color: Colors.white, fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 12,), maxLines: 1, overflow: TextOverflow.ellipsis, ), ), ], ) ], ), ), ), ), AnimatedPositioned( duration: Duration(milliseconds: pan?0:200), top: position!.dy, left: position!.dx, child: GestureDetector( onDoubleTap: (){ tapFunctions(context); if (!mounted) return; setState(() { widget.selected=true; }); widget.onDoubleTap(); }, onPanUpdate: (tapInfo){ if (!mounted) return; setState(() { position = Offset(position!.dx + tapInfo.delta.dx, position!.dy + tapInfo.delta.dy); }); }, onPanStart: (e){ tapFunctions(context); if (!mounted) return; setState(() { widget.selected=false; widget.name=controller!.text.toString(); pan=true; bgVisible=true; }); }, onPanEnd: (e){ if (!mounted) return; setState(() { pan=false; position=widget.initPos; }); Timer(Duration(milliseconds: 200), (){ if (!mounted) return; setState(() { bgVisible=false; widget.selected=true; });}); }, onTap: (){ tapFunctions(context); if (!mounted) return; setState(() { widget.selected=true; }); }, onSecondaryTap: (){ if (!mounted) return; setState(() { widget.selected=true; }); Provider.of<OnOff>(context, listen: false).onFRCM(); }, onSecondaryTapDown: (details){ tapFunctions(context); Provider.of<DataBus>(context, listen: false).setPos(details.globalPosition); }, child: Container( width: 122, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Container( height: 74.5, padding: EdgeInsets.symmetric(horizontal: screenWidth(context,mulBy: 0.0005)), decoration: (widget.selected)?BoxDecoration( color: Colors.black.withOpacity(0.25), border: Border.all( color: Colors.grey.withOpacity(0.4), width: 2 ), borderRadius: BorderRadius.circular(4) ):BoxDecoration( border: Border.all( color: Colors.grey.withOpacity(0.0), width: 2 ), ), child: Image.asset("assets/icons/server.png", height: 63.3, width: 69.12, ), ), SizedBox(height: screenHeight(context, mulBy: 0.005), ), Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( height: 18, padding: EdgeInsets.symmetric(horizontal: screenWidth(context,mulBy: 0.005)), alignment: Alignment.center, decoration: widget.selected?BoxDecoration( color: Color(0xff0058d0), borderRadius: BorderRadius.circular(3) ):BoxDecoration(), child: Text(widget.name??"", textAlign: TextAlign.center, style: TextStyle(color: Colors.white, fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 12,), maxLines: 1, overflow: TextOverflow.ellipsis, ), ), ], ) ], ), ), ), ), ], ), ); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/components/hoverDock.dart
import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'dart:html' as html; import 'package:mac_dt/sizes.dart'; class TranslateOnHover extends StatefulWidget { final Widget? child; // You can also pass the translation in here if you want to TranslateOnHover({Key? key, this.child}) : super(key: key); @override _TranslateOnHoverState createState() => _TranslateOnHoverState(); } class _TranslateOnHoverState extends State<TranslateOnHover> { final nonHoverTransform = Matrix4.identity()..translate(0, 0, 0); final hoverTransform = Matrix4.identity()..scale(1.2,1.2)..translate(-5, -25, 0, ); bool _hovering = false; @override Widget build(BuildContext context) { return MouseRegion( onEnter: (e) => _mouseEnter(true), onExit: (e) => _mouseEnter(false), child: AnimatedContainer( duration: const Duration(milliseconds: 140), child: widget.child, transform: _hovering ? hoverTransform: nonHoverTransform, ), ); } void _mouseEnter(bool hover) { setState(() { _hovering = hover; }); } } extension HoverExtensions on Widget { // Get a reference to the body of the view static final appContainer = html.window.document.getElementById("app-container"); Widget get showCursorOnHover { return MouseRegion( child: this, // When the mouse enters the widget set the cursor to pointer onHover: (event) { appContainer!.style.cursor = 'pointer'; }, // When it exits set it back to default onExit: (event) { appContainer!.style.cursor = 'default'; }, ); } Widget get moveUpOnHover { return TranslateOnHover( child: this, ); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/components/windowWidgets.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../sizes.dart'; import '../widgets.dart'; class LeftPaneItems extends StatefulWidget { bool isSelected; final String? iName; LeftPaneItems({ this.isSelected=false, this.iName, Key? key, }) : super(key: key); @override _LeftPaneItemsState createState() => _LeftPaneItemsState(); } class _LeftPaneItemsState extends State<LeftPaneItems> { bool hovering= false; @override Widget build(BuildContext context) { return MouseRegion( onEnter: (evnt){ setState(() { hovering=true; }); }, onExit: (evnt){ setState(() { hovering=false; }); }, child: Container( decoration: BoxDecoration( color: widget.isSelected?Colors.black.withOpacity(0.14): hovering ? Colors.black.withOpacity(0.14) : Colors.transparent , borderRadius: BorderRadius.all(Radius.circular(5))), alignment: Alignment.centerLeft, width: screenWidth(context,), padding: EdgeInsets.only(left: screenWidth(context,mulBy: 0.005)), height: screenHeight(context,mulBy: 0.038), child: Row( children: [ Image.asset("assets/icons/${widget.iName!.toLowerCase()}.png", height: 15), MBPText( text: " ${widget.iName}", color: Theme.of(context).cardColor.withOpacity(1), ), ], ), ), ); } }
0
mirrored_repositories/chrishub/lib/components
mirrored_repositories/chrishub/lib/components/wallpaper/wallpaper.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'wallpaper.dart'; // ************************************************************************** // TypeAdapterGenerator // ************************************************************************** class WallDataAdapter extends TypeAdapter<WallData> { @override final int typeId = 1; @override WallData read(BinaryReader reader) { final numOfFields = reader.readByte(); final fields = <int, dynamic>{ for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), }; return WallData( name: fields[0] as String, location: fields[1] as String, ); } @override void write(BinaryWriter writer, WallData obj) { writer ..writeByte(2) ..writeByte(0) ..write(obj.name) ..writeByte(1) ..write(obj.location); } @override int get hashCode => typeId.hashCode; @override bool operator ==(Object other) => identical(this, other) || other is WallDataAdapter && runtimeType == other.runtimeType && typeId == other.typeId; }
0
mirrored_repositories/chrishub/lib/components
mirrored_repositories/chrishub/lib/components/wallpaper/wallpaper.dart
import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import 'package:provider/provider.dart'; import '../../data/analytics.dart'; import '../../providers.dart'; import '../../theme/theme.dart'; part 'wallpaper.g.dart'; class Wallpaper extends StatefulWidget { const Wallpaper({Key? key}) : super(key: key); @override State<Wallpaper> createState() => _WallpaperState(); } class _WallpaperState extends State<Wallpaper> { late WallData wallpaper; List<WallData> wallData=[ WallData(name: "Big Sur Illustration", location: "assets/wallpapers/bigsur_.jpg"), WallData(name: "Big Sur", location: "assets/wallpapers/realbigsur_.jpg"), WallData(name: "Big Sur Valley", location: "assets/wallpapers/bigSurValley_.jpg"), WallData(name: "Iridescence", location: "assets/wallpapers/iridescence_.jpg"), WallData(name: "Big Sur Horizon", location: "assets/wallpapers/bigSurHorizon.jpg"), WallData(name: "Big Sur Mountains", location: "assets/wallpapers/bigSurMountains.jpg"), WallData(name: "Big Sur Road", location: "assets/wallpapers/bigSurRoad.jpg"), WallData(name: "Flutter Forward", location: "assets/wallpapers/flutterForward.jpg"), ]; @override Widget build(BuildContext context) { wallpaper=Provider.of<DataBus>(context, listen: true).getWallpaper; return Container( decoration: BoxDecoration( color: Theme.of(context).colorScheme.onError, borderRadius: BorderRadius.only( bottomRight: Radius.circular(15), bottomLeft: Radius.circular(15)), ), padding: EdgeInsets.only( left: 10, right: 10, top: 30, bottom: 10 ), child: Container( decoration: BoxDecoration( color: Theme.of(context) .colorScheme .errorContainer, borderRadius: BorderRadius.circular(10), border: Border.all( color: Colors.grey.withOpacity(0.5), width: 0.3 ) ), padding: EdgeInsets.only( bottom: 40, left: 20, right: 20, top: 10 ), child: Column( children: [ Container( width: 100, height: 30, alignment: Alignment.center, decoration: BoxDecoration( color: Theme.of(context).colorScheme.onError, borderRadius: BorderRadius.circular(20), border: Border.all( color: Colors.grey.withOpacity(0.5), width: 0.3 ) ), child: Text( "Desktop", style: TextStyle( fontSize: 14, color: Theme.of(context).cardColor.withOpacity(1), fontWeight: Theme.of(context) .textTheme .headline3! .fontWeight, fontFamily: "SF", ), ), ), SizedBox( height: 20, ), Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( width: 40, ), Container( padding: EdgeInsets.all(5), decoration: BoxDecoration( color: Colors.transparent, borderRadius: BorderRadius.circular(7), border: Border.all( color: Colors.grey.withOpacity(0.4), width: 1.2 ) ), height: 90, width: 130, child: ViewWallpaper(location: wallpaper.location,), ), SizedBox( width: 20, ), RichText( text: TextSpan( text: "\n${wallpaper.name}\n", children: [ TextSpan( text: wallpaper.location.contains("_")?"This desktop picture changes with your current theme.":"", style: TextStyle( fontSize: 11, fontWeight: FontWeight.w300, letterSpacing: .5 ) ) ], style: TextStyle( fontSize: 14, color: Theme.of(context).cardColor.withOpacity(1), fontWeight: Theme.of(context) .textTheme .headline3! .fontWeight, fontFamily: "SF", ), ), ) ], ), SizedBox( height: 20, ), Expanded( child: Container( decoration: BoxDecoration( color: Theme.of(context).colorScheme.onError, borderRadius: BorderRadius.circular(7), border: Border.all( color: Colors.grey.withOpacity(0.5), width: 0.3 ) ), child: GridView.builder( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 4, childAspectRatio: 1.6, mainAxisSpacing: 10, crossAxisSpacing: 10 ), padding: EdgeInsets.symmetric( vertical: 10, horizontal: 10 ), itemCount: wallData.length, itemBuilder: (context, index) { return InkWell( onTap: (){ Provider.of<DataBus>(context, listen: false) .setWallpaper(wallData[index],); Provider.of<AnalyticsService>(context, listen: false) .logWallPaper(wallData[index].name); }, child: Container( padding: EdgeInsets.all(1), decoration: BoxDecoration( color: Colors.transparent, borderRadius: BorderRadius.circular(7), border: Border.all( color: wallpaper.location==wallData[index].location?Colors.blueAccent:Colors.grey.withOpacity(0.4), width: 1.2 ) ), child: ViewWallpaper(location: wallData[index].location,), ), ); },), ), ), ], ), ), ); } } class ViewWallpaper extends StatelessWidget { const ViewWallpaper({Key? key, required this.location}) : super(key: key); final String location; @override Widget build(BuildContext context) { return Image.asset( location.contains("_") ? location.splitMapJoin("_", onMatch: (a){ return Provider.of<ThemeNotifier>(context).isDark()?"_dark":"_light"; }) :location, fit: BoxFit.cover, ); } } ///Declared as HiveObject for hive database @HiveType(typeId: 1) class WallData extends HiveObject { @HiveField(0,) final String name; @HiveField(1,) final String location; WallData({required this.name, required this.location}); }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/data/system_data.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'system_data.dart'; // ************************************************************************** // TypeAdapterGenerator // ************************************************************************** class SystemDataAdapter extends TypeAdapter<SystemData> { @override final int typeId = 0; @override SystemData read(BinaryReader reader) { final numOfFields = reader.readByte(); final fields = <int, dynamic>{ for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), }; return SystemData( wallpaper: fields[0] as WallData, dark: fields[1] as bool, ); } @override void write(BinaryWriter writer, SystemData obj) { writer ..writeByte(2) ..writeByte(0) ..write(obj.wallpaper) ..writeByte(1) ..write(obj.dark); } @override int get hashCode => typeId.hashCode; @override bool operator ==(Object other) => identical(this, other) || other is SystemDataAdapter && runtimeType == other.runtimeType && typeId == other.typeId; }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/data/system_data.dart
import 'package:hive/hive.dart'; import '../components/wallpaper/wallpaper.dart'; part 'system_data.g.dart'; @HiveType(typeId: 0) class SystemData extends HiveObject { SystemData({required this.wallpaper, required this.dark}); @HiveField(0,) WallData wallpaper; @HiveField(1, ) bool dark; }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/data/analytics.dart
import 'package:firebase_analytics/firebase_analytics.dart'; import 'package:firebase_analytics/observer.dart'; import 'package:flutter/foundation.dart'; class AnalyticsService extends ChangeNotifier{ FirebaseAnalytics analytics = FirebaseAnalytics.instance; FirebaseAnalyticsObserver getAnalyticsObserver() => FirebaseAnalyticsObserver(analytics: analytics); Future<void> setCurrentScreen(String screen) async { print('Setting current screen to $screen'); await analytics.setCurrentScreen( screenName: screen, ); } Future<void> logCurrentScreen(String screen) async { print('Setting current screen to $screen'); await analytics.setCurrentScreen( screenName: screen, ); await analytics.logScreenView( screenName: screen, ); } Future<void> logSearch(String search) async { await FirebaseAnalytics.instance.logEvent( name: "safariSearch", parameters: { "search": search, }, ); } Future<void> logFolder(String name) async { await FirebaseAnalytics.instance.logEvent( name: "folderName", parameters: { "name": name, }, ); } Future<void> logTerminal(String search) async { await FirebaseAnalytics.instance.logEvent( name: "terminalCommand", parameters: { "command": search, }, ); } Future<void> logWallPaper(String search) async { await FirebaseAnalytics.instance.logEvent( name: "wallpaperChanged", parameters: { "wallpaper": search, }, ); } // User properties tells us what the user is Future setUserProperties({ required String value, required String name}) async { await analytics.setUserProperty(name: name, value: value); } Future setUserId({required String userId,}) async { await analytics.setUserId(id: userId); } Future logLogin(String method) async { await analytics.logLogin(loginMethod: method); } Future logSignUp(String method) async { await analytics.logSignUp(signUpMethod: method); } Future logOpened(String a) async { await analytics.logEvent( name: "appOpened", parameters: {'app': a,}, ); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/data/system_data_CRUD.dart
import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import 'package:mac_dt/components/wallpaper/wallpaper.dart'; import 'package:mac_dt/data/system_data.dart'; import 'package:mac_dt/theme/theme.dart'; class SystemDataCRUD{ static Box<SystemData> getSystemData() => Hive.box<SystemData>('systemData'); ///Gets data from local database. If the database is empty(i.e being run the first time), ///then defaultValue is used. static WallData getWallpaper(){ final box= getSystemData(); SystemData? systemData= box.get( 'systemData', defaultValue: SystemData( dark: true, wallpaper: WallData(name: "Big Sur Illustration", location: "assets/wallpapers/bigsur_.jpg") ) ); return systemData!.wallpaper; } ///Sets data to local database. If the database is empty(i.e being run the first time), ///then defaultValue is used. The change is being made to the value and is saved again. ///WallData had to be registered as Adapter to this to work. static setWallpaper(WallData? wallData){ final box= getSystemData(); SystemData? systemData= box.get( 'systemData', defaultValue: SystemData( dark: true, wallpaper: WallData(name: "Big Sur Illustration", location: "assets/wallpapers/bigsur_.jpg") ) ); systemData!.wallpaper= wallData!; systemData.save(); } ///Gets data from local database. If the database is empty(i.e being run the first time), ///then defaultValue is used. static ThemeData getTheme(){ final box= getSystemData(); SystemData? systemData= box.get( 'systemData', defaultValue: SystemData( dark: true, wallpaper: WallData(name: "Big Sur Illustration", location: "assets/wallpapers/bigsur_.jpg") ) ); if(systemData!.dark) return ThemeNotifier.darkTheme; else return ThemeNotifier.lightTheme; } ///Sets data to local database. If the database is empty(i.e being run the first time), ///then defaultValue is used. The change is being made to the value and is saved again. static setTheme(ThemeData themeData){ final box= getSystemData(); SystemData? systemData= box.get( 'systemData', defaultValue: SystemData( dark: true, wallpaper: WallData(name: "Big Sur Illustration", location: "assets/wallpapers/bigsur_.jpg") ) ); if(themeData==ThemeNotifier.darkTheme) systemData!.dark= true; else systemData!.dark= false; systemData.save(); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/theme/theme.dart
import 'package:flutter/material.dart'; import 'package:mac_dt/data/system_data_CRUD.dart'; class ThemeNotifier with ChangeNotifier { static final ThemeData lightTheme = ThemeData( textTheme: TextTheme( headline4: TextStyle( fontWeight: FontWeight.w600, fontSize: 12, ), headline1: TextStyle( fontWeight: FontWeight.w700, fontSize: 15, ), headline3: TextStyle( fontWeight: FontWeight.w600, ),//iMessage info name headline2: TextStyle( //calendar heading fontWeight: FontWeight.w400, fontSize: 15, ) ), fontFamily: "SF", primarySwatch: Colors.blueGrey, indicatorColor: Colors.white, //Calendar bg color shadowColor: Colors.black.withOpacity(0.15), //Control Center outer border accentColor: Colors.black.withOpacity(.15), //shadow color backgroundColor: Colors.white.withOpacity(0.15), //Control Center cardColor: Colors.black.withOpacity(0.0), //Control Center item border, font color splashColor: Colors.black.withOpacity(0.2), //Control Center border focusColor: Colors.white.withOpacity(0.4), //docker color canvasColor: Colors.blue.withOpacity(0.4), //fileMenu Color scaffoldBackgroundColor: Colors.white, //window Color hintColor: Colors.white.withOpacity(0.6), //window transparency Color dividerColor: Colors.white, // Safari Window color dialogBackgroundColor: Colors.white, //feedback body color disabledColor: Colors.white, //terminal top color errorColor: Colors.white.withOpacity(0.3), //iMessages color hoverColor: Colors.white.withOpacity(0.4), // RCM color highlightColor:Colors.black.withOpacity(.13),//darkMode button bottomAppBarColor: Colors.black.withOpacity(0.1), //CC Music Color selectedRowColor: Color(0xffffffff).withOpacity(0.5), colorScheme: ColorScheme.fromSwatch().copyWith( secondary: Color(0xffbfbfbf), //feedback light color background: Color(0xff898989), //feedback dark color error: Color(0xffcecece), //feedback textbox fill primary: Color(0xff232220), onError: Colors.white, //system Pref 1 errorContainer: Color(0xffe9e9e7), //system Pref 2 inversePrimary: Color(0xff80807e), //system Pref 2 text color ), primaryTextTheme: TextTheme( button: TextStyle( color: Colors.blueGrey, decorationColor: Colors.blueGrey[300], ), subtitle1: TextStyle( color: Colors.black, ), ), iconTheme: IconThemeData(color: Colors.blueGrey), ); static final ThemeData darkTheme = ThemeData( textTheme: TextTheme( headline4: TextStyle( fontWeight: FontWeight.w400, fontSize: 12, fontFamily: "SF" ), ///iMessage info name headline3: TextStyle( fontWeight: FontWeight.w500, ), headline1: TextStyle( fontWeight: FontWeight.w600, fontSize: 15, ), ///calendar heading headline2: TextStyle( fontWeight: FontWeight.w300, fontSize: 15, ) ), fontFamily: "SF", primarySwatch: Colors.deepOrange, backgroundColor: Color(0xff2b2b2b).withOpacity(.05), //Control Center cardColor: Colors.white.withOpacity(0.15), //Control Center item border, font color indicatorColor: Colors.black, //Calendar bg color, ipad messages left color splashColor: Colors.black.withOpacity(0.4), //Control Center border shadowColor: Colors.black.withOpacity(0.3), //Control Center outer border accentColor: Colors.black.withOpacity(.2), //shadow color focusColor: Color(0xff393232).withOpacity(0.2), //docker color canvasColor: Colors.black.withOpacity(0.3), //fileMenu Color scaffoldBackgroundColor: Color(0xff242127), //Finder window Color dividerColor: Color(0xff3a383e), // Window top color hintColor: Color(0xff242127).withOpacity(0.3), //window transparency Color dialogBackgroundColor: Color(0xff1e1f23), //feedback body color disabledColor: Color(0xff39373b), //terminal top color errorColor: Color(0xff1e1e1e).withOpacity(0.4), //iMessages color, Fill color hoverColor: Color(0xff110f0f).withOpacity(0.4), // RCM color bottomAppBarColor: Colors.white.withOpacity(0.3), //CC Music Color selectedRowColor: Color(0xff111111).withOpacity(0.7), colorScheme: ColorScheme.fromSwatch().copyWith( secondary: Color(0xff3b3b3b), //feedback light color background: Color(0xff2f2f2f), //feedback dark color error: Color(0xff2f2e32), //feedback textbox fill primary: Color(0xff232220), onError: Color(0xff1f1e1d), //system Pref 1 errorContainer: Color(0xff272624), //system Pref 2 ///Color(0xffe9e9e7) inversePrimary: Colors.grey, //system Pref 2 text color ///Color(0xff80807e) ), primaryTextTheme: TextTheme( button: TextStyle( color: Colors.blueGrey[200], decorationColor: Colors.blueGrey[50], ), subtitle1: TextStyle( color: Colors.blueGrey[300], ), ), iconTheme: IconThemeData(color: Colors.blueGrey[200]), highlightColor: Colors.white, //darkMode button ); ThemeData _themeData; ThemeNotifier(this._themeData); getTheme() => _themeData; isDark() => _themeData==lightTheme?false:true; setTheme(ThemeData themeData) async { _themeData = themeData; SystemDataCRUD.setTheme(themeData); notifyListeners(); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/apps/launchpad.dart
import 'dart:ui'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:mac_dt/apps/systemPreferences.dart'; import 'package:mac_dt/components/finderWindow.dart'; import 'package:mac_dt/theme/theme.dart'; import 'package:mac_dt/widgets.dart'; import 'package:provider/provider.dart'; import '../components/wallpaper/wallpaper.dart'; import '../data/analytics.dart'; import '../system/componentsOnOff.dart'; import '../system/openApps.dart'; import '../providers.dart'; import '../sizes.dart'; import 'about.dart'; import 'calendar.dart'; import 'feedback/feedback.dart'; import 'messages/messages.dart'; import 'safari/safariWindow.dart'; import 'spotify.dart'; import 'terminal/terminal.dart'; import 'vscode.dart'; import 'dart:html' as html; //TODO Has overflowing error when window is too small class LaunchPad extends StatefulWidget { const LaunchPad({Key? key}) : super(key: key); @override _LaunchPadState createState() => _LaunchPadState(); } class _LaunchPadState extends State<LaunchPad> { late DateTime now; @override void initState() { now = DateTime.now(); super.initState(); } @override Widget build(BuildContext context) { bool launchPadOpen= Provider.of<OnOff>(context).getLaunchPad; return IgnorePointer( ignoring: !launchPadOpen, child: AnimatedOpacity( duration: Duration(milliseconds: 150), opacity: launchPadOpen?1:0, curve: Curves.easeInOut, child: Stack( children: [ ViewWallpaper(location: Provider.of<DataBus>(context, listen: true).getWallpaper.location,), ClipRect( child: BackdropFilter( filter: ImageFilter.blur(sigmaX: 23.0, sigmaY: 23.0), child: InkWell( mouseCursor: MouseCursor.defer, onTap: (){ Provider.of<OnOff>(context, listen: false).offLaunchPad(); }, child: Container( height: screenHeight(context), width: screenWidth(context), padding: EdgeInsets.only( left: screenWidth(context, mulBy: 0.12), right: screenWidth(context, mulBy: 0.12), bottom: screenHeight(context, mulBy: 0.17), top: screenHeight(context, mulBy: 0.06) ), color: Colors.black.withOpacity(0.15), child: AnimatedScale( duration: Duration(milliseconds: 150), scale: launchPadOpen?1:1.1, child: Column( children: [ Container( height: screenHeight(context, mulBy: 0.035), width: screenWidth(context, mulBy: 0.17), decoration: BoxDecoration( color: Colors.white.withOpacity(0.05), borderRadius: BorderRadius.circular(5), border: Border.all( color: Colors.white.withOpacity(0.2) ) ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.search, size: 14, color: Colors.white.withOpacity(0.7), ), SizedBox( width: screenWidth(context, mulBy: 0.0035), ), MBPText( text: "Search", color: Colors.white.withOpacity(0.3), weight: FontWeight.w200, ) ], ), ), Spacer(flex: 1,), GridView( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 6, childAspectRatio: 6/2.5, mainAxisSpacing: screenHeight(context, mulBy: 0.05) ), shrinkWrap: true, physics: BouncingScrollPhysics(), children: [ LaunchPadItem( iName: "Finder", onTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false) .maxFinder(); Provider.of<Apps>(context, listen: false).openApp( Finder( key: ObjectKey("finder"), initPos: Offset( screenWidth(context, mulBy: 0.2), screenHeight(context, mulBy: 0.18))), Provider.of<OnOff>(context, listen: false) .maxFinder() ); }); }, ), LaunchPadItem( iName: "About Me", onTap: () { tapFunctions(context); Provider.of<OnOff>(context, listen: false) .maxAbout(); Provider.of<Apps>(context, listen: false).openApp( About( key: ObjectKey("about"), initPos: Offset( screenWidth(context, mulBy: 0.2), screenHeight(context, mulBy: 0.12))), Provider.of<OnOff>(context, listen: false) .maxAbout() ); }, ), LaunchPadItem( iName: "Safari", onTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false) .maxSafari(); Provider.of<Apps>(context, listen: false).openApp( Safari( key: ObjectKey("safari"), initPos: Offset( screenWidth(context, mulBy: 0.14), screenHeight(context, mulBy: 0.1))), Provider.of<OnOff>(context, listen: false) .maxSafari() ); }); }, ), LaunchPadItem( iName: "Messages", onTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false) .maxMessages(); Provider.of<Apps>(context, listen: false).openApp( Messages( key: ObjectKey("messages"), initPos: Offset( screenWidth(context, mulBy: 0.27), screenHeight(context, mulBy: 0.2))), Provider.of<OnOff>(context, listen: false) .maxMessages() ); }); }, ), LaunchPadItem( iName: "Maps", onTap: (){ Provider.of<DataBus>(context, listen: false).setNotification( "App has not been installed. Create the app on GitHub.", "https://github.com/chrisbinsunny", "maps", "Not installed" ); Provider.of<OnOff>(context, listen: false).onNotifications(); }, ), LaunchPadItem( iName: "Spotify", onTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false) .maxSpotify(); Provider.of<Apps>(context, listen: false).openApp( Spotify( key: ObjectKey("spotify"), initPos: Offset( screenWidth(context, mulBy: 0.24), screenHeight(context, mulBy: 0.15) )), Provider.of<OnOff>(context, listen: false) .maxSpotify() ); }); }, ), LaunchPadItem( iName: "Terminal", onTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false) .maxTerminal(); Provider.of<Apps>(context, listen: false).openApp( Terminal( key: ObjectKey("terminal"), initPos: Offset( screenWidth(context, mulBy: 0.28), screenHeight(context, mulBy: 0.2))), Provider.of<OnOff>(context, listen: false) .maxTerminal() ); }); }, ), LaunchPadItem( iName: "Visual Studio Code", onTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false).maxVS(); Provider.of<Apps>(context, listen: false).openApp( VSCode( key: ObjectKey("vscode"), initPos: Offset( screenWidth(context, mulBy: 0.24), screenHeight(context, mulBy: 0.15))), Provider.of<OnOff>(context, listen: false).maxVS() ); }); }, ), LaunchPadItem( iName: "Photos", onTap: (){ Provider.of<DataBus>(context, listen: false).setNotification( "App has not been installed. Create the app on GitHub.", "https://github.com/chrisbinsunny", "photos", "Not installed" ); Provider.of<OnOff>(context, listen: false).onNotifications(); }, ), LaunchPadItem( iName: "Contacts", onTap: (){ Provider.of<DataBus>(context, listen: false).setNotification( "App has not been installed. Create the app on GitHub.", "https://github.com/chrisbinsunny", "contacts", "Not installed" ); Provider.of<OnOff>(context, listen: false).onNotifications(); }, ), InkWell( onTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false) .maxCalendar(); Provider.of<Apps>(context, listen: false).openApp( Calendar( key: ObjectKey("calendar"), initPos: Offset( screenWidth(context, mulBy: 0.24), screenHeight(context, mulBy: 0.15) ) ), Provider.of<OnOff>(context, listen: false) .maxCalendar() ); }); }, child: Column( children: [ Expanded( ///For setting the Text on the icon on position. Done by getting relative position. child: LayoutBuilder(builder: (context, cont) { return Stack( alignment: Alignment.topCenter, children: [ Image.asset( "assets/apps/calendar.png", ), Positioned( top: cont.smallest.height * .13, child: Container( height: cont.maxHeight*0.23, width: screenWidth(context, mulBy: 0.03), //color: Colors.green, child: FittedBox( fit: BoxFit.fitHeight, child: Text( "${DateFormat('LLL').format(now).toUpperCase()}", textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontFamily: "SF", fontWeight: FontWeight.w500, fontSize: 11, ), ), ), ), ), Positioned( top: cont.smallest.height * .35, child: Container( height: cont.maxHeight*0.5, width: screenWidth(context, mulBy: 0.03), //color:Colors.green, child: FittedBox( fit: BoxFit.fitHeight, child: Text( "${DateFormat('d').format(now).toUpperCase()}", style: TextStyle( color: Colors.black87 .withOpacity(0.8), fontFamily: 'SF', fontWeight: FontWeight.w400, fontSize: 28), ), ), ), ), ], ); },), ), MBPText( text: "Calendar", color: Colors.white ) ], ), ), LaunchPadItem( iName: "Notes", onTap: (){ Provider.of<DataBus>(context, listen: false).setNotification( "App has not been installed. Create the app on GitHub.", "https://github.com/chrisbinsunny", "notes", "Not installed" ); Provider.of<OnOff>(context, listen: false).onNotifications(); }, ), LaunchPadItem( iName: "Feedback", onTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false) .maxFeedBack(); Provider.of<Apps>(context, listen: false).openApp( FeedBack( key: ObjectKey("feedback"), initPos: Offset( screenWidth(context, mulBy: 0.2), screenHeight(context, mulBy: 0.12))), Provider.of<OnOff>(context, listen: false) .maxFeedBack() ); }); }, ), LaunchPadItem( iName: "System Preferences", onTap: () { tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false) .maxSysPref(); Provider.of<Apps>(context, listen: false).openApp( SystemPreferences( key: ObjectKey("systemPreferences"), initPos: Offset( screenWidth(context, mulBy: 0.27), screenHeight(context, mulBy: 0.13))), Provider.of<OnOff>(context, listen: false) .maxSysPref() ); }); }, ), ], ), Spacer(flex: 3,), Container( height: 8, width: 8, decoration: BoxDecoration( color: Colors.white, shape: BoxShape.circle, ), ), ], ), ), ), ), ), ), ], ), ), ); } } class LaunchPadItem extends StatefulWidget { final String iName; VoidCallback? onTap; VoidCallback? onDoubleTap; final bool folder; LaunchPadItem({ Key? key, required this.iName, this.onTap=null, this.onDoubleTap=null, this.folder=false, }) : super(key: key); @override _LaunchPadItemState createState() => _LaunchPadItemState(); } class _LaunchPadItemState extends State<LaunchPadItem> { @override Widget build(BuildContext context) { return InkWell( onTap: widget.onTap, onDoubleTap: widget.onDoubleTap, child: Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ Expanded( child: Image.asset( "assets/apps/${widget.iName.toLowerCase()}.png", // fit: BoxFit.contain, ), ), MBPText( text: widget.iName, color: widget.folder?Theme.of(context).cardColor.withOpacity(1):Colors.white ), ], ), ); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/apps/vscode.dart
import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:mac_dt/system/componentsOnOff.dart'; import 'package:mac_dt/theme/theme.dart'; import 'package:provider/provider.dart'; import '../data/analytics.dart'; import '../system/openApps.dart'; import '../sizes.dart'; import '../widgets.dart'; import 'dart:html' as html; import 'dart:ui' as ui; class VSCode extends StatefulWidget { final Offset? initPos; const VSCode({this.initPos, Key? key}) : super(key: key); @override _VSCodeState createState() => _VSCodeState(); } class _VSCodeState extends State<VSCode> { Offset? position = Offset(0.0, 0.0); late bool vsFS; late bool vsPan; final html.IFrameElement _iframeElementURL = html.IFrameElement(); @override void initState() { position = widget.initPos; super.initState(); _iframeElementURL.src = 'https://github1s.com/chrisbinsunny/chrishub'; _iframeElementURL.style.border = 'none'; _iframeElementURL.allow = "autoplay"; _iframeElementURL.allowFullscreen = true; ui.platformViewRegistry.registerViewFactory( 'vsIframe', (int viewId) => _iframeElementURL, ); Provider.of<AnalyticsService>(context, listen: false) .logCurrentScreen("VS Code"); } @override Widget build(BuildContext context) { var vsOpen = Provider.of<OnOff>(context).getVS; vsFS = Provider.of<OnOff>(context).getVSFS; vsPan = Provider.of<OnOff>(context).getVSPan; return vsOpen ? AnimatedPositioned( duration: Duration(milliseconds: vsPan ? 0 : 200), top: vsFS ? 25 : position!.dy, left: vsFS ? 0 : position!.dx, child: vsWindow(context), ) : Nothing(); } AnimatedContainer vsWindow(BuildContext context) { String topApp = Provider.of<Apps>(context).getTop; return AnimatedContainer( duration: Duration(milliseconds: 200), width: vsFS ? screenWidth(context, mulBy: 1) : screenWidth(context, mulBy: 0.55), height: vsFS ? screenHeight(context, mulBy: 0.975):screenHeight(context, mulBy: 0.7), decoration: BoxDecoration( border: Border.all( color: Colors.white.withOpacity(0.2), ), borderRadius: BorderRadius.all(Radius.circular(10)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), spreadRadius: 10, blurRadius: 15, offset: Offset(0, 8), // changes position of shadow ), ], ), child: Stack( children: [ Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Stack( alignment: Alignment.centerRight, children: [ Container( height: vsFS ? screenHeight(context, mulBy: 0.056) : screenHeight(context, mulBy: 0.053), decoration: BoxDecoration( color: Color(0xff252526), borderRadius: BorderRadius.only( topRight: Radius.circular(10), topLeft: Radius.circular(10))), ), GestureDetector( onPanUpdate: (tapInfo) { if (!vsFS) { setState(() { position = Offset(position!.dx + tapInfo.delta.dx, position!.dy + tapInfo.delta.dy); }); } }, onPanStart: (details) { Provider.of<OnOff>(context, listen: false).onVSPan(); }, onPanEnd: (details) { Provider.of<OnOff>(context, listen: false).offVSPan(); }, onDoubleTap: () { Provider.of<OnOff>(context, listen: false).toggleVSFS(); }, child: Container( alignment: Alignment.topRight, width: vsFS ? screenWidth(context, mulBy: 0.95) : screenWidth(context, mulBy: 0.7), height: vsFS ? screenHeight(context, mulBy: 0.056) : screenHeight(context, mulBy: 0.053), decoration: BoxDecoration( color: Colors.transparent, border: Border( bottom: BorderSide( color: Colors.black.withOpacity(0.5), width: 0.8))), ), ), Container( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.013), vertical: screenHeight(context, mulBy: 0.01)), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Row( children: [ InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.redAccent, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<Apps>(context, listen: false).closeApp("vscode"); Provider.of<OnOff>(context, listen: false) .offVSFS(); Provider.of<OnOff>(context, listen: false).toggleVS(); }, ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( onTap: (){ Provider.of<OnOff>(context, listen: false).toggleVS(); Provider.of<OnOff>(context, listen: false).offVSFS(); }, child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.amber, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.green, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<OnOff>(context, listen: false) .toggleVSFS(); }, ) ], ), ], ), ), ], ), Expanded( child: ClipRRect( borderRadius: BorderRadius.only( bottomRight: Radius.circular(10), bottomLeft: Radius.circular(10)), child: BackdropFilter( filter: ui.ImageFilter.blur(sigmaX: 30.0, sigmaY: 30.0), child: Container( height: screenHeight(context, mulBy: 0.14), width: screenWidth( context, ), decoration: BoxDecoration( color: Color(0xff1e1e1e).withOpacity(0.9), ), child: HtmlElementView( viewType: 'vsIframe', ), ), ), ), ), ], ), Visibility( visible: topApp != "VS Code", child: InkWell( onTap: (){ Provider.of<Apps>(context, listen: false) .bringToTop(ObjectKey("vscode")); }, child: Container( width: screenWidth(context,), height: screenHeight(context,), color: Colors.transparent, ), ), ), ], ), ); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/apps/about.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:intl/intl.dart'; import 'package:mac_dt/data/analytics.dart'; import 'package:mac_dt/system/componentsOnOff.dart'; import 'package:mac_dt/theme/theme.dart'; import 'package:provider/provider.dart'; import '../../system/openApps.dart'; import '../../sizes.dart'; import '../../widgets.dart'; import 'dart:html' as html; import 'dart:ui' as ui; class About extends StatefulWidget { final Offset? initPos; const About({this.initPos, Key? key}) : super(key: key); @override _AboutState createState() => _AboutState(); } class _AboutState extends State<About> { Offset? position = Offset(0.0, 0.0); late bool aboutFS; late bool aboutPan; late bool aboutOpen; String selected = "About"; final html.IFrameElement _iframeElementURL = html.IFrameElement(); @override void initState() { position = widget.initPos; super.initState(); _iframeElementURL.src = 'https://drive.google.com/file/d/1cuIQHOhjvZfM_M74HjsICNpuzvMO0uKX/preview'; _iframeElementURL.style.border = 'none'; _iframeElementURL.allow = "autoplay; encrypted-media;"; _iframeElementURL.allowFullscreen = true; ui.platformViewRegistry.registerViewFactory( 'resumeIframe', (int viewId) => _iframeElementURL, ); Provider.of<AnalyticsService>(context, listen: false) .logCurrentScreen("About me"); } getContent(){ switch(selected){ case "About": return Container( alignment: Alignment.topCenter, child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.start, children: [ SizedBox( height: screenHeight(context, mulBy: 0.02), ), Container( child: Image.asset( "assets/sysPref/chrisbin.jpg", fit: BoxFit.cover, ), clipBehavior: Clip.antiAlias, decoration: BoxDecoration(shape: BoxShape.circle), height: 120, width: 120, ), SizedBox( height: screenHeight(context, mulBy: 0.02), ), RichText( text: TextSpan( text: "Hey, I am ", children: [ TextSpan( text: "Chrisbin Sunny,\n", style: TextStyle( color: Color(0xff118bff), ) ), TextSpan( text: "App Developer from India 🇮🇳", style: TextStyle( fontSize: 19, fontWeight: FontWeight.w400, ) ) ], style: TextStyle( fontSize: 25, color: Theme.of(context) .cardColor .withOpacity(1), fontWeight: FontWeight.w600, letterSpacing: 1 ) ), textAlign: TextAlign.center, ), SizedBox( height: screenHeight(context, mulBy: 0.03), ), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "🏠 ", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), Expanded( child: Text( "I am a CS Engineering graduate from SJCET, Palai. I now work as a freelance" " App Developer. ", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), ), ], ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "👨‍💻 ", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), Expanded( child: Text( "I mostly use Flutter for building all kinds of projects. " "Currently, I am trying to bring more out of Flutter Web.", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), ), ], ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "🏅 ", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), Expanded( child: Text( "I have conducted several sessions and hands-on workshops at colleges." "All the sessions was on Flutter.", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), ), ], ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "🎯 ", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), Expanded( child: Text( "Programming was always my area of interest since teenage.Currently on a mission to make clean" "app UI/UX", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), ), ], ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "📲 ", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), Expanded( child: Text( "Feel free to email me at [email protected]", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), ), ], ), ], ), ), ); break; case "Education": return Container( alignment: Alignment.topCenter, child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.start, children: [ SizedBox( height: screenHeight(context, mulBy: 0.02), ), Text( "Education", style: TextStyle( fontSize: 25, color: Theme.of(context) .cardColor .withOpacity(1), fontWeight: FontWeight.w600, letterSpacing: 1 ) ), SizedBox( height: screenHeight(context, mulBy: 0.03), ), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "🧿 ", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), Expanded( child: RichText( text: TextSpan( text: "2018-2021\n", children: [ TextSpan( text: "St. Joesph's College of Engineering & Technology, Palai\n", style: TextStyle( color: Color(0xff118bff), ), ), TextSpan( text: "Btech\nComputer Science and Engineering", style: TextStyle( color: Colors.grey, fontWeight: FontWeight.w500, fontSize: 16 ), ) ], style: TextStyle( fontSize: 17, fontFamily: "HN", fontWeight: FontWeight.w700, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), ), ), ], ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "🧿 ", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), Expanded( child: RichText( text: TextSpan( text: "2017-2018\n", children: [ TextSpan( text: "Believer's Church Caarmel Engineering College\n", style: TextStyle( color: Color(0xff118bff), ), ), TextSpan( text: "Btech\nComputer Science and Engineering", style: TextStyle( color: Colors.grey, fontWeight: FontWeight.w500, fontSize: 16 ), ) ], style: TextStyle( fontSize: 17, fontFamily: "HN", fontWeight: FontWeight.w700, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), ), ), ], ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "🧿 ", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), Expanded( child: RichText( text: TextSpan( text: "2015-2017\n", children: [ TextSpan( text: "Holy Cross Vidya Sadan, Thellakom\n", style: TextStyle( color: Color(0xff118bff), ), ), TextSpan( text: "AISSCE\nComputer Science", style: TextStyle( color: Colors.grey, fontWeight: FontWeight.w500, fontSize: 16 ), ) ], style: TextStyle( fontSize: 17, fontFamily: "HN", fontWeight: FontWeight.w700, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), ), ), ], ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "🧿 ", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), Expanded( child: RichText( text: TextSpan( text: "2005-2015\n", children: [ TextSpan( text: "Holy Cross Vidya Sadan, Thellakom\n", style: TextStyle( color: Color(0xff118bff), ), ), TextSpan( text: "AISSE", style: TextStyle( color: Colors.grey, fontWeight: FontWeight.w500, fontSize: 16 ), ) ], style: TextStyle( fontSize: 17, fontWeight: FontWeight.w700, fontFamily: "HN", color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), ), ), ], ), ], ), ), ); break; case "Skills": return Container( alignment: Alignment.topCenter, child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ SizedBox( height: screenHeight(context, mulBy: 0.02), ), Text( "Languages & Tools", style: TextStyle( fontSize: 25, color: Theme.of(context) .cardColor .withOpacity(1), fontWeight: FontWeight.w600, letterSpacing: 1 ) ), SizedBox( height: screenHeight(context, mulBy: 0.03), ), Text( "🧿 GoLang", style: TextStyle( fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 16, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Text( "🧿 Dart", style: TextStyle( fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 16, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Text( "🧿 Python", style: TextStyle( fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 16, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Text( "🧿 C", style: TextStyle( fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 16, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Text( "🧿 HTML5", style: TextStyle( fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 16, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Text( "🧿 Firebase", style: TextStyle( fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 16, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Text( "🧿 Git", style: TextStyle( fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 16, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), ], ), ), ), Expanded( child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ SizedBox( height: screenHeight(context, mulBy: 0.02), ), Text( "Frameworks & others", style: TextStyle( fontSize: 25, color: Theme.of(context) .cardColor .withOpacity(1), fontWeight: FontWeight.w600, letterSpacing: 1 ) ), SizedBox( height: screenHeight(context, mulBy: 0.03), ), Text( "🧿 Flutter", style: TextStyle( fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 16, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Text( "🧿 Photoshop", style: TextStyle( fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 16, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Text( "🧿 DialogFlow", style: TextStyle( fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 16, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Text( "🧿 Gaming", style: TextStyle( fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 16, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Text( "🧿 Premiere Pro", style: TextStyle( fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 16, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Text( "🧿 After Effwcts", style: TextStyle( fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 16, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), ], ), ), ), ], ), ); break; case "Projects": return Container( alignment: Alignment.topCenter, child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.start, children: [ SizedBox( height: screenHeight(context, mulBy: 0.02), ), Text( "Open Projects", style: TextStyle( fontSize: 25, color: Theme.of(context) .cardColor .withOpacity(1), fontWeight: FontWeight.w600, letterSpacing: 1 ) ), SizedBox( height: screenHeight(context, mulBy: 0.04), ), InkWell( onTap: (){ html.window.open('https://chrisbinsunny.github.io/chrishub', 'new tab'); }, child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "👨‍💻 ", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), Expanded( child: RichText( text: TextSpan( text: "Chrisbin's Macbook Pro\n", children: [ TextSpan( text: "chrisbinsunny.github.io/chrishub\n", style: TextStyle( color: Color(0xff118bff), fontWeight: FontWeight.w500, fontSize: 15 ), ), TextSpan( text: "A portfolio website created as a web Simulation of macOS Big Sur." " The idea is to provide a glimpse at my personal system.", style: TextStyle( color: Colors.grey, fontWeight: FontWeight.w500, fontSize: 13 ), ) ], style: TextStyle( fontSize: 17, fontFamily: "HN", fontWeight: FontWeight.w700, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), ), ), ], ), ), SizedBox( height: screenHeight(context, mulBy: 0.025), ), InkWell( onTap: (){ html.window.open('https://chrisbinsunny.github.io/dream', 'new tab'); }, child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "👨‍💻 ", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), Expanded( child: RichText( text: TextSpan( text: "DREAM\n", children: [ TextSpan( text: "chrisbinsunny.github.io/dream\n", style: TextStyle( color: Color(0xff118bff), fontWeight: FontWeight.w500, fontSize: 15 ), ), TextSpan( text: "A utility website used to find " "colours from images and screenshots. " "There’s also a gradient builder to build" " beautiful background for websites.", style: TextStyle( color: Colors.grey, fontWeight: FontWeight.w500, fontSize: 13 ), ) ], style: TextStyle( fontSize: 17, fontFamily: "HN", fontWeight: FontWeight.w700, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), ), ), ], ), ), SizedBox( height: screenHeight(context, mulBy: 0.025), ), InkWell( onTap: (){ html.window.open('https://chrisbinsunny.github.io/Flutter-Talks', 'new tab'); }, child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "👨‍💻 ", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), Expanded( child: RichText( text: TextSpan( text: "Flutter Talks\n", children: [ TextSpan( text: "chrisbinsunny.github.io/Flutter-Talks\n", style: TextStyle( color: Color(0xff118bff), fontWeight: FontWeight.w500, fontSize: 15 ), ), TextSpan( text: "The project is basically a Flutter intro " " slideshow presentation used in workshops.", style: TextStyle( color: Colors.grey, fontWeight: FontWeight.w500, fontSize: 13 ), ) ], style: TextStyle( fontSize: 17, fontFamily: "HN", fontWeight: FontWeight.w700, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), ), ), ], ), ), SizedBox( height: screenHeight(context, mulBy: 0.025), ), InkWell( onTap: (){ html.window.open('https://chrisbinsunny.github.io', 'new tab'); }, child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "👨‍💻 ", style: TextStyle( fontSize: 15, color: Theme.of(context) .cardColor .withOpacity(1), ), ), Expanded( child: RichText( text: TextSpan( text: "Old Portfolio\n", children: [ TextSpan( text: "chrisbinsunny.github.io\n", style: TextStyle( color: Color(0xff118bff), fontWeight: FontWeight.w500, fontSize: 15 ), ), TextSpan( text: "The portfolio website while I was a real noob.", style: TextStyle( color: Colors.grey, fontWeight: FontWeight.w500, fontSize: 13 ), ) ], style: TextStyle( fontSize: 17, fontFamily: "HN", fontWeight: FontWeight.w700, color: Theme.of(context) .cardColor .withOpacity(1), letterSpacing: 1 ), ), ), ), ], ), ), ], ), ), ); break; case "Resume": //html.window.open('https://drive.google.com/uc?export=download&id=1cuIQHOhjvZfM_M74HjsICNpuzvMO0uKX', '_self'); return Container( width: screenWidth( context, ), child: HtmlElementView( viewType: 'resumeIframe', ), ); break; } } @override Widget build(BuildContext context) { aboutOpen = Provider.of<OnOff>(context).getAbout; aboutFS = Provider.of<OnOff>(context).getAboutFS; aboutPan = Provider.of<OnOff>(context).getAboutPan; return aboutOpen ? AnimatedPositioned( duration: Duration(milliseconds: aboutPan ? 0 : 200), top: aboutFS ? screenHeight(context, mulBy: 0.0335) : position!.dy, left: aboutFS ? 0 : position!.dx, child: aboutWindow(context), ) : Nothing(); } AnimatedContainer aboutWindow(BuildContext context) { String topApp = Provider.of<Apps>(context).getTop; return AnimatedContainer( duration: Duration(milliseconds: 200), width: aboutFS ? screenWidth(context, mulBy: 1) : screenWidth(context, mulBy: 0.58), height: aboutFS ?screenHeight(context, mulBy: 0.966) : screenHeight(context, mulBy: 0.7), decoration: BoxDecoration( border: Border.all( color: Colors.white.withOpacity(0.2), ), borderRadius: BorderRadius.all(Radius.circular(10)), color: Theme.of(context).dialogBackgroundColor, boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), spreadRadius: 10, blurRadius: 15, offset: Offset(0, 8), // changes position of shadow ), ], ), child: Stack( alignment: Alignment.topCenter, children: [ Row( children: [ Expanded( child: ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(10), bottomLeft: Radius.circular(10), ), child: AnimatedContainer( duration: Duration(milliseconds: 200), decoration: BoxDecoration( color: Theme.of(context).dialogBackgroundColor, border: Border( right: BorderSide( color: Theme.of(context) .cardColor .withOpacity(0.3), width: 0.6))), padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.01), vertical: screenHeight(context, mulBy: 0.05)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: screenHeight(context, mulBy: 0.03), ), AboutWindowItems( icon: CupertinoIcons.person_fill, iName: "About Chrisbin", isSelected: selected=="About", onTap: (){ setState(() { selected = "About"; }); }, ), AboutWindowItems( icon: CupertinoIcons.book_fill, iName: "Education", isSelected: selected=="Education", onTap: (){ setState(() { selected = "Education"; }); }, ), AboutWindowItems( icon: CupertinoIcons.hammer_fill, iName: "Skills", isSelected: selected=="Skills", onTap: (){ setState(() { selected = "Skills"; }); }, ), AboutWindowItems( icon: CupertinoIcons.device_desktop, iName: "Open Projects", isSelected: selected=="Projects", onTap: (){ setState(() { selected = "Projects"; }); }, ), AboutWindowItems( icon: CupertinoIcons.folder_fill, iName: "Resume", isSelected: selected=="Resume", onTap: (){ setState(() { selected = "Resume"; }); }, ), ], ), ), ), ), ClipRRect( borderRadius: BorderRadius.only( topRight: Radius.circular(10), bottomRight: Radius.circular(10), ), child: Stack( children: [ AnimatedContainer( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.02), vertical: screenHeight(context, mulBy: 0.05)), duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: aboutFS ? .78 : .43), decoration: BoxDecoration( color: Theme.of(context).dialogBackgroundColor, ), child: getContent(), ), ], ), ), ], ), GestureDetector( onPanUpdate: (tapInfo) { if (!aboutFS) { setState(() { position = Offset(position!.dx + tapInfo.delta.dx, position!.dy + tapInfo.delta.dy); }); } }, onPanStart: (details) { Provider.of<OnOff>(context, listen: false).onAboutPan(); }, onPanEnd: (details) { Provider.of<OnOff>(context, listen: false).offAboutPan(); }, onDoubleTap: () { Provider.of<OnOff>(context, listen: false).toggleAboutFS(); }, child: Container( alignment: Alignment.topRight, width: aboutFS ? screenWidth(context, mulBy: 0.95) : screenWidth(context, mulBy: 0.7), height: aboutFS ? screenHeight(context, mulBy: 0.059) : screenHeight(context, mulBy: 0.06), decoration: BoxDecoration( color: Colors.transparent, ), ), ), Container( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.013), vertical: screenHeight(context, mulBy: 0.02)), child: Row( children: [ InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.redAccent, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<OnOff>(context, listen: false).toggleAbout(); Provider.of<OnOff>(context, listen: false).offAboutFS(); Provider.of<Apps>(context, listen: false).closeApp("about"); }, ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( onTap: (){ Provider.of<OnOff>(context, listen: false).toggleAbout(); Provider.of<OnOff>(context, listen: false).offAboutFS(); }, child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.amber, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.green, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<OnOff>(context, listen: false) .toggleAboutFS(); }, ) ], ), ), Visibility( visible: topApp != "About Me", child: InkWell( onTap: (){ Provider.of<Apps>(context, listen: false) .bringToTop(ObjectKey("about")); }, child: Container( width: screenWidth(context,), height: screenHeight(context,), color: Colors.transparent, ), ), ), ], ), ); } } class AboutWindowItems extends StatefulWidget { bool isSelected; final String? iName; final IconData icon; VoidCallback? onTap; AboutWindowItems({ this.isSelected=false, this.iName, required this.icon, this.onTap, Key? key, }) : super(key: key); @override _AboutWindowItemsState createState() => _AboutWindowItemsState(); } class _AboutWindowItemsState extends State<AboutWindowItems> { bool hovering= false; @override Widget build(BuildContext context) { return InkWell( onTap: widget.onTap, child: MouseRegion( onEnter: (evnt){ setState(() { hovering=true; }); }, onExit: (evnt){ setState(() { hovering=false; }); }, child: Container( margin: EdgeInsets.only( bottom: 7 ), decoration: BoxDecoration( color: widget.isSelected?Colors.blueAccent.withOpacity(0.14): hovering ? Colors.blueAccent.withOpacity(0.14) : Colors.transparent , borderRadius: BorderRadius.all(Radius.circular(5))), alignment: Alignment.centerLeft, width: screenWidth(context,), padding: EdgeInsets.only(left: screenWidth(context,mulBy: 0.005)), height: screenHeight(context,mulBy: 0.038), child: Row( children: [ Icon(widget.icon, color: Theme.of(context).cardColor.withOpacity(1),), MBPText( text: " ${widget.iName}", size: 14, color: Theme.of(context).cardColor.withOpacity(1), ), ], ), ), ), ); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/apps/calendar.dart
import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:intl/intl.dart'; import 'package:mac_dt/system/componentsOnOff.dart'; import 'package:provider/provider.dart'; import '../data/analytics.dart'; import '../system/openApps.dart'; import '../sizes.dart'; import 'package:table_calendar/table_calendar.dart'; class Calendar extends StatefulWidget { final Offset? initPos; const Calendar({this.initPos, Key? key}) : super(key: key); @override _CalendarState createState() => _CalendarState(); } class _CalendarState extends State<Calendar> { Offset? position = Offset(0.0, 0.0); late bool calendarFS; late bool calendarPan; CalendarFormat format = CalendarFormat.month; DateTime selectedDay = DateTime.utc(1999, 07, 10); DateTime focusedDay = DateTime.now(); @override void initState() { position = widget.initPos; super.initState(); Provider.of<AnalyticsService>(context, listen: false) .logCurrentScreen("Calendar"); } @override Widget build(BuildContext context) { var spotifyOpen = Provider.of<OnOff>(context).getCalendar; calendarFS = Provider.of<OnOff>(context).getCalendarFS; calendarPan = Provider.of<OnOff>(context).getCalendarPan; return Visibility( visible: spotifyOpen, child: AnimatedPositioned( duration: Duration(milliseconds: calendarPan ? 0 : 200), top: calendarFS ? screenHeight(context, mulBy: 0.0335) : position!.dy, left: calendarFS ? 0 : position!.dx, child: calendarWindow(context), ), ); } AnimatedContainer calendarWindow(BuildContext context) { String topApp = Provider.of<Apps>(context).getTop; return AnimatedContainer( duration: Duration(milliseconds: 200), width: calendarFS ? screenWidth(context, mulBy: 1) : screenWidth(context, mulBy: 0.5), height: calendarFS ?screenHeight(context, mulBy: 0.966) : screenHeight(context, mulBy: 0.6), decoration: BoxDecoration( color: Theme.of(context).hintColor.withOpacity(1), border: Border.all( color: Colors.white.withOpacity(0.2), ), borderRadius: BorderRadius.all(Radius.circular(10)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), spreadRadius: 10, blurRadius: 15, offset: Offset(0, 8), // changes position of shadow ), ], ), child: Stack( children: [ Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Stack( alignment: Alignment.centerRight, children: [ Container( height: calendarFS ? screenHeight(context, mulBy: 0.059) : screenHeight(context, mulBy: 0.06), decoration: BoxDecoration( color: Theme.of(context).hintColor.withOpacity(1), borderRadius: BorderRadius.only( topRight: Radius.circular(10), topLeft: Radius.circular(10))), ), GestureDetector( onPanUpdate: (tapInfo) { if (!calendarFS) { setState(() { position = Offset(position!.dx + tapInfo.delta.dx, position!.dy + tapInfo.delta.dy); }); } }, onPanStart: (details) { Provider.of<OnOff>(context, listen: false).onCalendarPan(); }, onPanEnd: (details) { Provider.of<OnOff>(context, listen: false).offCalendarPan(); }, onDoubleTap: () { Provider.of<OnOff>(context, listen: false).toggleCalendarFS(); }, child: Container( alignment: Alignment.topRight, width: calendarFS ? screenWidth(context, mulBy: 0.95) : screenWidth(context, mulBy: 0.7), height: calendarFS ? screenHeight(context, mulBy: 0.059) : screenHeight(context, mulBy: 0.06), decoration: BoxDecoration( color: Colors.transparent, ), ), ), Container( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.013), vertical: screenHeight(context, mulBy: 0.01)), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Row( children: [ InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.redAccent, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<Apps>(context, listen: false).closeApp("calendar"); Provider.of<OnOff>(context, listen: false) .offCalendarFS(); Provider.of<OnOff>(context, listen: false).toggleCalendar(); }, ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( onTap: (){ Provider.of<OnOff>(context, listen: false).toggleCalendar(); Provider.of<OnOff>(context, listen: false).offCalendarFS(); }, child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.amber, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.green, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<OnOff>(context, listen: false) .toggleCalendarFS(); }, ) ], ), ], ), ), ], ), Expanded( child: ClipRRect( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(10), bottomRight: Radius.circular(10)), child: TableCalendar( firstDay: DateTime.utc(1999, 07, 10), lastDay: DateTime.utc(2200, 4, 28), focusedDay: focusedDay, calendarFormat: format, onFormatChanged: (CalendarFormat _format) { setState(() { format = _format; }); }, onDaySelected: (DateTime selectDay, DateTime focusDay) { setState(() { selectedDay = selectDay; focusedDay = focusDay; }); }, selectedDayPredicate: (DateTime date) { return isSameDay(selectedDay, date); }, weekendDays: [DateTime.sunday], calendarStyle: CalendarStyle( isTodayHighlighted: true, todayDecoration: BoxDecoration( color: Color(0xffff453a), shape: BoxShape.circle), defaultTextStyle: TextStyle( color: Theme.of(context).cardColor.withOpacity(1), fontWeight: Theme.of(context).textTheme.headline4!.fontWeight, fontFamily: "HN"), weekendTextStyle: TextStyle( color: Theme.of(context).cardColor.withOpacity(0.6), fontWeight: Theme.of(context).textTheme.headline4!.fontWeight, fontFamily: "HN"), outsideTextStyle: TextStyle( color: Theme.of(context).cardColor.withOpacity(0.3), fontWeight: Theme.of(context).textTheme.headline4!.fontWeight, fontFamily: "HN"), ), // rowHeight: screenHeight(context, mulBy: 0.07 ), headerStyle: HeaderStyle( formatButtonVisible: false, ), calendarBuilders: CalendarBuilders( headerTitleBuilder: (context, dateTime) { return Row( children: [ Text( "${DateFormat("LLLL").format(dateTime)}", style: TextStyle( color: Theme.of(context).cardColor.withOpacity(1), fontWeight: Theme.of(context) .textTheme .headline1! .fontWeight, fontSize: 25, fontFamily: "HN"), ), Text( " ${DateFormat("y").format(dateTime)}", style: TextStyle( color: Theme.of(context).cardColor.withOpacity(1), fontWeight: Theme.of(context) .textTheme .headline2! .fontWeight, fontSize: 25, fontFamily: "HN"), ), ], ); }, defaultBuilder: (context, dateTime, event) { return Container( decoration: BoxDecoration( color: (dateTime.weekday==DateTime.sunday)?Theme.of(context).cardColor.withOpacity(0.08):Colors.transparent, border: Border.all( color: Theme.of(context).cardColor.withOpacity(0.5), width: 0.1)), child: Align( alignment: Alignment.topRight, child: Container( padding: EdgeInsets.all(6), child: Text( (dateTime.day==1)?"${DateFormat("d LLL").format(dateTime)}":"${DateFormat("d").format(dateTime)}", style: TextStyle( color: Theme.of(context).cardColor.withOpacity(1), fontWeight: Theme.of(context) .textTheme .headline2! .fontWeight, fontSize: 14, fontFamily: "HN"), ), ), ), ); }, todayBuilder: (context, dateTime, event) { return Container( decoration: BoxDecoration( color: (dateTime.weekday==DateTime.sunday)?Theme.of(context).cardColor.withOpacity(0.08):Colors.transparent, border: Border.all( color: Theme.of(context).cardColor.withOpacity(0.5), width: 0.1)), child: Align( alignment: Alignment.topRight, child: Container( height: 25, width: 25, margin: EdgeInsets.all(3), decoration: BoxDecoration( color: Color(0xffff453a), shape: BoxShape.circle, ), child: Center( child: Text( "${DateFormat("d").format(dateTime)}", style: TextStyle( color: Colors.white, fontWeight: Theme.of(context) .textTheme .headline2! .fontWeight, fontSize: 12.5, fontFamily: "HN"), ), ), ), ) ); }, selectedBuilder: (context, dateTime, event) { return Container( decoration: BoxDecoration( color: (dateTime.weekday==DateTime.sunday)?Theme.of(context).cardColor.withOpacity(0.08):Colors.transparent, border: Border.all( color: Theme.of(context).cardColor.withOpacity(0.5), width: 0.1)), child: Align( alignment: Alignment.topRight, child: Container( height: 25, width: 25, margin: EdgeInsets.all(3), decoration: BoxDecoration( color: Colors.blueGrey, shape: BoxShape.circle, ), child: Center( child: Text( "${DateFormat("d").format(dateTime)}", style: TextStyle( color: Colors.white, fontWeight: Theme.of(context) .textTheme .headline2! .fontWeight, fontSize: 12.5, fontFamily: "HN"), ), ), ), ), ); }, outsideBuilder: (context, dateTime, event) { return Container( decoration: BoxDecoration( color: (dateTime.weekday==DateTime.sunday)?Theme.of(context).cardColor.withOpacity(0.08):Colors.transparent, border: Border.all( color: Theme.of(context).cardColor.withOpacity(0.5), width: 0.1)), child: Align( alignment: Alignment.topRight, child: Container( padding: EdgeInsets.all(6), child: Text( (dateTime==1)?"${DateFormat("d LLL").format(dateTime)}": "${DateFormat("d").format(dateTime)}", style: TextStyle( color: Theme.of(context).cardColor.withOpacity(0.3), fontWeight: Theme.of(context) .textTheme .headline2! .fontWeight, fontSize: 14, fontFamily: "HN"), ), ), ), ); }, dowBuilder: (context, dateTime){ return Padding( padding: const EdgeInsets.only(right: 8), child: Text( "${DateFormat("E").format(dateTime)}", textAlign: TextAlign.end, style: TextStyle( color: Theme.of(context).cardColor.withOpacity(1), fontWeight: Theme.of(context) .textTheme .headline2! .fontWeight, fontSize: 14, fontFamily: "HN"), ), ); }, ), ), ), ), ], ), Visibility( visible: topApp != "Calendar", child: InkWell( onTap: (){ Provider.of<Apps>(context, listen: false) .bringToTop(ObjectKey("calendar")); }, child: Container( width: screenWidth(context,), height: screenHeight(context,), color: Colors.transparent, ), ), ), ], ), ); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/apps/systemPreferences.dart
import 'dart:developer'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:mac_dt/system/componentsOnOff.dart'; import 'package:mac_dt/theme/theme.dart'; import 'package:provider/provider.dart'; import '../../system/openApps.dart'; import '../../sizes.dart'; import '../../widgets.dart'; import 'dart:html' as html; import 'dart:ui' as ui; import '../components/wallpaper/wallpaper.dart'; import '../data/analytics.dart'; /// Wallpaper screen is in a separate file. On right click>change wallpaper it willchange automatically /// due to the timer added in initstate. Usually wallpaper bool value is false. To be passed as true /// if wallpaper screen is to be opened. /// //TODO My image class SystemPreferences extends StatefulWidget { final Offset? initPos; final bool wallpaper; const SystemPreferences({this.initPos, this.wallpaper=false, Key? key}) : super(key: key); @override _SystemPreferencesState createState() => _SystemPreferencesState(); } class _SystemPreferencesState extends State<SystemPreferences> { Offset? position = Offset(0.0, 0.0); late bool sysPrefPan; late TextEditingController controller; final _navigatorKey2 = GlobalKey<NavigatorState>(); @override void initState() { position = widget.initPos; controller=TextEditingController()..addListener(() { setState(() { }); }); if(widget.wallpaper) Future.delayed(const Duration(milliseconds: 500), () { _navigatorKey2.currentState! .push(PageRouteBuilder( pageBuilder: (_, __, ___) => Wallpaper(), )); }); super.initState(); Provider.of<AnalyticsService>(context, listen: false) .logCurrentScreen("System Preferences"); } @override void dispose() { super.dispose(); } @override Widget build(BuildContext context) { var sysPrefOpen = Provider.of<OnOff>(context).getSysPref; sysPrefPan = Provider.of<OnOff>(context).getSysPrefPan; return sysPrefOpen ? AnimatedPositioned( duration: Duration(milliseconds: sysPrefPan ? 0 : 200), top: position!.dy, left: position!.dx, child: sysPrefWindow(context), ) : Nothing(); } AnimatedContainer sysPrefWindow(BuildContext context) { String topApp = Provider.of<Apps>(context).getTop; return AnimatedContainer( duration: Duration(milliseconds: 200), width: 673, height: 545, decoration: BoxDecoration( border: Border.all( color: Theme.of(context).cardColor.withOpacity(0.2), ), borderRadius: BorderRadius.all(Radius.circular(15)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), spreadRadius: 10, blurRadius: 15, offset: Offset(0, 8), // changes position of shadow ), ], ), child: Stack( children: [ Column( mainAxisAlignment: MainAxisAlignment.start, children: [ ///Top Stack( alignment: Alignment.centerRight, children: [ Container( height: 48, decoration: BoxDecoration( color: Theme.of(context).disabledColor, borderRadius: BorderRadius.only( topRight: Radius.circular(15), topLeft: Radius.circular(15))), ), GestureDetector( onPanUpdate: (tapInfo) { setState(() { position = Offset(position!.dx + tapInfo.delta.dx, position!.dy + tapInfo.delta.dy); }); }, onPanStart: (details) { Provider.of<OnOff>(context, listen: false).onSysPrefPan(); }, onPanEnd: (details) { Provider.of<OnOff>(context, listen: false) .offSysPrefPan(); }, child: Container( alignment: Alignment.topRight, width: screenWidth(context, mulBy: 0.7), height: 48, decoration: BoxDecoration( color: Colors.transparent, border: Border( bottom: BorderSide( color: Theme.of(context).splashColor, width: 0.8 )),), ), ), Container( height: 48, padding: EdgeInsets.symmetric( horizontal: 25, vertical: 9.61), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Row( children: [ InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.redAccent, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<OnOff>(context, listen: false) .offSafariFS(); Provider.of<Apps>(context, listen: false) .closeApp("systemPreferences"); Provider.of<OnOff>(context, listen: false) .toggleSysPref(); }, ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( onTap: () { Provider.of<OnOff>(context, listen: false) .toggleSysPref(); }, child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.amber, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.grey, shape: BoxShape.circle, ), ) ], ), SizedBox( width: 29, ), InkWell( onTap: () async => !await _navigatorKey2.currentState!.maybePop(), child: Icon( CupertinoIcons.back, color:Colors.grey.withOpacity(0.4), size: 20, ), ), SizedBox( width: 19.2, ), IgnorePointer( child: Icon( CupertinoIcons.forward, color: Colors.grey.withOpacity(0.4), size: 20, ), ), SizedBox( width: 25, ), IgnorePointer( child: Icon( CupertinoIcons.square_grid_4x3_fill, color: Colors.grey, size: 20, ), ), SizedBox( width: 19.2, ), IgnorePointer( child: MBPText( text: "System Preferences", size: 15, weight: Theme.of(context).textTheme.headline3!.fontWeight, color: Theme.of(context).cardColor.withOpacity(1), softWrap: true, ), ), Spacer( flex: 1, ), Container( alignment: Alignment.bottomCenter, width: screenWidth(context, mulBy: 0.09), height: 27, constraints: constraints(height: 0.028, width: 0.09), margin: EdgeInsets.zero, decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), ), child: TextField( textAlignVertical: TextAlignVertical.center, textAlign: TextAlign.start, controller: controller, cursorColor: Theme.of(context).cardColor.withOpacity(0.55), cursorHeight: 13, cursorWidth: 1, style: TextStyle( height: 0, color: Theme.of(context).cardColor.withOpacity(0.9), fontFamily: "HN", fontWeight: FontWeight.w300, fontSize: 11.5, letterSpacing: 0.5 ), maxLines: 1, decoration: InputDecoration( hintText: "Search", isCollapsed: false, suffixIcon: Visibility( visible: controller.text!="", child: IconButton( padding: EdgeInsets.zero, icon: Icon( CupertinoIcons.xmark_circle_fill, size: 15, color: Theme.of(context) .cardColor .withOpacity(0.55), ), onPressed: () { controller.clear(); }, ), ), contentPadding:EdgeInsets.zero, prefixIcon: Icon( CupertinoIcons.search, size: 15, color: Theme.of(context) .cardColor .withOpacity(0.55), ), hintStyle: TextStyle( height: 0, color: Theme.of(context) .cardColor .withOpacity(0.4), fontFamily: "SF", fontWeight: FontWeight.w400, fontSize: 12.5, letterSpacing: 0 ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(8), borderSide: BorderSide( color: Theme.of(context) .cardColor .withOpacity(0.2), width: 0.5 )), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(8), borderSide: BorderSide( color: Colors.blueAccent.withOpacity(0.7), width: 2 )), ), ), ), ], ), ), ], ), ///Content part Expanded( child: WillPopScope( onWillPop: () async => !await _navigatorKey2.currentState!.maybePop(), child: Navigator( key: _navigatorKey2, onGenerateRoute: (routeSettings) { return MaterialPageRoute( builder: (context) { final themeNotifier = Provider.of<ThemeNotifier>(context); return Column( children: [ Container( decoration: BoxDecoration( color: Theme.of(context).colorScheme.onError, // borderRadius: BorderRadius.only( // bottomRight: Radius.circular(15), // bottomLeft: Radius.circular(15)), ), padding: EdgeInsets.symmetric( vertical: 18.6, horizontal: 21.2), child: Row( children: [ Container( child: Image.asset( "assets/sysPref/chrisbin.jpg", fit: BoxFit.cover, ), clipBehavior: Clip.antiAlias, decoration: BoxDecoration(shape: BoxShape.circle), height: 57, width: 57, ), SizedBox( width: 13.44, ), RichText( text: TextSpan( text: "Chrisbin Sunny\n", style: TextStyle( color: Theme.of(context) .cardColor .withOpacity(0.9), fontWeight: Theme.of(context) .textTheme .headline3! .fontWeight, fontSize: 17, fontFamily: "SF", letterSpacing: 0.3), children: [ TextSpan( text: "Apple ID, iCloud, Media & App Store\n", style: TextStyle(fontSize: 11)) ])), Spacer(), Column( mainAxisSize: MainAxisSize.min, children: [ FittedBox( child: SizedBox( height: 45, width: 45, child: Image.asset( "assets/sysPref/appleID.png"), ), ), Text( "Apple ID\n", style: TextStyle( fontSize: 12, color: Colors.grey, fontWeight: FontWeight.w500, fontFamily: "SF", ), ) ], ), SizedBox( width: 42, ), Column( mainAxisSize: MainAxisSize.min, children: [ FittedBox( child: SizedBox( height: 45, width: 45, child: Image.asset( "assets/sysPref/familySharing.png"), ), ), Text( "Family\nSharing", textAlign: TextAlign.center, style: TextStyle( fontSize: 12, color: Colors.grey, fontWeight: FontWeight.w500, fontFamily: "SF", ), ) ], ), ], ), ), Container( decoration: BoxDecoration( color: Theme.of(context) .colorScheme .errorContainer, border: Border( top: BorderSide( color: Colors.grey.withOpacity(0.4), width: 0.6), bottom: BorderSide( color: Colors.grey.withOpacity(0.4), width: 0.6))), height: 190, padding: EdgeInsets.only( top: 15, left: 15, right: 21, bottom: 7), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( width: 18, ), Column( mainAxisSize: MainAxisSize.min, children: [ SizedBox( height: 5, ), FittedBox( child: SizedBox( height: 40, width: 40, child: Image.asset( "assets/sysPref/general.png"), ), ), Text( "General\n", style: TextStyle( fontSize: 12, color: Theme.of(context) .colorScheme .inversePrimary, fontWeight: FontWeight.w500, fontFamily: "SF", ), ) ], ), SizedBox( width: 20, ), InkWell( onTap: () { Navigator.of(context) .push(PageRouteBuilder( pageBuilder: (_, __, ___) => Wallpaper(), )); }, child: Column( mainAxisSize: MainAxisSize.min, children: [ SizedBox( height: 5, ), FittedBox( child: SizedBox( height: 40, width: 40, child: Image.asset( "assets/sysPref/desktop.png"), ), ), Text( "Desktop &\nScreen Saver", textAlign: TextAlign.center, style: TextStyle( fontSize: 12, color: Theme.of(context) .colorScheme .inversePrimary, fontWeight: FontWeight.w500, fontFamily: "SF", ), ) ], ), ), SizedBox( width: 10, ), SizedBox( height: 85, child: Image.asset( themeNotifier.isDark()? "assets/sysPref/settingTopDark.jpg": "assets/sysPref/settingTopLight.jpg", fit: BoxFit.contain, ), ) ], ), Expanded( child: Image.asset( themeNotifier.isDark()? "assets/sysPref/settingMidDark.jpg": "assets/sysPref/settingMidLight.jpg", fit: BoxFit.contain, ), ) ], ), ), Expanded( child: Container( width: screenWidth(context), decoration: BoxDecoration( color: Theme.of(context).colorScheme.onError, borderRadius: BorderRadius.only( bottomRight: Radius.circular(15), bottomLeft: Radius.circular(15)), ), clipBehavior: Clip.antiAliasWithSaveLayer, padding: EdgeInsets.only(left: 15), alignment: Alignment.centerLeft, child: Image.asset( themeNotifier.isDark()? "assets/sysPref/settingBottomDark.jpg": "assets/sysPref/settingBottomLight.jpg", fit: BoxFit.contain, ), ), ) ], ); }, ); }, ), ), ), ], ), Visibility( visible: topApp != "System Preferences", child: InkWell( onTap: () { Provider.of<Apps>(context, listen: false) .bringToTop(ObjectKey("systemPreferences")); }, child: Container( width: screenWidth( context, ), height: screenHeight( context, ), color: Colors.transparent, ), ), ), ], ), ); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/apps/maps.dart
import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:mac_dt/system/componentsOnOff.dart'; import 'package:mac_dt/theme/theme.dart'; import 'package:provider/provider.dart'; import '../sizes.dart'; import '../widgets.dart'; import 'dart:html' as html; import 'dart:ui' as ui; class Maps extends StatefulWidget { final Offset? initPos; const Maps({this.initPos, Key? key}) : super(key: key); @override _MapsState createState() => _MapsState(); } class _MapsState extends State<Maps> { Offset? position = Offset(0.0, 0.0); late bool spotifyFS; late bool spotifyPan; final html.IFrameElement _iframeElementURL = html.IFrameElement(); @override void initState() { position = widget.initPos; super.initState(); _iframeElementURL.srcdoc = '<html> <head> <meta charset="utf-8"> <script src="https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js"></script> <style> #map { width: 100%; height: 600px; } </style> </head> <body> <div id="map"></div> <script> mapkit.init({ authorizationCallback: function(done) { var xhr = new XMLHttpRequest(); xhr.open("GET", "/services/jwt"); xhr.addEventListener("load", function() { done(this.responseText); }); xhr.send(); } }); var Cupertino = new mapkit.CoordinateRegion( new mapkit.Coordinate(37.3316850890998, -122.030067374026), new mapkit.CoordinateSpan(0.167647972, 0.354985255) ); var map = new mapkit.Map("map"); map.region = Cupertino; </script> </body> </html>'; _iframeElementURL.style.border = 'none'; _iframeElementURL.allow = "autoplay; encrypted-media;"; _iframeElementURL.allowFullscreen = true; ui.platformViewRegistry.registerViewFactory( 'mapsIframe', (int viewId) => _iframeElementURL, ); } @override Widget build(BuildContext context) { var spotifyOpen = Provider.of<OnOff>(context).getSpotify; spotifyFS = Provider.of<OnOff>(context).getSpotifyFS; spotifyPan = Provider.of<OnOff>(context).getSpotifyPan; return spotifyOpen ? AnimatedPositioned( duration: Duration(milliseconds: spotifyPan ? 0 : 200), top: spotifyFS ? screenHeight(context, mulBy: 0.0335) : position!.dy, left: spotifyFS ? 0 : position!.dx, child: mapsWindow(context), ) : Container(); } AnimatedContainer mapsWindow(BuildContext context) { return AnimatedContainer( duration: Duration(milliseconds: 200), width: spotifyFS ? screenWidth(context, mulBy: 1) : screenWidth(context, mulBy: 0.7), height: spotifyFS ? screenHeight(context, mulBy: 0.863) : screenHeight(context, mulBy: 0.75), decoration: BoxDecoration( border: Border.all( color: Colors.white.withOpacity(0.2), ), borderRadius: BorderRadius.all(Radius.circular(10)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), spreadRadius: 10, blurRadius: 15, offset: Offset(0, 8), // changes position of shadow ), ], ), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Stack( alignment: Alignment.centerRight, children: [ Container( height: spotifyFS ? screenHeight(context, mulBy: 0.059) : screenHeight(context, mulBy: 0.06), decoration: BoxDecoration( color: Theme.of(context).dividerColor, borderRadius: BorderRadius.only( topRight: Radius.circular(10), topLeft: Radius.circular(10))), ), GestureDetector( onPanUpdate: (tapInfo) { if (!spotifyFS) { setState(() { position = Offset(position!.dx + tapInfo.delta.dx, position!.dy + tapInfo.delta.dy); }); } }, onPanStart: (details) { Provider.of<OnOff>(context, listen: false).onSpotifyPan(); }, onPanEnd: (details) { Provider.of<OnOff>(context, listen: false).offSpotifyPan(); }, onDoubleTap: () { Provider.of<OnOff>(context, listen: false).toggleSpotifyFS(); }, child: Container( alignment: Alignment.topRight, width: spotifyFS ? screenWidth(context, mulBy: 0.95) : screenWidth(context, mulBy: 0.7), height: spotifyFS ? screenHeight(context, mulBy: 0.059) : screenHeight(context, mulBy: 0.06), decoration: BoxDecoration( color: Colors.transparent, border: Border( bottom: BorderSide( color: Colors.black.withOpacity(0.5), width: 0.8))), ), ), Container( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.013), vertical: screenHeight(context, mulBy: 0.01)), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Row( children: [ InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.redAccent, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<OnOff>(context, listen: false) .toggleSpotify(); Provider.of<OnOff>(context, listen: false) .offSpotifyFS(); }, ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.amber, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.green, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<OnOff>(context, listen: false) .toggleSpotifyFS(); }, ) ], ), ], ), ), ], ), Expanded( child: ClipRRect( borderRadius: BorderRadius.only( bottomRight: Radius.circular(10), bottomLeft: Radius.circular(10)), child: BackdropFilter( filter: ui.ImageFilter.blur(sigmaX: 30.0, sigmaY: 30.0), child: Container( height: screenHeight(context, mulBy: 0.14), width: screenWidth( context, ), decoration: BoxDecoration( color: Theme.of(context).dividerColor.withOpacity(0.8), ), child: HtmlElementView( viewType: 'mapsIframe', ), ), ), ), ), ], ), ); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/apps/spotify.dart
import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:mac_dt/system/componentsOnOff.dart'; import 'package:mac_dt/theme/theme.dart'; import 'package:provider/provider.dart'; import '../data/analytics.dart'; import '../system/openApps.dart'; import '../sizes.dart'; import '../widgets.dart'; import 'dart:html' as html; import 'dart:ui' as ui; class Spotify extends StatefulWidget { final Offset? initPos; const Spotify({this.initPos, Key? key}) : super(key: key); @override _SpotifyState createState() => _SpotifyState(); } class _SpotifyState extends State<Spotify> { Offset? position = Offset(0.0, 0.0); late bool spotifyFS; late bool spotifyPan; final html.IFrameElement _iframeElementURL = html.IFrameElement(); @override void initState() { position = widget.initPos; super.initState(); _iframeElementURL.src = 'https://open.spotify.com/embed/playlist/2HBIMnwHxqq2Q79LFJkBtB'; _iframeElementURL.style.border = 'none'; _iframeElementURL.allow = "autoplay; encrypted-media;"; _iframeElementURL.allowFullscreen = true; ui.platformViewRegistry.registerViewFactory( 'spotifyIframe', (int viewId) => _iframeElementURL, ); Provider.of<AnalyticsService>(context, listen: false) .logCurrentScreen("Spotify"); } @override Widget build(BuildContext context) { var spotifyOpen = Provider.of<OnOff>(context).getSpotify; spotifyFS = Provider.of<OnOff>(context).getSpotifyFS; spotifyPan = Provider.of<OnOff>(context).getSpotifyPan; return spotifyOpen ? AnimatedPositioned( duration: Duration(milliseconds: spotifyPan ? 0 : 200), top: spotifyFS ? 25 : position!.dy, left: spotifyFS ? 0 : position!.dx, child: spotifyWindow(context), ) : Nothing(); } AnimatedContainer spotifyWindow(BuildContext context) { String topApp = Provider.of<Apps>(context).getTop; return AnimatedContainer( duration: Duration(milliseconds: 200), width: spotifyFS ? screenWidth(context, mulBy: 1) : screenWidth(context, mulBy: 0.5), height: spotifyFS ?screenHeight(context, mulBy: 0.975) : screenHeight(context, mulBy: 0.7), decoration: BoxDecoration( border: Border.all( color: Colors.white.withOpacity(0.2), ), borderRadius: BorderRadius.all(Radius.circular(10)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), spreadRadius: 10, blurRadius: 15, offset: Offset(0, 8), // changes position of shadow ), ], ), child: Stack( children: [ Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Stack( alignment: Alignment.centerRight, children: [ Container( height: spotifyFS ? screenHeight(context, mulBy: 0.056) : screenHeight(context, mulBy: 0.053), decoration: BoxDecoration( color: Color(0xff3a383e), borderRadius: BorderRadius.only( topRight: Radius.circular(10), topLeft: Radius.circular(10))), ), GestureDetector( onPanUpdate: (tapInfo) { if (!spotifyFS) { setState(() { position = Offset(position!.dx + tapInfo.delta.dx, position!.dy + tapInfo.delta.dy); }); } }, onPanStart: (details) { Provider.of<OnOff>(context, listen: false).onSpotifyPan(); }, onPanEnd: (details) { Provider.of<OnOff>(context, listen: false).offSpotifyPan(); }, onDoubleTap: () { Provider.of<OnOff>(context, listen: false).toggleSpotifyFS(); }, child: Container( alignment: Alignment.topRight, width: spotifyFS ? screenWidth(context, mulBy: 0.95) : screenWidth(context, mulBy: 0.6), height: spotifyFS ? screenHeight(context, mulBy: 0.056) : screenHeight(context, mulBy: 0.053), decoration: BoxDecoration( color: Colors.transparent, border: Border( bottom: BorderSide( color: Colors.black.withOpacity(0.5), width: 0.8))), ), ), Container( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.013), vertical: screenHeight(context, mulBy: 0.01)), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Row( children: [ InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.redAccent, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<OnOff>(context, listen: false) .offSpotifyFS(); Provider.of<Apps>(context, listen: false).closeApp("spotify"); Provider.of<OnOff>(context, listen: false).toggleSpotify(); }, ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( onTap: (){ Provider.of<OnOff>(context, listen: false).toggleSpotify(); Provider.of<OnOff>(context, listen: false).offSpotifyFS(); }, child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.amber, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.green, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<OnOff>(context, listen: false) .toggleSpotifyFS(); }, ) ], ), ], ), ), ], ), Expanded( child: ClipRRect( borderRadius: BorderRadius.only( bottomRight: Radius.circular(10), bottomLeft: Radius.circular(10)), child: BackdropFilter( filter: ui.ImageFilter.blur(sigmaX: 30.0, sigmaY: 30.0), child: Container( height: screenHeight(context, mulBy: 0.14), width: screenWidth( context, ), decoration: BoxDecoration( color: Color(0xff3a383e).withOpacity(0.8), ), child: HtmlElementView( viewType: 'spotifyIframe', ), ), ), ), ), ], ), Visibility( visible: topApp != "Spotify", child: InkWell( onTap: (){ Provider.of<Apps>(context, listen: false) .bringToTop(ObjectKey("spotify")); }, child: Container( width: screenWidth(context,), height: screenHeight(context,), color: Colors.transparent, ), ), ), ], ), ); } }
0
mirrored_repositories/chrishub/lib/apps
mirrored_repositories/chrishub/lib/apps/safari/safariWindow.dart
import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:mac_dt/system/componentsOnOff.dart'; import 'package:mac_dt/theme/theme.dart'; import 'package:provider/provider.dart'; import '../../data/analytics.dart'; import '../../system/openApps.dart'; import '../../sizes.dart'; import '../../widgets.dart'; import 'dart:html' as html; import 'dart:ui' as ui; //TODO: BUG Found>> After opening youtube and closing the safari, all searches redirects to youtube. class Safari extends StatefulWidget { final Offset? initPos; const Safari({this.initPos, Key? key}) : super(key: key); @override _SafariState createState() => _SafariState(); } class _SafariState extends State<Safari> { Offset? position = Offset(0.0, 0.0); String selected = "Applications"; TextEditingController urlController = new TextEditingController(); late bool safariFS; late bool safariPan; String url = ""; bool isDoc = false; final html.IFrameElement _iframeElementURL = html.IFrameElement(); final _navigatorKey2 = GlobalKey<NavigatorState>(); final html.IFrameElement _iframeElementDOC = html.IFrameElement(); void handleURL( String text, ) { Provider.of<AnalyticsService>(context, listen: false) .logSearch(text); isDoc = false; text = text.trim(); if (text.length == 0) return; if (text.indexOf("http://") != 0 && text.indexOf("https://") != 0) { url = "https://" + text + "/"; } else { url = text; } if (url.contains("pornhub")||url.contains("porn")||url.contains("xxx")) { url = "https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1&enablejsapi=1"; } if (url.contains("google")) { url = "https://www.google.com/webhp?igu=1"; } setState(() { url = Uri.encodeFull(url); urlController.text = "https://"+url.substring(8, url.indexOf("/", 8)); _iframeElementURL.src = url; debugPrint(_iframeElementURL.innerHtml.toString()); }); } void handleDOC( String text, ) { Provider.of<AnalyticsService>(context, listen: false) .logSearch(text); text = text.trim(); if (text.length == 0) return; setState(() { isDoc = true; url = text; if(url.contains("twitter")){ urlController.text ="twitter.com"; }else{ urlController.text = url.substring(8, url.indexOf("/", 8)); } _iframeElementDOC.srcdoc = url; }); } @override void initState() { position = widget.initPos; super.initState(); _iframeElementURL.src = 'https://www.google.com/webhp?igu=1'; _iframeElementURL.style.border = 'none'; _iframeElementURL.allow = "autoplay"; _iframeElementURL.allow = "keyboard-map"; _iframeElementURL.allowFullscreen = true; ui.platformViewRegistry.registerViewFactory( 'urlIframe', (int viewId) => _iframeElementURL, ); ui.platformViewRegistry.registerViewFactory( 'docIframe', (int viewId) => _iframeElementDOC, ); Provider.of<AnalyticsService>(context, listen: false) .logCurrentScreen("Safari"); } @override Widget build(BuildContext context) { var safariOpen = Provider.of<OnOff>(context).getSafari; safariFS = Provider.of<OnOff>(context).getSafariFS; safariPan = Provider.of<OnOff>(context).getSafariPan; return safariOpen ? AnimatedPositioned( duration: Duration(milliseconds: safariPan ? 0 : 200), top: safariFS ? 25 : position!.dy, left: safariFS ? 0 : position!.dx, child: safariWindow(context), ) : Nothing(); } AnimatedContainer safariWindow(BuildContext context) { String topApp = Provider.of<Apps>(context).getTop; return AnimatedContainer( duration: Duration(milliseconds: 200), width: safariFS ? screenWidth(context, mulBy: 1) : screenWidth(context, mulBy: 0.57), height: safariFS ?screenHeight(context, mulBy: 0.975) : screenHeight(context, mulBy: 0.7), decoration: BoxDecoration( border: Border.all( color: Colors.white.withOpacity(0.2), ), borderRadius: BorderRadius.all(Radius.circular(10)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), spreadRadius: 10, blurRadius: 15, offset: Offset(0, 8), // changes position of shadow ), ], ), child: Stack( children: [ Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Stack( alignment: Alignment.centerRight, children: [ Container( height: safariFS ? screenHeight(context, mulBy: 0.059) : screenHeight(context, mulBy: 0.06), decoration: BoxDecoration( color: Theme.of(context).dividerColor, borderRadius: BorderRadius.only( topRight: Radius.circular(10), topLeft: Radius.circular(10))), ), GestureDetector( onPanUpdate: (tapInfo) { if (!safariFS) { setState(() { position = Offset(position!.dx + tapInfo.delta.dx, position!.dy + tapInfo.delta.dy); }); } }, onPanStart: (details) { Provider.of<OnOff>(context, listen: false).onSafariPan(); }, onPanEnd: (details) { Provider.of<OnOff>(context, listen: false).offSafariPan(); }, onDoubleTap: () { Provider.of<OnOff>(context, listen: false).toggleSafariFS(); }, child: Container( alignment: Alignment.topRight, width: safariFS ? screenWidth(context, mulBy: 0.95) : screenWidth(context, mulBy: 0.7), height: safariFS ? screenHeight(context, mulBy: 0.059) : screenHeight(context, mulBy: 0.06), decoration: BoxDecoration( color: Colors.transparent, border: Border( bottom: BorderSide( color: Colors.black.withOpacity(0.5), width: 0.8))), ), ), Container( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.013), vertical: screenHeight(context, mulBy: 0.01)), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Row( children: [ InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.redAccent, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<OnOff>(context, listen: false) .offSafariFS(); Provider.of<Apps>(context, listen: false).closeApp("safari"); Provider.of<OnOff>(context, listen: false).toggleSafari(); url = ""; urlController.text = ""; }, ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( onTap: (){ Provider.of<OnOff>(context, listen: false).toggleSafari(); Provider.of<OnOff>(context, listen: false).offSafariFS(); }, child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.amber, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.green, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<OnOff>(context, listen: false) .toggleSafariFS(); }, ) ], ), Spacer( flex: 4, ), Center( child: Container( height: screenHeight(context, mulBy: 0.033), child: IconButton( padding: EdgeInsets.zero, color: Theme.of(context).cardColor.withOpacity(0.5), icon: Icon(Icons.home_outlined, size: 22,), onPressed: () { setState(() { url = ""; urlController.text = ""; }); }, ), ), ), Spacer( flex: 1, ), Container( width: 300, height: screenHeight(context, mulBy: 0.03), //0.038 margin: EdgeInsets.zero, decoration: BoxDecoration( color: Theme.of(context).colorScheme.error, borderRadius: BorderRadius.circular(5), ), child: Center( child: Container( alignment: Alignment.center, child: TextField( controller: urlController, //textAlignVertical: TextAlignVertical.center, textAlign: TextAlign.center, cursorColor: Theme.of(context).cardColor.withOpacity(0.55), onSubmitted: (text) => handleURL(text), style: TextStyle( height: 2, color: Theme.of(context).cardColor.withOpacity(1), fontFamily: "HN", fontWeight: FontWeight.w400, fontSize: 10, ), maxLines: 1, decoration: InputDecoration( hintText: "Search or enter website name", //TODO isCollapsed: true, contentPadding: EdgeInsets.fromLTRB(5.0, 00.0, 5.0, 3.0), hintStyle: TextStyle( height: 2, color: Theme.of(context) .cardColor .withOpacity(0.4), fontFamily: "HN", fontWeight: FontWeight.w400, fontSize: 10, ), border: InputBorder.none, ), ), ), ), ), Spacer( flex: 6, ), ], ), ), ], ), Expanded( child: ClipRRect( borderRadius: BorderRadius.only( bottomRight: Radius.circular(10), bottomLeft: Radius.circular(10)), child: BackdropFilter( filter: ui.ImageFilter.blur(sigmaX: 30.0, sigmaY: 30.0), child: Container( // padding: EdgeInsets.symmetric( // horizontal: screenWidth(context, mulBy: 0.013), // vertical: screenHeight(context, mulBy: 0.025)), height: screenHeight(context, mulBy: 0.14), width: screenWidth( context, ), decoration: BoxDecoration( color: Theme.of(context).hintColor, ), child: (url == "") ?WillPopScope( onWillPop: () async => !await _navigatorKey2.currentState!.maybePop(), child: Navigator( key: _navigatorKey2, onGenerateRoute: (routeSettings) { return MaterialPageRoute( builder: (context) { return SingleChildScrollView( child: Padding( padding: EdgeInsets.symmetric( vertical: screenHeight(context, mulBy: 0.08), horizontal: screenWidth(context, mulBy: 0.06)), child: Column( children: [ Container( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.06)), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ MBPText( text: "Favourites", color: Theme.of(context).cardColor.withOpacity(1), size: 22, weight: Theme.of(context) .textTheme .headline1! .fontWeight, ), SizedBox( height: screenHeight(context, mulBy: 0.02), ), Wrap( alignment: WrapAlignment.spaceBetween, spacing: 15, runSpacing: 20, children: [ InkWell( onTap: () { html.window.open( 'https://www.apple.com', 'new tab', ); }, child: Column( children: [ ClipRRect( borderRadius: BorderRadius.circular(10), child: Container( height: 70, width: 70, padding: EdgeInsets.all(6), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10)), child: Image.asset( "assets/caches/apple.png", fit: BoxFit.scaleDown, ), ), ), SizedBox( height: screenHeight(context, mulBy: 0.01), ), MBPText( text: "Apple", size: 10, color: Theme.of(context) .cardColor .withOpacity(0.8), ) ], ), ), InkWell( onTap: () { handleURL( "https://www.google.com/webhp?igu=1"); }, child: Column( children: [ ClipRRect( borderRadius: BorderRadius.circular(10), child: Container( height: 70, width: 70, padding: EdgeInsets.all(6), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10)), child: Image.asset( "assets/caches/google.png", fit: BoxFit.scaleDown, ), ), ), SizedBox( height: screenHeight(context, mulBy: 0.01), ), MBPText( text: "Google", size: 10, color: Theme.of(context) .cardColor .withOpacity(0.8), ) ], ), ), InkWell( onTap: () { handleURL( "https://www.youtube.com/embed/GEZhD3J89ZE?start=4207&autoplay=1&enablejsapi=1"); }, child: Column( children: [ ClipRRect( borderRadius: BorderRadius.circular(10), child: Container( height: 70, width: 70, padding: EdgeInsets.all(6), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10)), child: Image.asset( "assets/caches/youtube.jpg", fit: BoxFit.scaleDown, ), ), ), SizedBox( height: screenHeight(context, mulBy: 0.01), ), MBPText( text: "Youtube", size: 10, color: Theme.of(context) .cardColor .withOpacity(0.8), ) ], ), ), InkWell( onTap: () { handleDOC( '<a class="twitter-timeline" href="https://twitter.com/chrisbinsunny?ref_src=twsrc%5Etfw">Tweets by chrisbinsunny</a> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>', ); }, child: Column( children: [ ClipRRect( borderRadius: BorderRadius.circular(10), child: Container( height: 70, width: 70, padding: EdgeInsets.all(6), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10)), child: Image.asset( "assets/caches/twitter.png", fit: BoxFit.scaleDown, ), ), ), SizedBox( height: screenHeight(context, mulBy: 0.01), ), MBPText( text: "Twitter", size: 10, color: Theme.of(context) .cardColor .withOpacity(0.8), ) ], ), ), InkWell( onTap: () { html.window.open( "https://github.com/chrisbinsunny", "new_tab"); }, child: Column( children: [ ClipRRect( borderRadius: BorderRadius.circular(10), child: Container( height: 70, width: 70, padding: EdgeInsets.all(6), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10)), child: Image.asset( "assets/caches/github.png", fit: BoxFit.scaleDown, ), ), ), SizedBox( height: screenHeight(context, mulBy: 0.01), ), MBPText( text: "GitHub", size: 10, color: Theme.of(context) .cardColor .withOpacity(0.8), ) ], ), ), InkWell( onTap: () { html.window.open( "https://www.instagram.com/binary.ghost", "new_tab"); }, child: Column( children: [ ClipRRect( borderRadius: BorderRadius.circular(10), child: Container( height: 70, width: 70, padding: EdgeInsets.all(6), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10)), child: Image.asset( "assets/caches/insta.png", fit: BoxFit.scaleDown, ), ), ), SizedBox( height: screenHeight(context, mulBy: 0.01), ), MBPText( text: "Instagram", size: 10, color: Theme.of(context) .cardColor .withOpacity(0.8), ) ], ), ), ], ), ], ), ), SizedBox( height: screenHeight(context, mulBy: 0.05), ), Container( child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ MBPText( text: "Frequently Visited", color: Theme.of(context).cardColor.withOpacity(1), size: 22, weight: Theme.of(context) .textTheme .headline1! .fontWeight, ), SizedBox( height: screenHeight(context, mulBy: 0.02), ), Wrap( alignment: WrapAlignment.spaceBetween, spacing: 20, runSpacing: 20, children: [ InkWell( onTap: () { html.window.open( 'https://chrisbinsunny.github.io/chrishub', 'new tab', ); }, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( height: 100, width: 170, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), ), clipBehavior: Clip.antiAlias, child: Image.asset( "assets/caches/chrishub.jpg", fit: BoxFit.cover, alignment: Alignment.topLeft, ), ), SizedBox( height: screenHeight(context, mulBy: 0.01), ), MBPText( text: "Chrisbin's MacBook Pro", size: 10, color: Theme.of(context) .cardColor .withOpacity(0.8), ) ], ), ), InkWell( onTap: () { html.window.open( 'https://chrisbinsunny.github.io/dream', 'new tab', ); }, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( height: 100, width: 170, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), ), clipBehavior: Clip.antiAlias, child: Image.asset( "assets/caches/dream.jpg", fit: BoxFit.cover, alignment: Alignment.topLeft, ), ), SizedBox( height: screenHeight(context, mulBy: 0.01), ), MBPText( text: "Dream", size: 10, color: Theme.of(context) .cardColor .withOpacity(0.8), ) ], ), ), InkWell( onTap: () { html.window.open( 'https://chrisbinsunny.github.io/Flutter-Talks', 'new tab', ); }, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( height: 100, width: 170, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), ), clipBehavior: Clip.antiAlias, child: Image.asset( "assets/caches/flutterTalks.jpg", fit: BoxFit.cover, alignment: Alignment.topLeft, ), ), SizedBox( height: screenHeight(context, mulBy: 0.01), ), MBPText( text: "Flutter Talks", size: 10, color: Theme.of(context) .cardColor .withOpacity(0.8), ) ], ), ), ], ) ], ), ), ], ), ), ); }, ); }, ), ) : ((!isDoc) ? HtmlElementView( viewType: 'urlIframe', ) : Container( color: Colors.black, padding: EdgeInsets.only( left: screenWidth(context, mulBy: 0.09), right: screenWidth(context, mulBy: 0.09), top: screenHeight(context, mulBy: 0.05) ), child: HtmlElementView( viewType: 'docIframe', ), )), ), ), ), ), ], ), Visibility( visible: topApp != "Safari", child: InkWell( onTap: (){ Provider.of<Apps>(context, listen: false) .bringToTop(ObjectKey("safari")); }, child: Container( width: screenWidth(context,), height: screenHeight(context,), color: Colors.transparent, ), ), ), ], ), ); } }
0
mirrored_repositories/chrishub/lib/apps
mirrored_repositories/chrishub/lib/apps/terminal/terminal.dart
import 'dart:developer'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter/services.dart'; import 'package:intl/intl.dart'; import 'package:mac_dt/system/componentsOnOff.dart'; import 'package:mac_dt/widgets.dart'; import 'package:provider/provider.dart'; import '../../components/finderWindow.dart'; import '../../data/analytics.dart'; import '../../providers.dart'; import '../../system/folders/folders.dart'; import '../../system/openApps.dart'; import '../../sizes.dart'; import 'dart:html' as html; import '../calendar.dart'; import '../feedback/feedback.dart'; import '../messages/messages.dart'; import '../safari/safariWindow.dart'; import '../spotify.dart'; import '../vscode.dart'; import 'commands.dart'; //TODO Has an issue with cursor. Currently the issue is present in master branch of flutter. /// GitHub Issue: https://github.com/flutter/flutter/issues/31661 //TODO Clear command not working String output = ""; String directory = "/~"; class Terminal extends StatefulWidget { final Offset? initPos; const Terminal({this.initPos, Key? key}) : super(key: key); @override _TerminalState createState() => _TerminalState(); } class _TerminalState extends State<Terminal> { Offset? position = Offset(0.0, 0.0); late bool terminalFS; late bool terminalPan; var commandTECs = <TextEditingController>[]; var oldCommands = <String>[""]; var commandCards = <Widget>[]; late DateTime now; int updownIndex = 0; String currentDir = "~"; ///Data should be entered as lowercase. It is converted to alternate caps when it is displayed. /// /// Links are added to end of pdf name after //// Map<String, List<String>> contents = { "~": [ "applications", "documents", "downloads", "library", "movies", "music", "pictures", ], "library": [ "Alchemist", "One Night at a call centre", "Revolution 2020" ], "skills": ["Front-end development", "jQuery", "Flutter", "Firebase"], "projects": ["Macbook", "Dream", "chrisbinsunny.github.io", "Flutter-Talks", ], "applications": [ "calendar", "feedback", "notes", "photos", "messages", "maps", "safari", "spotify", "vscode", ], "interests": ["Software Engineering","Game Development", "AI in Games","Deep Learning", "Computer Vision"], "languages": ["Flutter", "Dart", "Python", "GoLang", "C++", "Java", ], "documents":[ "cabby: published paper.pdf////https://www.transistonline.com/downloads/cabby-the-ride-sharing-platform/", "chrisbin resume.pdf////https://drive.google.com/file/d/1cuIQHOhjvZfM_M74HjsICNpuzvMO0uKX/view", "chrisbin resume dark long.pdf////https://drive.google.com/file/d/1lPK15gLkNr2Rso3JNr0b-RdmFN245w87/view", "chrisbin resume light long.pdf////https://drive.google.com/file/d/11j0UCdSXBRA1DPFct1EImmKFpyQu0fiH/view", "interests", "languages", "projects", ], "downloads":[ "Antonn- Game Testing platform.pdf", "Cabby final.pdf", "Chrisbin seminar.docx", "Chrisbin seminar.pdf", "Dream.zip", "Flutter_F_4K_Wallpaper.png", "Flutter Talks.pdf" "Ride Sharing platform.pdf", ], "movies":[], "music":[], "pictures":[], }; ScrollController _scrollController = ScrollController(); _scrollToBottom() { _scrollController.jumpTo(_scrollController.position.maxScrollExtent); } Widget createCard() { var commandController = TextEditingController(); commandTECs.add(commandController); return TerminalCommand( commandController: commandController, onSubmit: () { setState(() { processCommands(commandController.text); commandCards.add(createCard()); oldCommands.add(commandController.text); }); }, ); } processCommands(String text) { Provider.of<AnalyticsService>(context, listen: false) .logTerminal(text); String textOrg= text; text = text.toLowerCase(); var textWords = text.split(" "); String command = textWords[0]; textWords.removeAt(0); String variable = ""; output = ""; if (textWords.length > 0) variable = textWords[0]; switch (command) { case "": break; case "ls": String target; if (variable == "") target = currentDir; else { target = textWords[0]; } if (textWords.length > 1) { output = "Too many arguments found, 1 argument expected."; break; } if (contents.containsKey(target)) { if (contents[target]!.length < 10) { int maxLen = 0; for (int i = 0; i < contents[target]!.length; i++) { if (contents[target]![i].length > maxLen) maxLen = contents[target]![i].length; } maxLen += 5; for (int i = 0; i < contents[target]!.length; i++) { output += "${contents[target]![i].split("////")[0].capitalize()}"; if ((i + 1) % 3 == 0) output += "\n"; else output += " " * (maxLen - contents[target]![i].length); } } else contents[target]!.forEach((item) { output += "${item.split("////")[0].capitalize()}\n"; }); break; } else { output = "ls: $target: No such file or directory"; } break; case "open": if (variable=="-a"||currentDir=="applications") { switch (textWords[currentDir=="applications"?0:1]){ case "finder": output="Opening Finder"; tapFunctions(context); Provider.of<OnOff>(context, listen: false) .maxFinder(); Provider.of<Apps>(context, listen: false).openApp( Finder( key: ObjectKey("finder"), initPos: Offset( screenWidth(context, mulBy: 0.2), screenHeight(context, mulBy: 0.18))), Provider.of<OnOff>(context, listen: false) .maxFinder() ); break; case "safari": output="Opening Safari"; tapFunctions(context); Provider.of<OnOff>(context, listen: false) .maxSafari(); Provider.of<Apps>(context, listen: false).openApp( Safari( key: ObjectKey("safari"), initPos: Offset( screenWidth(context, mulBy: 0.21), screenHeight(context, mulBy: 0.14))), Provider.of<OnOff>(context, listen: false) .maxSafari() ); break; case "messages": output="Opening Messages"; tapFunctions(context); Provider.of<OnOff>(context, listen: false) .maxMessages(); Provider.of<Apps>(context, listen: false).openApp( Messages( key: ObjectKey("messages"), initPos: Offset( screenWidth(context, mulBy: 0.27), screenHeight(context, mulBy: 0.2))), Provider.of<OnOff>(context, listen: false) .maxMessages() ); break; case "maps": output="Opening Maps"; Provider.of<DataBus>(context, listen: false).setNotification( "App has not been installed. Create the app on GitHub.", "https://github.com/chrisbinsunny", "maps", "Not installed" ); Provider.of<OnOff>(context, listen: false).onNotifications(); break; case "spotify": output="Opening Spotify"; tapFunctions(context); Provider.of<OnOff>(context, listen: false) .maxSpotify(); Provider.of<Apps>(context, listen: false).openApp( Spotify( key: ObjectKey("spotify"), initPos: Offset( screenWidth(context, mulBy: 0.24), screenHeight(context, mulBy: 0.15) )), Provider.of<OnOff>(context, listen: false) .maxSpotify() ); break; case "terminal": output="Opening Terminal"; break; case "vscode": output="Opening Visual Studio Code"; tapFunctions(context); Provider.of<OnOff>(context, listen: false).maxVS(); Provider.of<Apps>(context, listen: false).openApp( VSCode( key: ObjectKey("vscode"), initPos: Offset( screenWidth(context, mulBy: 0.24), screenHeight(context, mulBy: 0.15))), Provider.of<OnOff>(context, listen: false).maxVS() ); break; case "photos": output="Opening Photos"; Provider.of<DataBus>(context, listen: false).setNotification( "App has not been installed. Create the app on GitHub.", "https://github.com/chrisbinsunny", "photos", "Not installed" ); Provider.of<OnOff>(context, listen: false).onNotifications(); break; case "calendar": output="Opening Calendar"; tapFunctions(context); Provider.of<OnOff>(context, listen: false) .maxCalendar(); Provider.of<Apps>(context, listen: false).openApp( Calendar( key: ObjectKey("calendar"), initPos: Offset( screenWidth(context, mulBy: 0.24), screenHeight(context, mulBy: 0.15)) ), Provider.of<OnOff>(context, listen: false) .maxCalendar() ); break; case "notes": output="Opening Notes"; Provider.of<DataBus>(context, listen: false).setNotification( "App has not been installed. Create the app on GitHub.", "https://github.com/chrisbinsunny", "notes", "Not installed" ); Provider.of<OnOff>(context, listen: false).onNotifications(); break; case "feedback": output="Opening Feedback"; tapFunctions(context); Provider.of<OnOff>(context, listen: false) .maxFeedBack(); Provider.of<Apps>(context, listen: false).openApp( FeedBack( key: ObjectKey("feedback"), initPos: Offset( screenWidth(context, mulBy: 0.2), screenHeight(context, mulBy: 0.12))), Provider.of<OnOff>(context, listen: false) .maxFeedBack() ); break; default: output="Application not found or Installed."; } } else if(currentDir=="projects"){ String link="404"; switch(variable){ case "macbook": link= "https://chrisbinsunny.github.io/chrishub"; break; case "dream": link= "https://chrisbinsunny.github.io/dream"; break; case "chrisbinsunny.github.io": link= "https://chrisbinsunny.github.io"; break; case "flutter-talks": link= "https://chrisbinsunny.github.io/Flutter-Talks"; break; } if(link=="404"){ output="Can't open the application from this location. Try using \"open -a\"."; } else{ output="Opening ${variable}"; Future.delayed(const Duration(seconds: 1), () { html.window.open(link, 'new tab'); }); } } else if(textWords.join(" ").contains(".pdf")){ String pdf=""; contents[currentDir]!.forEach((element) { if(element.split("////")[0]==textWords.join(" ")){ pdf= element; } }); if(pdf==""){ output="File \"${textWords.join(" ")}\" not found. Check the file name"; } else{ output="Opening ${pdf.split("////")[0].capitalize()}"; Future.delayed(const Duration(seconds: 1), () { html.window.open(pdf.split("////")[1], 'new tab'); }); } } else{ output="Can't open the application from this location. Try using \"open -a\"."; } break; case "cd": if (variable == "") { log("1"); currentDir = "~"; directory = "/~"; break; } if (textWords.length > 1) { output = "Too many arguments found, 1 argument expected."; break; } if (variable == ".." || variable == "../") { if (currentDir == "~") { output = "Can't go back. Reached the end"; break; } var folders = directory.split("/"); currentDir = folders[folders.length - 2]; folders.removeAt(folders.length - 1); directory = folders.join("/"); break; } if (variable == "personal-documents") { output = "/$currentDir : Permission denied."; break; } if (currentDir == "downloads") { output = "/$currentDir : Permission denied."; break; } if (contents[currentDir]!.contains(variable,)) { directory = directory + "/" + variable; currentDir = variable; } else { output = "cd: $variable: No such file or directory"; } break; case "mkdir": if(variable=="") { output = "usage: mkdir directory ..."; break; } if (textWords.length > 1) { for(String name in textOrg.split(" ")..removeAt(0)) ///Org text used for for Upper and Lower org cases Provider.of<Folders>(context, listen: false).createFolder(context, renaming: false, name: name); break; } Provider.of<Folders>(context, listen: false).createFolder(context, renaming: false, name: textOrg.split(" ")[1]); break; case "echo": output = textWords.join(" "); break; case "clear": ///Not working as of now. ///What went wrong: The textfield is not enabled after clearing. leaving the code below. // commandCards.clear(); // commandCards.add( // Column( // mainAxisAlignment: MainAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.start, // mainAxisSize: MainAxisSize.max, // children: [ // SizedBox( // height: 5, // ), // MBPText( // text: // "Last login: ${DateFormat("E LLL d HH:mm:ss").format(now)} on console", // color: Theme.of(context).cardColor.withOpacity(1), // fontFamily: "Menlo", // size: 10, // ), // ], // ), // ); output="Bug found!!! Submit an issue on GitHub."; break; case "exit": { directory="/~"; Provider.of<Apps>(context, listen: false).closeApp("terminal"); Provider.of<OnOff>(context, listen: false) .offTerminalFS(); Provider.of<OnOff>(context, listen: false).toggleTerminal(); } break; case "sudo": output = "\"With great power comes great responsibility.\" ~Peter Parker"; break; default: output = "Command '" + command + "' not found!\nTry something like: [ cd, ls, echo, clear, exit, mkdir]"; } } void _handleKeyEvent(RawKeyEvent event) { if (event.runtimeType == RawKeyDownEvent) { if (event.logicalKey == LogicalKeyboardKey.arrowUp) { setState(() { if (updownIndex < oldCommands.length) { updownIndex++; } commandTECs.last.text = oldCommands[oldCommands.length - updownIndex]; }); } else if (event.logicalKey == LogicalKeyboardKey.arrowDown) { setState(() { if (updownIndex > 1) { updownIndex--; } commandTECs.last.text = oldCommands[oldCommands.length - updownIndex]; }); } } } @override void initState() { position = widget.initPos; super.initState(); now = DateTime.now(); SchedulerBinding.instance.addPostFrameCallback((_) { setState(() { commandCards.add( Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ SizedBox( height: 5, ), MBPText( text: "Last login: ${DateFormat("E LLL d HH:mm:ss").format(now)} on console", color: Theme.of(context).cardColor.withOpacity(1), fontFamily: "Menlo", size: 10, ), ], ), ); commandCards.add(createCard()); }); }); Provider.of<AnalyticsService>(context, listen: false) .logCurrentScreen("Terminal"); } @override Widget build(BuildContext context) { WidgetsBinding.instance.addPostFrameCallback((_) => _scrollToBottom()); terminalFS = Provider.of<OnOff>(context).getTerminalFS; terminalPan = Provider.of<OnOff>(context).getTerminalPan; return AnimatedPositioned( duration: Duration(milliseconds: terminalPan ? 0 : 200), top: terminalFS ? 25 : position!.dy, left: terminalFS ? 0 : position!.dx, child: RawKeyboardListener( autofocus: true, focusNode: FocusNode(), onKey: _handleKeyEvent, child: terminalWindow(context)), ); } AnimatedContainer terminalWindow(BuildContext context) { String topApp = Provider.of<Apps>(context).getTop; return AnimatedContainer( duration: Duration(milliseconds: 200), width: terminalFS ? screenWidth(context, mulBy: 1) : screenWidth(context, mulBy: 0.4), height: terminalFS ? screenHeight(context, mulBy: 0.975) : screenHeight(context, mulBy: 0.5), decoration: BoxDecoration( border: Border.all( color: Colors.white.withOpacity(0.2), ), color: Theme.of(context).dialogBackgroundColor, borderRadius: BorderRadius.all(Radius.circular(10)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), spreadRadius: 10, blurRadius: 15, offset: Offset(0, 8), // changes position of shadow ), ], ), child: Stack( children: [ Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Stack( alignment: Alignment.centerRight, children: [ Container( height: terminalFS ? screenHeight(context, mulBy: 0.04) : screenHeight(context, mulBy: 0.04), decoration: BoxDecoration( color: Theme.of(context).disabledColor, borderRadius: BorderRadius.only( topRight: Radius.circular(10), topLeft: Radius.circular(10))), child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ MBPText( text: "chrisbin -- -zsh -- ${terminalFS ? screenWidth(context, mulBy: .1).floor() : screenWidth(context, mulBy: 0.04).floor()}x${terminalFS ? screenHeight(context, mulBy: 0.0966).floor() : screenHeight(context, mulBy: 0.05).floor()}", fontFamily: "HN", color: Theme.of(context).cardColor.withOpacity(1), weight: Theme.of(context).textTheme.headline4!.fontWeight, ) ], ), ), GestureDetector( onPanUpdate: (tapInfo) { if (!terminalFS) { setState(() { position = Offset(position!.dx + tapInfo.delta.dx, position!.dy + tapInfo.delta.dy); }); } }, onPanStart: (details) { Provider.of<OnOff>(context, listen: false).onTerminalPan(); }, onPanEnd: (details) { Provider.of<OnOff>(context, listen: false).offTerminalPan(); }, onDoubleTap: () { Provider.of<OnOff>(context, listen: false).toggleTerminalFS(); }, child: Container( alignment: Alignment.topRight, width: terminalFS ? screenWidth(context, mulBy: 0.95) : screenWidth(context, mulBy: 0.7), height: terminalFS ? screenHeight(context, mulBy: 0.04) : screenHeight(context, mulBy: 0.04), decoration: BoxDecoration( color: Colors.transparent, border: Border( bottom: BorderSide( color: Colors.black.withOpacity(0.9), width: 0.2))), ), ), Container( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.013), vertical: screenHeight(context, mulBy: 0.01)), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Row( children: [ InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.redAccent, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { directory="/~"; Provider.of<Apps>(context, listen: false).closeApp("terminal"); Provider.of<OnOff>(context, listen: false) .offTerminalFS(); Provider.of<OnOff>(context, listen: false).toggleTerminal(); }, ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( onTap: (){ Provider.of<OnOff>(context, listen: false).toggleTerminal(); Provider.of<OnOff>(context, listen: false).offTerminalFS(); }, child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.amber, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.green, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<OnOff>(context, listen: false) .toggleTerminalFS(); }, ) ], ), ], ), ), ], ), Expanded( child: ClipRRect( borderRadius: BorderRadius.only( bottomRight: Radius.circular(10), bottomLeft: Radius.circular(10)), child: Container( height: screenHeight(context, mulBy: 0.14), width: screenWidth( context, ), padding: EdgeInsets.only(left: 6, right: 6, bottom: 5), decoration: BoxDecoration( color: Theme.of(context).dialogBackgroundColor, ), child: ListView.builder( controller: _scrollController, shrinkWrap: true, itemCount: commandCards.length, itemBuilder: (BuildContext context, int index) { return commandCards[index]; }, ), ), ), ), ], ), Visibility( visible: topApp != "Terminal", child: InkWell( onTap: (){ Provider.of<Apps>(context, listen: false) .bringToTop(ObjectKey("terminal")); }, child: Container( width: screenWidth(context,), height: screenHeight(context,), color: Colors.transparent, ), ), ), ], ), ); } } class TerminalCommand extends StatefulWidget { final TextEditingController? commandController; final VoidCallback? onSubmit; TerminalCommand({Key? key, this.commandController, this.onSubmit}) : super(key: key); @override _TerminalCommandState createState() => _TerminalCommandState(); } class _TerminalCommandState extends State<TerminalCommand> { bool submit = false; final dir = directory.substring(directory.lastIndexOf("/") + 1).capitalize(); @override Widget build(BuildContext context) { return Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ SizedBox( height: 2, ), Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, textBaseline: TextBaseline.alphabetic, children: [ MBPText( text: "guest@Chrisbins-MacBook-Pro $dir %", color: Theme.of(context).cardColor.withOpacity(1), fontFamily: "Menlo", size: 10, ), Expanded( child: Container( height: 9, child: Theme( data: ThemeData( textSelectionTheme: TextSelectionThemeData( cursorColor: Color(0xff9d9d9d), ), ), child: TextField( autofocus: true, enabled: !submit, cursorWidth: 8, cursorHeight: 17, controller: widget.commandController, onSubmitted: (text) { setState(() { submit = true; }); widget.onSubmit!(); }, style: TextStyle( color: Theme.of(context).cardColor.withOpacity(1), fontFamily: "Menlo", fontSize: 10, fontWeight: Theme.of(context).textTheme.headline4!.fontWeight // height: 1, ), decoration: new InputDecoration( border: InputBorder.none, focusedBorder: InputBorder.none, enabledBorder: InputBorder.none, errorBorder: InputBorder.none, disabledBorder: InputBorder.none, contentPadding: EdgeInsets.only(left: 8, top: 10, bottom: 16)), ), ), ), ), ], ), SizedBox( height: 2, ), Visibility( visible: submit && output.trim() != "", child: SelectableText( output, showCursor: false, style: TextStyle( color: Theme.of(context).cardColor.withOpacity(1), fontFamily: "Menlo", fontSize: 10, fontWeight: Theme.of(context).textTheme.headline4!.fontWeight), ), ), ], ); } }
0
mirrored_repositories/chrishub/lib/apps
mirrored_repositories/chrishub/lib/apps/terminal/commands.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/scheduler.dart'; import 'package:provider/provider.dart'; import '../../system/componentsOnOff.dart'; class Commands{ var oldCommands = <String>[""]; } Commands? commands;
0
mirrored_repositories/chrishub/lib/apps
mirrored_repositories/chrishub/lib/apps/feedback/firebase.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:mac_dt/apps/feedback/model.dart'; class DataBase{ Stream<QuerySnapshot> getFeedback() { return FirebaseFirestore.instance .collection("Feedback") .where("type", isEqualTo: "Issue") .orderBy("time", descending: true) .snapshots(); } Future<bool> addFeedback( {required FeedbackForm feedbackForm})async { return await FirebaseFirestore.instance .collection("Feedback") .add(feedbackForm.toJson()).then((value) { return true; }).catchError((e){ return false; }); } }
0
mirrored_repositories/chrishub/lib/apps
mirrored_repositories/chrishub/lib/apps/feedback/controller.dart
import 'dart:convert' as convert; import 'package:http/http.dart' as http; import 'model.dart'; /// FormController is a class which does work of saving FeedbackForm in Google Sheets using /// HTTP GET request on Google App Script Web URL and parses response and sends result callback. class FormController { // Google App Script Web URL. static const String URL = "https://script.google.com/macros/s/AKfycbzB1TDVgMXVJIT5xszTv9W729aEIxhmFYiGh1CgKPDuRfJLi8oTqV54038EbzThtVfp7Q/exec"; //static const String URL = "https://script.google.com/macros/s/AKfycbyAaNh-1JK5pSrUnJ34Scp3889mTMuFI86DkDp42EkWiSOOycE/exec"; // Success Status Message static const STATUS_SUCCESS = "SUCCESS"; /// Async function which saves feedback, parses [feedbackForm] parameters /// and sends HTTP GET request on [URL]. On successful response, [callback] is called. void submitForm( FeedbackForm feedbackForm, void Function(String?) callback) async { try { await http.post(Uri.parse(URL), body: feedbackForm.toJson()).then((response) async { if (response.statusCode == 302) { var url = response.headers['location']!; await http.get(Uri.parse(url)).then((response) { callback(convert.jsonDecode(response.body)['status']); }); } else { callback(convert.jsonDecode(response.body)['status']); } }); } catch (e) { print(e); } } /// Async function which loads feedback from endpoint URL and returns List. Future<List<FeedbackForm>> getFeedbackList() async { return await http.get(Uri.parse(URL)).then((response) { var jsonFeedback = convert.jsonDecode(response.body) as List; return jsonFeedback.map((json) => FeedbackForm.fromJson(json)).toList(); }); } }
0
mirrored_repositories/chrishub/lib/apps
mirrored_repositories/chrishub/lib/apps/feedback/feedback.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:intl/intl.dart'; import 'package:mac_dt/system/componentsOnOff.dart'; import 'package:mac_dt/theme/theme.dart'; import 'package:provider/provider.dart'; import '../../data/analytics.dart'; import '../../system/openApps.dart'; import '../../sizes.dart'; import '../../widgets.dart'; import 'dart:html' as html; import 'dart:ui' as ui; import 'controller.dart'; import 'firebase.dart'; import 'model.dart'; //TODO Theming of feedback class FeedBack extends StatefulWidget { final Offset? initPos; const FeedBack({this.initPos, Key? key}) : super(key: key); @override _FeedBackState createState() => _FeedBackState(); } class _FeedBackState extends State<FeedBack> { Offset? position = Offset(0.0, 0.0); late bool feedbackFS; late bool feedbackPan; late bool feedbackOpen; bool error = true; bool valAni = false; bool valid = false; int submit = 3; bool reportIssue = true; DataBase dataBase =DataBase(); late Stream<QuerySnapshot> feedback; /// 0=submitting, 1=success, 2=error, 3= free state bool submitShow = false; final _formKey = GlobalKey<FormState>(); TextEditingController? nameController; TextEditingController? emailController; TextEditingController? mobileNoController; TextEditingController? feedbackController; String type = "Feedback"; FeedbackForm? feedbackItem= FeedbackForm("", "email", "mobileNo", "type", "feedback", DateTime(0), key: ObjectKey("fresh")); ScrollController scrollController = new ScrollController(); void _submitForm() { if (nameController!.text.isNotEmpty && emailController!.text.contains("@") && (mobileNoController!.text.isEmpty || (mobileNoController!.text.length >= 10 && int.tryParse(mobileNoController!.text) != null)) && type.isNotEmpty && feedbackController!.text.isNotEmpty) { valid = true; } _formKey.currentState!.validate(); if (valid) { /// If the form is valid, proceed. FeedbackForm feedbackForm = FeedbackForm( nameController!.text, emailController!.text, mobileNoController!.text, type, feedbackController!.text, DateTime.now(), ); FormController formController = FormController(); setState(() { submitShow = true; submit = 0; }); dataBase.addFeedback(feedbackForm: feedbackForm).then((success) { if (success) { setState(() { submit = 1; nameController!.clear(); emailController!.clear(); mobileNoController!.clear(); feedbackController!.clear(); }); } else { setState(() { submit = 2; }); } }); valid = false; } } @override void initState() { super.initState(); position = widget.initPos; nameController = TextEditingController(); emailController = TextEditingController(); mobileNoController = TextEditingController(); feedbackController = TextEditingController(); feedback=dataBase.getFeedback(); Provider.of<AnalyticsService>(context, listen: false) .logCurrentScreen("Feedback"); } @override Widget build(BuildContext context) { feedbackOpen = Provider.of<OnOff>(context).getFeedBack; feedbackFS = Provider.of<OnOff>(context).getFeedBackFS; feedbackPan = Provider.of<OnOff>(context).getFeedBackPan; return feedbackOpen ? AnimatedPositioned( duration: Duration(milliseconds: feedbackPan ? 0 : 200), top: feedbackFS ? screenHeight(context, mulBy: 0.0335) : position!.dy, left: feedbackFS ? 0 : position!.dx, child: feedbackWindow(context), ) : Nothing(); } AnimatedContainer feedbackWindow(BuildContext context) { String topApp = Provider.of<Apps>(context).getTop; return AnimatedContainer( duration: Duration(milliseconds: 200), width: feedbackFS ? screenWidth(context, mulBy: 1) : screenWidth(context, mulBy: 0.58), height: feedbackFS ?screenHeight(context, mulBy: 0.966) : screenHeight(context, mulBy: 0.7), decoration: BoxDecoration( border: Border.all( color: Colors.white.withOpacity(0.2), ), borderRadius: BorderRadius.all(Radius.circular(10)), color: Theme.of(context).dialogBackgroundColor, boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), spreadRadius: 10, blurRadius: 15, offset: Offset(0, 8), // changes position of shadow ), ], ), child: Stack( alignment: Alignment.topCenter, children: [ Row( children: [ Expanded( child: ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(10), bottomLeft: Radius.circular(10), ), child: AnimatedContainer( duration: Duration(milliseconds: 200), //width: screenWidth(context, mulBy: feedbackFS ? .5 : .35), decoration: BoxDecoration( color: Theme.of(context).dialogBackgroundColor, border: Border( right: BorderSide( color: Theme.of(context) .cardColor .withOpacity(0.3), width: 0.6))), padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.025), vertical: screenHeight(context, mulBy: 0.05)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: screenHeight(context, mulBy: 0.07), ), InkWell( onTap: () { setState(() { reportIssue=true; feedbackItem= FeedbackForm("", "email", "mobileNo", "type", "feedback", DateTime(0), key: ObjectKey("fresh")); }); }, child: Container( decoration: new BoxDecoration( gradient: new LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ Theme.of(context).colorScheme.secondary ,Theme.of(context).colorScheme.background, ], ), borderRadius: BorderRadius.circular(7)), width: 1200, height: 30, child: MBPText( text: "Feedback & Report Issues", size: 11, color: Colors.white, ), ), ), SizedBox( height: screenHeight(context, mulBy: 0.05), ), MBPText( text: "Recent Issues Reported", size: 18, fontFamily: "HN", weight: FontWeight.w600, color: Theme.of(context).cardColor.withOpacity(1), ), SizedBox( height: screenHeight(context, mulBy: 0.015), ), Expanded( child: AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context), height: screenHeight(context), decoration: BoxDecoration( border: Border.all( color: Theme.of(context).cardColor.withOpacity(0.5), ), borderRadius: BorderRadius.all(Radius.circular(10)), color: Theme.of(context).colorScheme.background, ), child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(10)), child: StreamBuilder<QuerySnapshot>( stream: feedback, builder: (context, snapshot) { if (snapshot.hasData) { return ListView.builder( physics: BouncingScrollPhysics(), controller: scrollController, itemCount: snapshot.data?.docs.length, itemBuilder: (context, index) { return InkWell( onTap: () { setState(() { feedbackItem = FeedbackForm.fromSnapshot(snapshot.data?.docs[index]); reportIssue = false; }); }, child: AnimatedContainer( duration: Duration(milliseconds: 200), height: screenHeight(context, mulBy: 0.065), padding: EdgeInsets.only( left: screenWidth(context, mulBy: 0.013), right: screenWidth(context, mulBy: 0.008)), decoration: BoxDecoration( color: index % 2 == 0 ? Theme.of(context).colorScheme.secondary : Theme.of(context).colorScheme.background, border: Border.all( color: feedbackItem!.key==ObjectKey(snapshot.data?.docs[index].id)?Color(0xffb558e1):Colors.transparent, width: 2 ) ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "${snapshot.data?.docs[index]["name"]}", style: TextStyle( color: Theme.of(context) .cardColor .withOpacity(1), fontSize: 13, fontFamily: 'HN', fontWeight: FontWeight.w500), overflow: TextOverflow.fade, maxLines: 1, softWrap: false, ), Text( snapshot.data?.docs[index]["feedback"], style: TextStyle( color: Theme.of(context) .cardColor .withOpacity(1), fontSize: 10, fontFamily: 'HN', fontWeight: FontWeight.w300), overflow: TextOverflow.fade, maxLines: 1, softWrap: false, ), ], ), ), ); }, ); } return Theme( data: ThemeData( cupertinoOverrideTheme: CupertinoThemeData( brightness: Brightness.dark)), child: CupertinoActivityIndicator()); }, ), ), ), ), ], ), ), ), ), ClipRRect( borderRadius: BorderRadius.only( topRight: Radius.circular(10), bottomRight: Radius.circular(10), ), child: Stack( children: [ AnimatedContainer( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.02), vertical: screenHeight(context, mulBy: 0.05)), duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: feedbackFS ? .75 : .41), decoration: BoxDecoration( color: Theme.of(context).dialogBackgroundColor, ), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ AnimatedContainer( duration: Duration(milliseconds: 200), height: screenHeight(context, mulBy: feedbackFS ? 0.40 : .25), child: Column( children: [ Image.asset( "assets/apps/feedback.png", height: 100, // width: 30, ), MBPText( text: "Chrisbin's MacBook Pro Feedback", size: 25, color: Theme.of(context) .cardColor .withOpacity(1), ), ], ), ), reportIssue ? AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: feedbackFS ? 0.5 : 0.35), child: Form( key: _formKey, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: 0.1675), height: screenHeight(context, mulBy: 0.042), //0.038 child: TextFormField( cursorHeight: 16, controller: nameController, validator: (value) { if (value!.isEmpty) { setState(() { error = false; valAni = true; }); } return null; }, textAlign: TextAlign.start, cursorColor: Theme.of(context) .cardColor .withOpacity(0.55), style: TextStyle( height: 1.5, color: Theme.of(context) .cardColor .withOpacity(1), fontFamily: "HN", fontWeight: FontWeight.w400, fontSize: 12, ), maxLines: 1, decoration: InputDecoration( isDense: true, filled: true, fillColor: Theme.of(context).colorScheme.error, contentPadding: EdgeInsets.symmetric( vertical: 8, horizontal: 15), hintText: "Name*", hintStyle: TextStyle( height: 1.5, color: Theme.of(context) .cardColor .withOpacity(0.4), fontFamily: "HN", fontWeight: FontWeight.w400, fontSize: 12, ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular( 10), borderSide: BorderSide( width: 2, color: Color( 0xffb558e1)), ), border: OutlineInputBorder( borderRadius: BorderRadius.circular( 10), borderSide: BorderSide(), )), ), ), AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: feedbackFS ? 0.06 : 0.015), ), AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: 0.1675), height: screenHeight(context, mulBy: 0.042), //0.038 child: TextFormField( cursorHeight: 16, controller: emailController, validator: (value) { if (!value!.contains("@")) { setState(() { error = false; valAni = true; }); } return null; }, textAlign: TextAlign.start, cursorColor: Theme.of(context) .cardColor .withOpacity(0.55), style: TextStyle( height: 1.5, color: Theme.of(context) .cardColor .withOpacity(1), fontFamily: "HN", fontWeight: FontWeight.w400, fontSize: 12, ), maxLines: 1, decoration: InputDecoration( isDense: true, filled: true, fillColor: Theme.of(context).colorScheme.error, contentPadding: EdgeInsets.symmetric( vertical: 8, horizontal: 15), hintText: "Email ID*", hintStyle: TextStyle( height: 1.5, color: Theme.of(context) .cardColor .withOpacity(0.4), fontFamily: "HN", fontWeight: FontWeight.w400, fontSize: 12, ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular( 10), borderSide: BorderSide( width: 2, color: Color( 0xffb558e1)), ), border: OutlineInputBorder( borderRadius: BorderRadius.circular( 10), borderSide: BorderSide(), )), ), ), ], ), SizedBox( height: screenHeight(context, mulBy: 0.025), ), Row( children: [ AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: 0.19), height: screenHeight(context, mulBy: 0.042), //0.038 child: TextFormField( cursorHeight: 16, controller: mobileNoController, validator: (value) { if (value!.isNotEmpty && value.length < 10 && int.tryParse(value) == null) setState(() { error = false; valAni = true; }); return null; }, textAlign: TextAlign.start, cursorColor: Theme.of(context) .cardColor .withOpacity(0.55), style: TextStyle( height: 1.5, color: Theme.of(context) .cardColor .withOpacity(1), fontFamily: "HN", fontWeight: FontWeight.w400, fontSize: 12, ), maxLines: 1, decoration: InputDecoration( isDense: true, filled: true, fillColor: Theme.of(context).colorScheme.error, contentPadding: EdgeInsets.symmetric( vertical: 8, horizontal: 15), hintText: "Mobile Number", hintStyle: TextStyle( height: 1.5, color: Theme.of(context) .cardColor .withOpacity(0.4), fontFamily: "HN", fontWeight: FontWeight.w400, fontSize: 12, ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular( 10), borderSide: BorderSide( width: 2, color: Color( 0xffb558e1)), ), border: OutlineInputBorder( borderRadius: BorderRadius.circular( 10), borderSide: BorderSide(), )), ), ), AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: feedbackFS ? 0.06 : 0.02), ), Row( children: [ MBPText( text: "Type: ", size: 12, color: Theme.of(context) .cardColor .withOpacity(0.85), ), InkWell( onTap: () { setState(() { type = "Feedback"; }); }, child: Row( children: [ Container( height: 14, width: 14, margin: EdgeInsets.zero, padding: EdgeInsets.zero, decoration: BoxDecoration( color: Colors.white, shape: BoxShape.circle, border: (type != "Feedback") ? Border.all( color: Colors .black) : Border.all( width: 4, color: Colors .blue), ), ), MBPText( text: " Feedback", size: 12, color: Theme.of(context) .cardColor .withOpacity(0.75), ), ], ), ), SizedBox( width: screenWidth(context, mulBy: 0.015), ), InkWell( onTap: () { setState(() { type = "Issue"; }); }, child: Row( children: [ Container( height: 14, width: 14, margin: EdgeInsets.zero, padding: EdgeInsets.zero, decoration: BoxDecoration( color: Colors.white, shape: BoxShape.circle, border: (type != "Issue") ? Border.all( color: Colors .black) : Border.all( width: 4, color: Colors .blue), ), ), MBPText( text: " Issues", size: 12, color: Theme.of(context) .cardColor .withOpacity(0.75), ), ], ), ), ], ) ], ), SizedBox( height: screenHeight(context, mulBy: 0.025), ), AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: 0.35), height: screenHeight(context, mulBy: 0.13), //0.038 child: TextFormField( cursorHeight: 16, controller: feedbackController, textAlign: TextAlign.start, validator: (value) { if (value!.isEmpty) { setState(() { error = false; valAni = true; }); } return null; }, cursorColor: Theme.of(context) .cardColor .withOpacity(0.55), style: TextStyle( height: 1.5, color: Theme.of(context) .cardColor .withOpacity(1), fontFamily: "HN", fontWeight: FontWeight.w400, fontSize: 12, ), maxLines: 6, decoration: InputDecoration( isDense: true, filled: true, fillColor: Theme.of(context).colorScheme.error, contentPadding: EdgeInsets.symmetric( vertical: 8, horizontal: 15), hintText: "$type*", hintStyle: TextStyle( height: 1.5, color: Theme.of(context) .cardColor .withOpacity(0.4), fontFamily: "HN", fontWeight: FontWeight.w400, fontSize: 12, ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: BorderSide( width: 2, color: Color(0xffb558e1)), ), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: BorderSide(), )), ), ), SizedBox( height: screenHeight(context, mulBy: 0.025), ), Align( alignment: Alignment.centerRight, child: InkWell( onTap: _submitForm, child: Container( decoration: new BoxDecoration( gradient: new LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ Color(0xffb558e1), Color(0xff7a3a9e), ], ), borderRadius: BorderRadius.circular(7)), width: 80, height: 30, child: MBPText( text: "Submit", size: 11, color: Colors.white, ), ), ), ) ], ), ), ) : AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: feedbackFS ? 0.5 : 0.35), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ MBPText( text: "Name:", size: 15, fontFamily: "HN", weight: FontWeight.w500, color: Theme.of(context) .cardColor .withOpacity(1), ), AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: 0.01), ), AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: 0.115), height: screenHeight(context, mulBy: 0.038), padding: EdgeInsets.only( left: screenWidth(context, mulBy: 0.015), right: screenWidth(context, mulBy: 0.015), top: screenHeight(context, mulBy: 0.011)), decoration: BoxDecoration( color: Theme.of(context).colorScheme.error, border: Border.all( color: Theme.of(context) .cardColor .withOpacity(0.5), width: 0.5), borderRadius: BorderRadius.circular(8)), child: Text( "${feedbackItem!.name}", style: TextStyle( fontSize: 12, fontFamily: "HN", fontWeight: FontWeight.w300, color: Theme.of(context) .cardColor .withOpacity(1), ), //maxLines: 6, ), ), AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: 0.03), ), MBPText( text: "Time:", size: 15, fontFamily: "HN", weight: FontWeight.w500, color: Theme.of(context) .cardColor .withOpacity(1), ), AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: 0.01), ), AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: 0.115), height: screenHeight(context, mulBy: 0.038), padding: EdgeInsets.only( left: screenWidth(context, mulBy: 0.015), right: screenWidth(context, mulBy: 0.015), top: screenHeight(context, mulBy: 0.011)), decoration: BoxDecoration( color: Theme.of(context).colorScheme.error, border: Border.all( color: Theme.of(context) .cardColor .withOpacity(0.5), width: 0.5), borderRadius: BorderRadius.circular(8)), child: Text( "${DateFormat('hh:mm a, MMMM dd yyyy').format(feedbackItem!.dateTime)}", style: TextStyle( fontSize: 12, fontFamily: "HN", fontWeight: FontWeight.w300, color: Theme.of(context) .cardColor .withOpacity(1), ), //maxLines: 6, ), ), ], ), AnimatedContainer( duration: Duration(milliseconds: 200), height: screenHeight(context, mulBy: 0.02), ), Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ MBPText( text: "Issue:", size: 15, fontFamily: "HN", weight: FontWeight.w500, color: Theme.of(context) .cardColor .withOpacity(1), ), AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: 0.013), ), AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: 0.295), height: screenHeight(context, mulBy: 0.13), //0.038 padding: EdgeInsets.only( left: screenWidth(context, mulBy: 0.015), right: screenWidth(context, mulBy: 0.015), ), decoration: BoxDecoration( color: Theme.of(context).colorScheme.error, border: Border.all( color: Theme.of(context) .cardColor .withOpacity(0.5), width: 0.5), borderRadius: BorderRadius.circular(10)), child: SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: screenHeight( context, mulBy: 0.02), ), Text( "${feedbackItem!.feedback}", style: TextStyle( fontSize: 12, fontFamily: "HN", fontWeight: FontWeight.w300, color: Theme.of(context) .cardColor .withOpacity(1), ), //maxLines: 6, ), SizedBox( height: screenHeight( context, mulBy: 0.01), ), ], ), ), ), ], ), AnimatedContainer( duration: Duration(milliseconds: 200), height: screenHeight(context, mulBy: 0.02), ), MBPText( text: "Create a Pull Request to fix this bug:", size: 14, fontFamily: "HN", weight: FontWeight.w400, color: Theme.of(context) .cardColor .withOpacity(1), ), Align( alignment: Alignment.bottomRight, child: InkWell( onTap: () { html.window.open( 'https://github.com/chrisbinsunny/chrishub/fork', 'new tab', ); }, child: Container( decoration: new BoxDecoration( gradient: new LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ Color(0xffb558e1), Color(0xff7a3a9e), ], ), borderRadius: BorderRadius.circular(7)), width: 120, height: 30, child: MBPText( text: "Fork Repository", size: 11, color: Colors.white, ), ), ), ), ], ), ), ], ), ), !error ? InkWell( onTap: () { setState(() { error = true; }); }, child: AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: feedbackFS ? .75 : .41), //height: screenHeight(context), color: Colors.transparent), ) : Container(), AnimatedPositioned( duration: Duration(milliseconds: valAni ? 400 : 200), left: screenWidth(context, mulBy: feedbackFS ? 0.284 : 0.125), top: error ? -(screenHeight(context, mulBy: 0.32)) : 0, child: AnimatedContainer( duration: Duration(milliseconds: 200), width: feedbackFS ? screenWidth(context, mulBy: 0.17) : screenWidth(context, mulBy: 0.16), height: feedbackFS ? screenHeight(context, mulBy: 0.32) : screenHeight(context, mulBy: 0.3), decoration: BoxDecoration( border: Border.all( color: Colors.white.withOpacity(0.2), ), borderRadius: BorderRadius.only( bottomRight: Radius.circular(10), bottomLeft: Radius.circular(10)), boxShadow: [ BoxShadow( color: !error ? Colors.black.withOpacity(0.2) : Colors.transparent, spreadRadius: 10, blurRadius: 15, offset: Offset(0, 8), // changes position of shadow ), ], ), child: ClipRRect( borderRadius: BorderRadius.only( bottomRight: Radius.circular(10), bottomLeft: Radius.circular(10)), child: BackdropFilter( filter: ui.ImageFilter.blur(sigmaX: 30.0, sigmaY: 30.0), child: Container( decoration: BoxDecoration( color: Theme.of(context) .dialogBackgroundColor .withOpacity(0.5), ), padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.02)), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( "assets/apps/feedback.png", height: 50, ), MBPText( text: "Value Error", color: Theme.of(context) .cardColor .withOpacity(1), size: 18, weight: FontWeight.w600, ), SizedBox( height: screenHeight(context, mulBy: 0.01), ), MBPText( text: "Please check the values\nyou entered.", color: Theme.of(context) .cardColor .withOpacity(1), size: 11.5, weight: FontWeight.w300, fontFamily: "HN", maxLines: 2, ), SizedBox( height: screenHeight(context, mulBy: 0.035), ), InkWell( onTap: () { setState(() { error = true; Future.delayed( Duration(milliseconds: 400), () { valAni = false; }); }); }, child: Container( decoration: new BoxDecoration( gradient: new LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ Color(0xff1473e8), Color(0xff0c4382), ], ), borderRadius: BorderRadius.circular(5)), width: 65, height: 23, child: MBPText( text: "Continue", size: 11, color: Colors.white, ), ), ), ], )), ), ), ), ), submitShow ? InkWell( onTap: () { if (submit == 2) { setState(() { submit = 3; submitShow = false; }); return; } if (submit == 1) { setState(() { submit = 3; submitShow = false; }); } }, child: AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: feedbackFS ? .75 : .41), //height: screenHeight(context), color: Colors.transparent), ) : Container(), AnimatedPositioned( duration: Duration(milliseconds: valAni ? 400 : 200), left: screenWidth(context, mulBy: feedbackFS ? 0.284 : 0.125), top: !submitShow ? -(screenHeight(context, mulBy: 0.32)) : 0, child: AnimatedContainer( duration: Duration(milliseconds: 200), width: feedbackFS ? screenWidth(context, mulBy: 0.17) : screenWidth(context, mulBy: 0.16), height: feedbackFS ? screenHeight(context, mulBy: 0.32) : screenHeight(context, mulBy: 0.3), decoration: BoxDecoration( border: Border.all( color: Colors.white.withOpacity(0.2), ), borderRadius: BorderRadius.only( bottomRight: Radius.circular(10), bottomLeft: Radius.circular(10)), boxShadow: [ BoxShadow( color: submitShow ? Colors.black.withOpacity(0.2) : Colors.transparent, spreadRadius: 10, blurRadius: 15, offset: Offset(0, 8), // changes position of shadow ), ], ), child: ClipRRect( borderRadius: BorderRadius.only( bottomRight: Radius.circular(10), bottomLeft: Radius.circular(10)), child: BackdropFilter( filter: ui.ImageFilter.blur(sigmaX: 30.0, sigmaY: 30.0), child: Container( decoration: BoxDecoration( color: Theme.of(context) .dialogBackgroundColor .withOpacity(0.5), ), padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.02)), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( "assets/apps/feedback.png", height: 50, ), MBPText( text: submit == 0 ? "Please Wait" : (submit == 1 ? "Submission Successful" : "Submission Error"), color: Theme.of(context) .cardColor .withOpacity(1), size: 18, weight: FontWeight.w600, ), SizedBox( height: screenHeight(context, mulBy: 0.01), ), MBPText( text: submit == 0 ? "Your $type is being\nsubmitted" : (submit == 1 ? "Your $type has been\nsuccessfully submitted" : "Could not submit your $type.\nPlease try again."), color: Theme.of(context) .cardColor .withOpacity(1), size: 11.5, weight: FontWeight.w300, fontFamily: "HN", maxLines: 2, ), SizedBox( height: screenHeight(context, mulBy: 0.035), ), submit > 0 ? InkWell( onTap: () { setState(() { submit = 3; submitShow = false; Future.delayed( Duration(milliseconds: 400), () { valAni = false; }); }); }, child: Container( decoration: new BoxDecoration( gradient: new LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ Color(0xff1473e8), Color(0xff0c4382), ], ), borderRadius: BorderRadius.circular(5)), width: 65, height: 23, child: MBPText( text: "Continue", size: 11, color: Colors.white, ), ), ) : Theme( data: ThemeData( cupertinoOverrideTheme: CupertinoThemeData( brightness: Brightness.dark)), child: CupertinoActivityIndicator()), ], )), ), ), ), ), ], ), ), ], ), GestureDetector( onPanUpdate: (tapInfo) { if (!feedbackFS) { setState(() { position = Offset(position!.dx + tapInfo.delta.dx, position!.dy + tapInfo.delta.dy); }); } }, onPanStart: (details) { Provider.of<OnOff>(context, listen: false).onFeedBackPan(); }, onPanEnd: (details) { Provider.of<OnOff>(context, listen: false).offFeedBackPan(); }, onDoubleTap: () { valAni = false; Provider.of<OnOff>(context, listen: false).toggleFeedBackFS(); }, child: Container( alignment: Alignment.topRight, width: feedbackFS ? screenWidth(context, mulBy: 0.95) : screenWidth(context, mulBy: 0.7), height: feedbackFS ? screenHeight(context, mulBy: 0.059) : screenHeight(context, mulBy: 0.06), decoration: BoxDecoration( color: Colors.transparent, ), ), ), Container( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.013), vertical: screenHeight(context, mulBy: 0.02)), child: Row( children: [ InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.redAccent, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<OnOff>(context, listen: false).toggleFeedBack(); Provider.of<OnOff>(context, listen: false).offFeedBackFS(); Provider.of<Apps>(context, listen: false).closeApp("feedback"); }, ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( onTap: (){ Provider.of<OnOff>(context, listen: false).toggleFeedBack(); Provider.of<OnOff>(context, listen: false).offFeedBackFS(); }, child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.amber, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.green, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { valAni = false; Provider.of<OnOff>(context, listen: false) .toggleFeedBackFS(); }, ) ], ), ), Visibility( visible: topApp != "Feedback", child: InkWell( onTap: (){ Provider.of<Apps>(context, listen: false) .bringToTop(ObjectKey("feedback")); }, child: Container( width: screenWidth(context,), height: screenHeight(context,), color: Colors.transparent, ), ), ), ], ), ); } }
0
mirrored_repositories/chrishub/lib/apps
mirrored_repositories/chrishub/lib/apps/feedback/model.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; class FeedbackForm { String name; String email; String mobileNo; String type; String feedback; DateTime dateTime; Key? key; FeedbackForm(this.name, this.email, this.mobileNo, this.type, this.feedback, this.dateTime, {this.key}); factory FeedbackForm.fromJson(dynamic json) { return FeedbackForm( "${json['name']}", "${json['email']}", "${json['mobileNo']}", "${json['type']}", "${json['feedback']}", json['dateTime']); } // Method to make GET parameters. Map<String, dynamic> toJson() => { 'name': name, 'email': email, 'number': mobileNo, 'type': type, 'feedback': feedback, 'time': dateTime }; factory FeedbackForm.fromSnapshot(QueryDocumentSnapshot? snapshot) { return FeedbackForm( "${snapshot!['name']}", "${snapshot['email']}", "${snapshot['number']}", "${snapshot['type']}", "${snapshot['feedback']}", snapshot['time'].toDate(), key: ObjectKey(snapshot.id) ); } }
0
mirrored_repositories/chrishub/lib/apps
mirrored_repositories/chrishub/lib/apps/messages/chat_bubble.dart
import 'package:flutter/material.dart'; import 'clipper.dart'; import 'types.dart'; class ChatBubble extends StatelessWidget { final CustomClipper? clipper; final Widget? child; final EdgeInsetsGeometry? margin; final double? elevation; final Color? backGroundColor; final Color? shadowColor; final Alignment? alignment; final EdgeInsetsGeometry? padding; ChatBubble({ this.clipper, this.child, this.margin, this.elevation, this.backGroundColor, this.shadowColor, this.alignment, this.padding }); @override Widget build(BuildContext context) { return Container( alignment: alignment ?? Alignment.topLeft, margin: margin ?? EdgeInsets.all(0), child: PhysicalShape( clipper: clipper as CustomClipper<Path>, color: backGroundColor ?? Colors.blue, child: Padding( padding: padding ?? setPadding(), child: child ?? Container(), ), ), ); } EdgeInsets setPadding() { if (clipper is iMessageClipper) { if ((clipper as iMessageClipper).type == BubbleType.sendBubble) { return EdgeInsets.only(top: 6, bottom: 6, left: 10, right: 16); } else { return EdgeInsets.only(top: 6, bottom: 6, left: 16, right: 10); } } return EdgeInsets.all(10); } }
0
mirrored_repositories/chrishub/lib/apps
mirrored_repositories/chrishub/lib/apps/messages/messages.dart
import 'dart:convert'; import 'dart:ui'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:intl/intl.dart'; import 'package:mac_dt/apps/messages/clipper.dart'; import 'package:mac_dt/apps/messages/types.dart'; import 'package:mac_dt/system/componentsOnOff.dart'; import 'package:provider/provider.dart'; import '../../../system/openApps.dart'; import '../../../sizes.dart'; import '../../../widgets.dart'; import '../../data/analytics.dart'; import '../../theme/theme.dart'; import 'chat_bubble.dart'; import 'dart:html' as html; class Messages extends StatefulWidget { final Offset? initPos; const Messages({this.initPos, Key? key}) : super(key: key); @override _MessagesState createState() => _MessagesState(); } class _MessagesState extends State<Messages> { Offset? position = Offset(0.0, 0.0); late bool messagesFS; late bool messagesPan; Future? messageRecords; ScrollController chatScrollController = new ScrollController(); ScrollController nameScrollController = new ScrollController(); int? selectedChatIndex; late bool info; MessageContent? selectedChat= new MessageContent( ); Future<List<MessageContent>?> readMessages() async { var data = json .decode(await rootBundle.loadString('assets/messages/messageLog.json')); return data .map<MessageContent>((json) => MessageContent.fromJson(json)) .toList(); } @override void initState() { position = widget.initPos; messageRecords = readMessages(); selectedChatIndex = 0; info= false; Provider.of<AnalyticsService>(context, listen: false) .logCurrentScreen("Messages"); super.initState(); } @override Widget build(BuildContext context) { var messagesOpen = Provider.of<OnOff>(context).getMessages; messagesFS = Provider.of<OnOff>(context).getMessagesFS; messagesPan = Provider.of<OnOff>(context).getMessagesPan; return messagesOpen ? AnimatedPositioned( duration: Duration(milliseconds: messagesPan ? 0 : 200), top: messagesFS ? 25 : position!.dy, left: messagesFS ? 0 : position!.dx, child: messagesWindow(context), ) : Nothing(); } AnimatedContainer messagesWindow(BuildContext context) { String topApp = Provider.of<Apps>(context).getTop; var reversedIndex; return AnimatedContainer( duration: Duration(milliseconds: 200), width: messagesFS ? screenWidth(context, mulBy: 1) : screenWidth(context, mulBy: 0.47), height: messagesFS ? screenHeight(context, mulBy: 0.975) : screenHeight(context, mulBy: 0.57), decoration: BoxDecoration( border: Border.all( color: Colors.white.withOpacity(0.2), ), borderRadius: BorderRadius.all(Radius.circular(10)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), spreadRadius: 10, blurRadius: 15, offset: Offset(0, 8), // changes position of shadow ), ], ), child: Stack( alignment: Alignment.topRight, clipBehavior: Clip.none, children: [ Row( children: [ ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(10), bottomLeft: Radius.circular(10)), child: BackdropFilter( filter: ImageFilter.blur(sigmaX: 70.0, sigmaY: 70.0), child: Container( padding: EdgeInsets.only( left: screenWidth(context, mulBy: 0.005), right: screenWidth(context, mulBy: 0.005), top: screenHeight(context, mulBy: 0.025)), height: screenHeight(context), width: screenWidth(context, mulBy: 0.17), decoration: BoxDecoration( color: Theme.of(context).hintColor, borderRadius: BorderRadius.only( topLeft: Radius.circular(10), bottomLeft: Radius.circular(10)), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.008), ), child: Row( children: [ InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.redAccent, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<OnOff>(context, listen: false) .offMessagesFS(); Provider.of<Apps>(context, listen: false) .closeApp("messages"); Provider.of<OnOff>(context, listen: false) .toggleMessages(); }, ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( onTap: () { Provider.of<OnOff>(context, listen: false) .toggleFinder(); Provider.of<OnOff>(context, listen: false) .offFinderFS(); }, child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.amber, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), InkWell( child: Container( height: 11.5, width: 11.5, decoration: BoxDecoration( color: Colors.green, shape: BoxShape.circle, border: Border.all( color: Colors.black.withOpacity(0.2), ), ), ), onTap: () { Provider.of<OnOff>(context, listen: false) .toggleMessagesFS(); }, ) ], ), ), SizedBox( height: screenHeight(context, mulBy: 0.028), ), ///Search Box (Fake) Container( height: screenHeight(context, mulBy: 0.035), padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.005)), decoration: BoxDecoration( color: Theme.of(context).cardColor.withOpacity(0.07), borderRadius: BorderRadius.circular(7), border: Border.all( color: Theme.of(context) .cardColor .withOpacity(0.15), width: 0.5)), child: Row( children: [ Image.asset( "assets/icons/spotlight.png", height: 12, color: Theme.of(context) .cardColor .withOpacity(0.3), ), SizedBox( width: screenWidth(context, mulBy: 0.002), ), MBPText( text: "Search", color: Theme.of(context) .cardColor .withOpacity(0.3), fontFamily: 'HN') ], ), ), SizedBox( height: screenHeight(context, mulBy: 0.01), ), Expanded( child: FutureBuilder( future: messageRecords, builder: (context, snapshot) { if (snapshot.hasData) { if(selectedChat!.senderName=="A") selectedChat= snapshot.data[0]; return ListView.builder( physics: BouncingScrollPhysics(), itemCount: snapshot.data.length, controller: nameScrollController, itemBuilder: (context, index) { return InkWell( onTap: () { setState(() { selectedChatIndex = index; selectedChat= snapshot.data[index]; }); }, child: Column( children: [ Container( height: screenHeight(context, mulBy: 0.08), padding: EdgeInsets.only( left: screenWidth(context, mulBy: 0.01), right: screenWidth(context, mulBy: 0.008), ), decoration: BoxDecoration( borderRadius: BorderRadius.circular( 5), color: selectedChatIndex == index ? Color(0xff0b84ff) : Colors.transparent), child: Row( children: [ Container( decoration: BoxDecoration( shape: BoxShape.circle, gradient: new LinearGradient( colors: [ Color(0xff6d6d6d), Color(0xff484848) ], begin: const FractionalOffset( 0, 0), end: const FractionalOffset( 0, 1), stops: [0.0, 1.0], tileMode: TileMode.clamp), ), height: screenHeight( context, mulBy: 0.055), width: screenHeight( context, mulBy: 0.055), clipBehavior: Clip.antiAlias, child: (snapshot.data[index].senderPhoto=="")? Padding( padding: EdgeInsets.all( screenHeight(context, mulBy: 0.01)), child: MBPText( text: "${snapshot.data[index].senderName.toString().getInitials().capitalize()}", color: Colors.white, fontFamily: "SFR", size: 25, weight: FontWeight.w500, overflow: TextOverflow.fade, maxLines: 1, softWrap: false, ), ): Image.network( snapshot.data[index].senderPhoto, fit: BoxFit.cover, ), ), SizedBox( width: screenWidth( context, mulBy: 0.006), ), Column( mainAxisAlignment: MainAxisAlignment .spaceEvenly, crossAxisAlignment: CrossAxisAlignment .start, children: [ SizedBox( width: screenWidth(context, mulBy: 0.07), child: Text( "${snapshot.data[index].senderName}", style: TextStyle( color: Theme.of( context) .cardColor .withOpacity( 1), fontSize: 13, fontFamily: 'HN', fontWeight: FontWeight .w500), overflow: TextOverflow.fade, maxLines: 1, softWrap: false, ), ), SizedBox( width: screenWidth(context, mulBy: 0.07), child: Text( snapshot .data[index] .messages .sender .last, style: TextStyle( color: Theme.of( context) .cardColor .withOpacity( selectedChatIndex == index ? 1 : .6), fontSize: 11, fontFamily: 'HN', fontWeight: FontWeight .w400), overflow: TextOverflow.fade, maxLines: 1, softWrap: false, ), ), SizedBox( height: screenHeight( context, mulBy: 0.01), ) ], ), Spacer(), Align( alignment: Alignment.topCenter, child: Padding( padding: EdgeInsets.only(top: screenHeight(context, mulBy: 0.01),), child: MBPText( text: "${DateFormat("d/M/yy").format(DateTime.parse(snapshot.data[index].dates.last))}", color: Theme.of(context) .cardColor .withOpacity(0.6), fontFamily: "HN", size: 11.5, ), ), ), ], ), ), Align( child: Container( color: ((selectedChatIndex == index) || (selectedChatIndex! - 1 == index)) ? Colors.transparent : Theme.of(context) .cardColor .withOpacity(0.5), height: 0.3, width: screenWidth(context, mulBy: 0.15), ), alignment: Alignment.topRight, ) ], ), ); }, ); } return Theme( data: ThemeData( cupertinoOverrideTheme: CupertinoThemeData( brightness: Brightness.dark)), child: Center( child: CupertinoActivityIndicator())); }), ) ], ), ), ), ), FutureBuilder( future: messageRecords, builder: (context, snapshot) { if (snapshot.hasData) { return Expanded( child: ClipRRect( borderRadius: BorderRadius.only( topRight: Radius.circular(10), bottomRight: Radius.circular(10)), child: Container( decoration: BoxDecoration( color: Theme.of(context).errorColor.withOpacity(1), border: Border( left: BorderSide( color: Colors.black, width: 0.8)), ), child: Stack( alignment: Alignment.bottomCenter, children: [ Column( children: [ AnimatedContainer( duration: Duration(milliseconds: 200), height: screenHeight(context, mulBy: 0.07), width: double.infinity, padding: EdgeInsets.only( left: screenWidth(context, mulBy: 0.013), right: screenWidth(context, mulBy: messagesFS?0.088:0.013), //vertical: screenHeight(context, mulBy: 0.03) ), decoration: BoxDecoration( color: Provider.of<ThemeNotifier>(context).isDark()?Color(0xff3b393b):Color( 0xffdcdcdc), ), child: Row( children: [ MBPText( text: "To:", color: Color(0xff747374), fontFamily: "HN", weight: FontWeight.w500, size: 11, ), MBPText( text: " ${snapshot.data[selectedChatIndex].senderName}", color: Theme.of(context) .cardColor .withOpacity(1), fontFamily: 'HN', weight: FontWeight.w400, size: 12, ), Spacer(), ///The info screen on/off function has been moved to outer stack. Icon( CupertinoIcons.info, color: Color(0xff9b999b), size: 20, ), ], ), ), Expanded( child: Container( padding: EdgeInsets.symmetric(), decoration: BoxDecoration(), child: ScrollConfiguration( //TODO Scrollbar ///turned off scrollbar, coz of weird reverse scrollbar behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false ), child: ListView.builder( ///For viewing the last chat when the screen opens. Using index in reverse. reverse: snapshot.data[selectedChatIndex] .messages.sender.length > 7, padding: EdgeInsets.only( bottom: screenHeight(context, mulBy: 0.085), top: screenHeight(context, mulBy: 0.045), left: screenWidth(context, mulBy: 0.009), right: screenWidth(context, mulBy: 0.009), ), physics: BouncingScrollPhysics(), itemCount: snapshot.data[selectedChatIndex] .messages.sender.length, controller: chatScrollController, itemBuilder: (context, index) { if (snapshot.data[selectedChatIndex] .messages.sender.length > 7) reversedIndex = snapshot .data[selectedChatIndex] .messages .sender .length - 1 - index; else reversedIndex = index; return Column( children: [ if (snapshot.data[selectedChatIndex] .dateStops .contains(reversedIndex)) MBPText( text: "${DateFormat("EEE, d MMM, hh:mm a").format(DateTime.parse(snapshot.data[selectedChatIndex].dates[snapshot.data[selectedChatIndex].dateStops.indexOf(reversedIndex)]))}", color: Theme.of(context) .cardColor .withOpacity(0.6), fontFamily: "HN", size: 10, ), if(snapshot.data[selectedChatIndex].messages.sender[reversedIndex]!="") ChatBubble( clipper: iMessageClipper( type: BubbleType.receiverBubble), margin: EdgeInsets.only(top: 5), backGroundColor: Provider.of<ThemeNotifier>(context).isDark()?Color(0xff3b393b):Color( 0xffc5c5c5), child: Container( constraints: BoxConstraints( maxWidth: screenWidth( context, mulBy: 0.15), ), child: Text( "${snapshot.data[selectedChatIndex].messages.sender[reversedIndex]}", style: TextStyle( color: Theme.of(context).cardColor.withOpacity(1), fontFamily: 'HN', fontWeight: FontWeight.w400, fontSize: 12), ), ), ), if(snapshot.data[selectedChatIndex].messages.me[reversedIndex]!="") ChatBubble( clipper: iMessageClipper( type: BubbleType .sendBubble), alignment: Alignment.topRight, margin: EdgeInsets.only(top: 5), backGroundColor: Color(0xff1f8bff), child: Container( constraints: BoxConstraints( maxWidth: screenWidth( context, mulBy: 0.15), ), child: Text( "${snapshot.data[selectedChatIndex].messages.me[reversedIndex]}", style: TextStyle( color: Colors.white, fontFamily: 'HN', fontWeight: FontWeight.w400, fontSize: 12), ), ), ), ], ); }, ), ), ), ), ], ), ClipRect( child: BackdropFilter( filter: ImageFilter.blur( sigmaX: 15.0, sigmaY: 15.0, tileMode: TileMode.decal ), child: Container( height: screenHeight(context, mulBy: 0.055), width: double.infinity, decoration: BoxDecoration( color: Theme.of(context) .scaffoldBackgroundColor .withOpacity(0.5), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Image.asset( "assets/messages/store.png", height: 23, ), InkWell( //onTap: (){showAlertDialog(context);}, child: AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: messagesFS ? 0.73 : 0.23), height: screenHeight(context, mulBy: 0.032), padding: EdgeInsets.only( left: screenWidth(context, mulBy: 0.008), right: screenWidth(context, mulBy: 0.005)), decoration: BoxDecoration( color: Theme.of(context) .scaffoldBackgroundColor, borderRadius: BorderRadius.circular(50), border: Border.all( color: Theme.of(context) .cardColor .withOpacity(0.2))), child: Row( mainAxisAlignment: MainAxisAlignment .spaceBetween, children: [ Padding( padding: EdgeInsets.symmetric( vertical: screenHeight( context, mulBy: 0.0052), ), child: Text( "iMessage", style: TextStyle( color: Theme.of(context) .cardColor .withOpacity(0.2), fontFamily: 'HN', fontWeight: FontWeight.w400, fontSize: 12), ), ), Image.asset( "assets/messages/voice.png", height: 23, ), ], ), ), ), Image.asset( "assets/messages/emoji.png", height: 23, ), ], ), ), ), ), ], ), ), ), ); } return Theme( data: ThemeData( cupertinoOverrideTheme: CupertinoThemeData(brightness: Brightness.dark)), child: Expanded( child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.only( topRight: Radius.circular(10), bottomRight: Radius.circular(10)), color: Theme.of(context).scaffoldBackgroundColor, ), child: Center( child: CupertinoActivityIndicator())))); }, ) ], ), ///Info closer Visibility( visible: info, child: GestureDetector( onTap: () { setState(() { info=false; }); }, child: Container( width: screenWidth( context, ), height: screenHeight( context, ), color: Colors.transparent, ), ), ), ///Info Visibility( visible: info, child: Positioned( top: screenHeight(context, mulBy: 0.043), right: screenWidth(context, mulBy: messagesFS?0.005:-0.07), child: Stack( children: [ ClipPath( clipper: DetailsClipper(), child: BackdropFilter( filter: ImageFilter.blur( sigmaX: 25.0, sigmaY: 25.0), child: CustomPaint( size: Size(screenWidth(context, mulBy: 0.18),screenHeight(context, mulBy: .55)), painter: DetailsPainter(context, false), isComplex: true, ), ), ), CustomPaint( size: Size(screenWidth(context, mulBy: 0.18),screenHeight(context, mulBy: .55)), painter: DetailsPainter(context, true), isComplex: true, child: InkWell( onTap: () { html.window.open( selectedChat!.profileLink, 'new tab', ); }, child: Container( width: screenWidth(context, mulBy: 0.18), height: screenHeight(context, mulBy: .55), padding: EdgeInsets.symmetric( vertical: screenHeight(context, mulBy: .05), horizontal: screenWidth(context, mulBy: 0.02) ), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( decoration: BoxDecoration( shape: BoxShape.circle, gradient: new LinearGradient( colors: [ Color(0xff6d6d6d), Color(0xff484848) ], begin: const FractionalOffset( 0, 0), end: const FractionalOffset( 0, 1), stops: [0.0, 1.0], tileMode: TileMode.clamp), ), height: screenHeight( context, mulBy: 0.065), width: screenHeight( context, mulBy: 0.065), padding: EdgeInsets.all( screenHeight(context, mulBy: 0.012)), child: MBPText( text: "${selectedChat!.senderName.toString().getInitials().capitalize()}", color: Colors.white, fontFamily: "SFR", size: 25, weight: FontWeight.w500, overflow: TextOverflow.fade, maxLines: 1, softWrap: false, ), ), SizedBox( height: screenHeight(context, mulBy: .014), ), MBPText( text: "${selectedChat!.senderName.toString().capitalize()}", color: Theme.of(context).cardColor.withOpacity(1), fontFamily: "HN", size: 13, weight: Theme.of(context).textTheme.headline3!.fontWeight, overflow: TextOverflow.fade, maxLines: 1, softWrap: false, ), SizedBox( height: screenHeight(context, mulBy: .02), ), //TODO: BUG Found>> Right side of info screen wont work ///Track the issue at https://github.com/flutter/flutter/issues/19445 Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( children: [ Container( decoration: BoxDecoration( shape: BoxShape.circle, color: Color(0xff0b84ff), ), margin: EdgeInsets.symmetric( vertical: screenHeight( context, mulBy: 0.005), ), height: screenHeight( context, mulBy: 0.03), width: screenHeight( context, mulBy: 0.03), child: Center( child: Icon( CupertinoIcons.phone_solid, color: Colors.white, size: 12, ), ), ), Text( "call", overflow: TextOverflow.fade, maxLines: 1, softWrap: false, style: TextStyle( color: Color(0xff0b84ff), fontFamily: "HN", fontSize: 9, fontWeight: FontWeight.w400, ), ), ], ), Column( children: [ Container( decoration: BoxDecoration( shape: BoxShape.circle, color: Color(0xff0b84ff), ), margin: EdgeInsets.symmetric( vertical: screenHeight( context, mulBy: 0.005), ), height: screenHeight( context, mulBy: 0.03), width: screenHeight( context, mulBy: 0.03), child: Center( child: Icon( CupertinoIcons.person_crop_circle_fill, color: Colors.white, size: 14, ), ), ), Text( "info", overflow: TextOverflow.fade, maxLines: 1, softWrap: false, style: TextStyle( color: Color(0xff0b84ff), fontFamily: "HN", fontSize: 9, fontWeight: FontWeight.w400, ), ), ], ), Column( children: [ Container( decoration: BoxDecoration( shape: BoxShape.circle, color: Color(0xff0b84ff), ), margin: EdgeInsets.symmetric( vertical: screenHeight( context, mulBy: 0.005), ), height: screenHeight( context, mulBy: 0.03), width: screenHeight( context, mulBy: 0.03), child: Center( child: Icon( CupertinoIcons.videocam_fill, color: Colors.white, size: 15, ), ), ), Text( "video", overflow: TextOverflow.fade, maxLines: 1, softWrap: false, style: TextStyle( color: Color(0xff0b84ff), fontFamily: "HN", fontSize: 9, fontWeight: FontWeight.w400, ), ), ], ), Column( children: [ Container( decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.transparent, border: Border.all( color: Theme.of(context).cardColor.withOpacity(0.15) ) ), margin: EdgeInsets.symmetric( vertical: screenHeight( context, mulBy: 0.005), ), height: screenHeight( context, mulBy: 0.03), width: screenHeight( context, mulBy: 0.03), child: Center( child: Icon( CupertinoIcons.rectangle_fill_on_rectangle_fill, color: Theme.of(context).cardColor.withOpacity(0.15), size: 10, ), ), ), Text( "share", overflow: TextOverflow.fade, maxLines: 1, softWrap: false, style: TextStyle( color: Theme.of(context).cardColor.withOpacity(0.15), fontFamily: "HN", fontSize: 9, fontWeight: FontWeight.w400, ), ), ], ), Column( children: [ Container( decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.transparent, border: Border.all( color: Theme.of(context).cardColor.withOpacity(0.15) ) ), margin: EdgeInsets.symmetric( vertical: screenHeight( context, mulBy: 0.005), ), height: screenHeight( context, mulBy: 0.03), width: screenHeight( context, mulBy: 0.03), child: Center( child: Icon( CupertinoIcons.mail_solid, color: Theme.of(context).cardColor.withOpacity(0.15), size: 10, ), ), ), Text( "mail", overflow: TextOverflow.fade, maxLines: 1, softWrap: false, style: TextStyle( color: Theme.of(context).cardColor.withOpacity(0.15), fontFamily: "HN", fontSize: 9, fontWeight: FontWeight.w400, ), ), ], ), ], ), SizedBox( height: screenHeight(context, mulBy: .035), ), Align( alignment: Alignment.centerLeft, child: MBPText( text: "Send My Current Location", color: Color(0xff0b84ff), fontFamily: "HN", size: 10, weight: FontWeight.w500, overflow: TextOverflow.fade, maxLines: 1, softWrap: false, ), ), SizedBox( height: screenHeight(context, mulBy: .015), ), Container( color: Theme.of(context) .cardColor .withOpacity(0.5), height: 0.3, width: double.infinity), SizedBox( height: screenHeight(context, mulBy: .015), ), Align( alignment: Alignment.centerLeft, child: MBPText( text: "Share My Location", color: Color(0xff0b84ff), fontFamily: "HN", size: 10, weight: FontWeight.w500, overflow: TextOverflow.fade, maxLines: 1, softWrap: false, ), ), SizedBox( height: screenHeight(context, mulBy: .015), ), Container( color: Theme.of(context) .cardColor .withOpacity(0.5), height: 0.3, width: double.infinity), SizedBox( height: screenHeight(context, mulBy: .015), ), Align( alignment: Alignment.centerLeft, child: Text( "You are free to contact me anytime for business needs or enquiry about Chrisbin. Select info for more.", style: TextStyle( color: Theme.of(context).cardColor.withOpacity(0.5), fontFamily: "HN", fontSize: 9, fontWeight: FontWeight.w400, ), overflow: TextOverflow.fade, maxLines: 3, ), ), ], ), ), ), ), ], ), ), ), ///Drag around GestureDetector( onPanUpdate: (tapInfo) { if (!messagesFS) { setState(() { position = Offset(position!.dx + tapInfo.delta.dx, position!.dy + tapInfo.delta.dy); }); } }, onPanStart: (details) { Provider.of<OnOff>(context, listen: false).onMessagesPan(); }, onPanEnd: (details) { Provider.of<OnOff>(context, listen: false).offMessagesPan(); }, onDoubleTap: () { Provider.of<OnOff>(context, listen: false).toggleMessagesFS(); }, child: Container( alignment: Alignment.centerRight, width: messagesFS ? screenWidth(context, mulBy: 0.95) : screenWidth(context, mulBy: 0.42), height: screenHeight(context, mulBy: 0.04), color: Colors.transparent ), ), ///Open info Padding( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: messagesFS?0.088:0.013), ), child: InkWell( onTap: (){ setState(() { info=!info; }); }, child: Container( padding: EdgeInsets.all(10), height: screenHeight(context,mulBy: 0.06), width: screenWidth(context,mulBy: 0.027), ), ), ), ///Bring to top Visibility( visible: topApp != "Messages", child: GestureDetector( onTap: () { Provider.of<Apps>(context, listen: false) .bringToTop(ObjectKey("messages")); }, child: Container( width: screenWidth( context, ), height: screenHeight( context, ), color: Colors.transparent, ), ), ), ], ), ); } } class MessageContent { MainMessage? messages; String senderName; String senderPhoto; String profileLink; List<int>? dateStops; List<String>? dates; MessageContent( {this.messages, this.senderName="A", this.profileLink="A", this.senderPhoto="A", this.dates, this.dateStops}); factory MessageContent.fromJson(Map<String, dynamic> json) { return MessageContent( messages: MainMessage.fromJson(json["messages"]), senderName: json["senderName"].toString(), dateStops: List<int>.from(json["dateStops"]), dates: List<String>.from(json["dates"]), senderPhoto: json["senderPhoto"].toString(), profileLink: json["profileLink"].toString()); } } class MainMessage { List<String>? sender; List<String>? me; MainMessage({this.me, this.sender}); factory MainMessage.fromJson(Map<String, dynamic> json) { return MainMessage( me: List<String>.from(json["me"]), sender: List<String>.from(json["sender"])); } } class DetailsPainter extends CustomPainter{ BuildContext context; bool stroke; DetailsPainter(this.context,this.stroke); @override void paint(Canvas canvas, Size size) { Paint paint_0 = new Paint() ..color = Theme.of(context).cardColor.withOpacity(0.2) ..style = PaintingStyle.stroke ..strokeJoin= StrokeJoin.round ..strokeWidth = 1; Paint paint_1 = new Paint() ..color = Theme.of(context).errorColor ..style = PaintingStyle.fill ..strokeWidth = 1; Path path_0 = Path(); path_0.moveTo(size.width*0.0531250,size.height*0.0720000); path_0.quadraticBezierTo(size.width*0.0521250,size.height*0.0473000,size.width*0.0937500,size.height*0.0480000); path_0.quadraticBezierTo(size.width*0.3445313,size.height*0.0477600,size.width*0.4335938,size.height*0.0472600); path_0.cubicTo(size.width*0.4711250,size.height*0.0469400,size.width*0.4671875,size.height*0.0455800,size.width*0.4779063,size.height*0.0396200); path_0.quadraticBezierTo(size.width*0.4812812,size.height*0.0367000,size.width*0.4993750,size.height*0.0233600); path_0.quadraticBezierTo(size.width*0.5146875,size.height*0.0368000,size.width*0.5206250,size.height*0.0404000); path_0.cubicTo(size.width*0.5328125,size.height*0.0485000,size.width*0.5372500,size.height*0.0457400,size.width*0.5621875,size.height*0.0470000); path_0.cubicTo(size.width*0.6450781,size.height*0.0472500,size.width*0.8108594,size.height*0.0477500,size.width*0.8937500,size.height*0.0480000); path_0.quadraticBezierTo(size.width*0.9511875,size.height*0.0447200,size.width*0.9468750,size.height*0.0760000); path_0.quadraticBezierTo(size.width*0.9468750,size.height*0.7315000,size.width*0.9468750,size.height*0.9500000); path_0.quadraticBezierTo(size.width*0.9474687,size.height*0.9778600,size.width*0.9062500,size.height*0.9740000); path_0.quadraticBezierTo(size.width*0.2921875,size.height*0.9755000,size.width*0.0875000,size.height*0.9760000); path_0.quadraticBezierTo(size.width*0.0496562,size.height*0.9752400,size.width*0.0531250,size.height*0.9480000); path_0.quadraticBezierTo(size.width*0.0531250,size.height*0.7290000,size.width*0.0531250,size.height*0.0720000); path_0.close(); canvas.drawPath(path_0, stroke?paint_0:paint_1); } @override bool shouldRepaint(covariant CustomPainter oldDelegate) { return false; } } class DetailsClipper extends CustomClipper<Path> { DetailsClipper({this.borderRadius = 15}); final double borderRadius; @override Path getClip(Size size) { Path path_0 = Path(); path_0.moveTo(size.width*0.0531250,size.height*0.0720000); path_0.quadraticBezierTo(size.width*0.0521250,size.height*0.0473000,size.width*0.0937500,size.height*0.0480000); path_0.quadraticBezierTo(size.width*0.3445313,size.height*0.0477600,size.width*0.4335938,size.height*0.0472600); path_0.cubicTo(size.width*0.4711250,size.height*0.0469400,size.width*0.4671875,size.height*0.0455800,size.width*0.4779063,size.height*0.0396200); path_0.quadraticBezierTo(size.width*0.4812812,size.height*0.0367000,size.width*0.4993750,size.height*0.0233600); path_0.quadraticBezierTo(size.width*0.5146875,size.height*0.0368000,size.width*0.5206250,size.height*0.0404000); path_0.cubicTo(size.width*0.5328125,size.height*0.0485000,size.width*0.5372500,size.height*0.0457400,size.width*0.5621875,size.height*0.0470000); path_0.cubicTo(size.width*0.6450781,size.height*0.0472500,size.width*0.8108594,size.height*0.0477500,size.width*0.8937500,size.height*0.0480000); path_0.quadraticBezierTo(size.width*0.9511875,size.height*0.0447200,size.width*0.9468750,size.height*0.0760000); path_0.quadraticBezierTo(size.width*0.9468750,size.height*0.7315000,size.width*0.9468750,size.height*0.9500000); path_0.quadraticBezierTo(size.width*0.9474687,size.height*0.9778600,size.width*0.9062500,size.height*0.9740000); path_0.quadraticBezierTo(size.width*0.2921875,size.height*0.9755000,size.width*0.0875000,size.height*0.9760000); path_0.quadraticBezierTo(size.width*0.0496562,size.height*0.9752400,size.width*0.0531250,size.height*0.9480000); path_0.quadraticBezierTo(size.width*0.0531250,size.height*0.7290000,size.width*0.0531250,size.height*0.0720000); path_0.close(); return path_0; } @override bool shouldReclip(CustomClipper<Path> oldClipper) => true; }
0
mirrored_repositories/chrishub/lib/apps
mirrored_repositories/chrishub/lib/apps/messages/types.dart
enum BubbleType { sendBubble, receiverBubble }
0
mirrored_repositories/chrishub/lib/apps
mirrored_repositories/chrishub/lib/apps/messages/clipper.dart
import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'types.dart'; class iMessageClipper extends CustomClipper<Path> { final BubbleType? type; final double radius; final double nipSize; iMessageClipper({this.type, this.radius = 13, this.nipSize = 4}); @override Path getClip(Size size) { var path = Path(); if (type == BubbleType.sendBubble) { path.moveTo(radius, 0); path.lineTo(size.width - radius - nipSize, 0); path.arcToPoint(Offset(size.width - nipSize, radius), radius: Radius.circular(radius)); path.lineTo(size.width - nipSize, size.height - nipSize); path.arcToPoint(Offset(size.width, size.height), radius: Radius.circular(nipSize), clockwise: false); path.arcToPoint(Offset(size.width - 2 * nipSize, size.height - nipSize), radius: Radius.circular(2 * nipSize)); path.arcToPoint(Offset(size.width - 4 * nipSize, size.height), radius: Radius.circular(2 * nipSize)); path.lineTo(radius, size.height); path.arcToPoint(Offset(0, size.height - radius), radius: Radius.circular(radius)); path.lineTo(0, radius); path.arcToPoint(Offset(radius, 0), radius: Radius.circular(radius)); } else { path.moveTo(radius, 0); path.lineTo(size.width - radius, 0); path.arcToPoint(Offset(size.width, radius), radius: Radius.circular(radius)); path.lineTo(size.width, size.height - radius); path.arcToPoint(Offset(size.width - radius, size.height), radius: Radius.circular(radius)); path.lineTo(4 * nipSize, size.height); path.arcToPoint(Offset(2 * nipSize, size.height - nipSize), radius: Radius.circular(2 * nipSize)); path.arcToPoint(Offset(0, size.height), radius: Radius.circular(2 * nipSize)); path.arcToPoint(Offset(nipSize, size.height - nipSize), radius: Radius.circular(nipSize), clockwise: false); path.lineTo(nipSize, radius); path.arcToPoint(Offset(radius + nipSize, 0), radius: Radius.circular(radius)); } return path; } @override bool shouldReclip(CustomClipper<Path> oldClipper) => false; }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/system/rightClickMenu.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:mac_dt/system/componentsOnOff.dart'; import 'package:mac_dt/system/folders/folders.dart'; import '../apps/systemPreferences.dart'; import '../providers.dart'; import '../theme/theme.dart'; import 'package:provider/provider.dart'; import 'openApps.dart'; import '../../sizes.dart'; import '../../widgets.dart'; import 'dart:html' as html; import 'dart:ui' as ui; class RightClick extends StatefulWidget { final Offset? initPos; const RightClick({this.initPos, Key? key}) : super(key: key); @override _RightClickState createState() => _RightClickState(); } class _RightClickState extends State<RightClick> { Offset? position = Offset(0.0, 0.0); late var themeNotifier; Offset QFinder(){ Offset? offset=new Offset(0, 0); if(widget.initPos!.dx+screenWidth(context, mulBy: 0.15)+1>=screenWidth(context)) { if(widget.initPos!.dy+screenHeight(context, mulBy: 0.3)+1>=screenHeight(context)) { offset = widget.initPos! - Offset(screenWidth(context, mulBy: 0.15) + 1, 0); offset = Offset(offset.dx, screenHeight(context, mulBy: 0.7) - 1); } else offset=widget.initPos!-Offset(screenWidth(context, mulBy: 0.15)+1,0); } else{ if(widget.initPos!.dy+screenHeight(context, mulBy: 0.3)+1>=screenHeight(context)) { offset = Offset(widget.initPos!.dx, screenHeight(context, mulBy: 0.7) - 1); } else offset=widget.initPos; } return offset!; } @override void initState() { position = widget.initPos; super.initState(); } @override Widget build(BuildContext context) { var rcmOpen = Provider.of<OnOff>(context).getRCM; themeNotifier = Provider.of<ThemeNotifier>(context); return Visibility( visible: rcmOpen, child: Positioned( top: QFinder().dy, left: QFinder().dx, child: RightClickMenu(context), ), ); } AnimatedContainer RightClickMenu(BuildContext context) { return AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: 0.15)+1, height: screenHeight(context, mulBy: 0.2)+1, decoration: BoxDecoration( border: Border.all(color: Theme.of(context).shadowColor, width: 1), borderRadius: BorderRadius.all(Radius.circular(5)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.1), spreadRadius: 5, blurRadius: 10, offset: Offset(0, 3), ), ], ), child: Container( width: screenWidth(context, mulBy: 0.15), height: screenHeight(context, mulBy: 0.2), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(5)), border: Border.all( color: Colors.grey.withOpacity(0.9), width: themeNotifier.isDark()?0.6:0 ), ), child: ClipRRect( borderRadius: BorderRadius.circular(5), child: BackdropFilter( filter: ui.ImageFilter.blur(sigmaX: 30.0, sigmaY: 30.0), child: Container( height: screenHeight(context, mulBy: 0.14), width: screenWidth( context, ), padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.0025), vertical: screenHeight(context, mulBy: 0.003) ), decoration: BoxDecoration( color: Theme.of(context).hoverColor ), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ RCMItem( name: "New Folder", margin: EdgeInsets.only( bottom: screenHeight(context, mulBy: 0.006) ), buttonFunc: (){ Provider.of<Folders>(context, listen: false).createFolder(context, renaming: true); Provider.of<OnOff>(context, listen: false).offRCM(); }, ), Container( color: Theme.of(context) .cardColor .withOpacity(0.9), height: 0.25, width: screenWidth(context, mulBy: 0.13), ), RCMItem( name: "Get Info", margin: EdgeInsets.only( top: screenHeight(context, mulBy: 0.006) ), buttonFunc: (){ print("Get Info Screen"); Provider.of<OnOff>(context, listen: false).offRCM(); }, ), RCMItem( name: "Change Desktop Background...", margin: EdgeInsets.only( bottom: screenHeight(context, mulBy: 0.006) ), buttonFunc: (){ tapFunctions(context); Future.delayed(const Duration(milliseconds: 200), () { Provider.of<OnOff>(context, listen: false) .maxSysPref(); Provider.of<Apps>(context, listen: false).openApp( SystemPreferences( key: ObjectKey("systemPreferences"), initPos: Offset( screenWidth(context, mulBy: 0.24), screenHeight(context, mulBy: 0.13)), wallpaper: true, ), Provider.of<OnOff>(context, listen: false) .maxSysPref() ); }); }, ), Container( color: Theme.of(context) .cardColor .withOpacity(0.9), height: 0.25, width: screenWidth(context, mulBy: 0.13), ), RCMItem( name: "Use Stacks", margin: EdgeInsets.only( top: screenHeight(context, mulBy: 0.006) ), ), RCMItem( name: "Group Stacks By", ), RCMItem( name: "Show View Options", ), ], ), ), ), ), ), ); } } class RCMItem extends StatefulWidget { final String? name; final EdgeInsets margin; VoidCallback? buttonFunc=(){}; bool folder; bool icon; RCMItem({ Key? key, this.name, this.margin=EdgeInsets.zero, this.buttonFunc, this.folder=false, this.icon=false }) : super(key: key); @override _RCMItemState createState() => _RCMItemState(); } class _RCMItemState extends State<RCMItem> { Color? color; @override Widget build(BuildContext context) { return MouseRegion( onHover: (event){ setState(() { color= Color(0xff1a6cc4); }); }, onExit: (event){ setState(() { color= Colors.transparent; }); }, child: InkWell( onTap: widget.buttonFunc, child: Container( height: screenHeight(context, mulBy: 0.0275), width: screenWidth(context), alignment: Alignment.centerLeft, padding: EdgeInsets.only( left: screenWidth(context, mulBy: widget.folder?0.004:0.0125), right: screenWidth(context, mulBy: 0.006), ), margin: widget.margin, decoration: BoxDecoration( color: color, borderRadius: BorderRadius.circular(3) ), child: Row( children: [ MBPText( text: widget.name, color: Theme.of(context).cardColor.withOpacity(1), fontFamily: 'SF', size: 12.5, weight: FontWeight.w400, ), Visibility( visible: widget.icon, child: Spacer()), Visibility( visible: widget.icon, child: Icon(CupertinoIcons.forward, color: Theme.of(context).cardColor.withOpacity(1), size: 12.5,)) ], ), ), ), ); } } class BrdrContainer extends StatelessWidget { final Widget? child; final double height; final double width; const BrdrContainer({this.height = 1, this.width = 1, this.child, Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Container( height: screenHeight(context, mulBy: height) + 1, width: screenWidth(context, mulBy: width) + 1, decoration: BoxDecoration( color: Theme.of(context).backgroundColor.withOpacity(0.00), borderRadius: BorderRadius.all(Radius.circular(10)), border: Border.all(color: Theme.of(context).shadowColor, width: 1), ), child: child, ); } } class FolderRightClick extends StatefulWidget { final Offset? initPos; const FolderRightClick({this.initPos, Key? key}) : super(key: key); @override _FolderRightClickState createState() => _FolderRightClickState(); } class _FolderRightClickState extends State<FolderRightClick> { Offset? position = Offset(0.0, 0.0); late var themeNotifier; Offset QFinder(){ Offset? offset=new Offset(0, 0); if(widget.initPos!.dx+screenWidth(context, mulBy: 0.15)+1>=screenWidth(context)) { if(widget.initPos!.dy+screenHeight(context, mulBy: 0.73)+1>=screenHeight(context)) { offset = widget.initPos! - Offset(screenWidth(context, mulBy: 0.15) + 1, 0); offset = Offset(offset.dx, screenHeight(context, mulBy: 0.27) - 1); } else offset=widget.initPos!-Offset(screenWidth(context, mulBy: 0.15)+1,0); } else{ if(widget.initPos!.dy+screenHeight(context, mulBy: 0.73)+1>=screenHeight(context)) { offset = Offset(widget.initPos!.dx, screenHeight(context, mulBy: 0.27) - 1); } else offset=widget.initPos; } return offset!; } @override void initState() { position = widget.initPos; super.initState(); } @override Widget build(BuildContext context) { var frcmOpen = Provider.of<OnOff>(context).getFRCM; themeNotifier = Provider.of<ThemeNotifier>(context); return Visibility( visible: frcmOpen, child: Positioned( top: QFinder().dy, left: QFinder().dx, child: RightClickMenu(context), ), ); } AnimatedContainer RightClickMenu(BuildContext context) { return AnimatedContainer( duration: Duration(milliseconds: 200), width: screenWidth(context, mulBy: 0.15)+1, height: screenHeight(context, mulBy: 0.54)+1, decoration: BoxDecoration( border: Border.all(color: Theme.of(context).shadowColor, width: 1), borderRadius: BorderRadius.all(Radius.circular(5)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.1), spreadRadius: 5, blurRadius: 10, offset: Offset(0, 3), ), ], ), child: Container( width: screenWidth(context, mulBy: 0.15), height: screenHeight(context, mulBy: 0.54), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(5)), border: Border.all( color: Colors.white.withOpacity(0.3), width: themeNotifier.isDark()?0.6:0 ), ), child: ClipRRect( borderRadius: BorderRadius.circular(5), child: BackdropFilter( filter: ui.ImageFilter.blur(sigmaX: 30.0, sigmaY: 30.0), child: Container( height: screenHeight(context, mulBy: 0.14), width: screenWidth( context, ), padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.0025), vertical: screenHeight(context, mulBy: 0.003) ), decoration: BoxDecoration( color: Theme.of(context).hoverColor ), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ RCMItem( name: "Open", folder: true, margin: EdgeInsets.only( bottom: screenHeight(context, mulBy: 0.006) ), ), Container( color: Theme.of(context) .cardColor .withOpacity(0.9), height: 0.25, width: screenWidth(context, mulBy: 0.14), ), RCMItem( folder: true, name: "Move to Bin", margin: EdgeInsets.only( top: screenHeight(context, mulBy: 0.006), bottom: screenHeight(context, mulBy: 0.006) ), buttonFunc: (){ Provider.of<Folders>(context, listen: false).deleteFolder(context); Provider.of<OnOff>(context, listen: false).offFRCM(); }, ), Container( color: Theme.of(context) .cardColor .withOpacity(0.9), height: 0.25, width: screenWidth(context, mulBy: 0.14), ), RCMItem( folder: true, name: "Get Info", margin: EdgeInsets.only( top: screenHeight(context, mulBy: 0.006) ), ), RCMItem( folder: true, name: "Rename", buttonFunc: (){ Provider.of<Folders>(context, listen: false).renameFolder(); Provider.of<OnOff>(context, listen: false).offFRCM(); }, ), RCMItem( folder: true, name: "Compress", ), RCMItem( folder: true, name: "Duplicate", ), RCMItem( folder: true, name: "Make Alias", ), RCMItem( folder: true, name: "Quick Look", margin: EdgeInsets.only( bottom: screenHeight(context, mulBy: 0.006) ), ), Container( color: Theme.of(context) .cardColor .withOpacity(0.9), height: 0.25, width: screenWidth(context, mulBy: 0.14), ), RCMItem( folder: true, name: "Copy", margin: EdgeInsets.only( top: screenHeight(context, mulBy: 0.006) ), ), RCMItem( folder: true, icon: true, name: "Share", margin: EdgeInsets.only( bottom: screenHeight(context, mulBy: 0.006) ), ), Container( color: Theme.of(context) .cardColor .withOpacity(0.9), height: 0.25, width: screenWidth(context, mulBy: 0.14), ), Padding( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.006), vertical: screenHeight(context, mulBy: 0.009) ), child: Row( children: [ Container( height: screenHeight(context, mulBy: 0.018), width: screenHeight(context, mulBy: 0.018), decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.redAccent ), ), SizedBox( width: screenWidth(context, mulBy: 0.004), ), Container( height: screenHeight(context, mulBy: 0.018), width: screenHeight(context, mulBy: 0.018), decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.orange ), ), SizedBox( width: screenWidth(context, mulBy: 0.004), ), Container( height: screenHeight(context, mulBy: 0.018), width: screenHeight(context, mulBy: 0.018), decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.amberAccent ), ), SizedBox( width: screenWidth(context, mulBy: 0.004), ), Container( height: screenHeight(context, mulBy: 0.018), width: screenHeight(context, mulBy: 0.018), decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.green ), ), SizedBox( width: screenWidth(context, mulBy: 0.004), ), Container( height: screenHeight(context, mulBy: 0.018), width: screenHeight(context, mulBy: 0.018), decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.blueAccent ), ), SizedBox( width: screenWidth(context, mulBy: 0.004), ), Container( height: screenHeight(context, mulBy: 0.018), width: screenHeight(context, mulBy: 0.018), decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.deepPurple ), ), SizedBox( width: screenWidth(context, mulBy: 0.004), ), Container( height: screenHeight(context, mulBy: 0.018), width: screenHeight(context, mulBy: 0.018), decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.white70 ), ), ], ), ), RCMItem( folder: true, name: "Tags...", margin: EdgeInsets.only( bottom: screenHeight(context, mulBy: 0.006) ), ), Container( color: Theme.of(context) .cardColor .withOpacity(0.9), height: 0.25, width: screenWidth(context, mulBy: 0.14), ), RCMItem( folder: true, icon: true, name: "Quick Actions", margin: EdgeInsets.only( bottom: screenHeight(context, mulBy: 0.006), top: screenHeight(context, mulBy: 0.006), ), ), Container( color: Theme.of(context) .cardColor .withOpacity(0.9), height: 0.25, width: screenWidth(context, mulBy: 0.14), ), RCMItem( folder: true, name: "Folder Actions Setup...", margin: EdgeInsets.only( top: screenHeight(context, mulBy: 0.006), ), ), RCMItem( folder: true, name: "New Terminal at Folder", ), RCMItem( folder: true, name: "New Terminal Tab at Folder", ), ], ), ), ), ), ), ); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/system/desktop.dart
import 'dart:ui'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:mac_dt/apps/launchpad.dart'; import 'package:mac_dt/components/wallpaper/wallpaper.dart'; import 'package:mac_dt/system/componentsOnOff.dart'; import 'package:mac_dt/fileMenu/controlCentre.dart'; import 'package:mac_dt/system/folders/folders.dart'; import 'package:mac_dt/providers.dart'; import 'package:mac_dt/system/rightClickMenu.dart'; import 'package:mac_dt/sizes.dart'; import 'package:mac_dt/widgets.dart'; import 'package:provider/provider.dart'; import 'package:flutter/rendering.dart'; import '../components/notification.dart'; import 'openApps.dart'; import '../components/dock.dart'; import '../fileMenu/fileMenu.dart'; class MacOS extends StatefulWidget { @override _MacOSState createState() => _MacOSState(); } class _MacOSState extends State<MacOS> { @override Widget build(BuildContext context) { var size = MediaQuery.of(context).size; bool ccOpen = Provider.of<OnOff>(context).getCc; final dataBus = Provider.of<DataBus>(context, listen: true); List<Widget> apps = Provider.of<Apps>(context).getApps; List<Folder> folders = Provider.of<Folders>(context, listen: true).getFolders; return Scaffold( body: Center( child: Stack( children: <Widget>[ ///wallpaper GestureDetector( onSecondaryTap: () { Provider.of<OnOff>(context, listen: false).onRCM(); }, onSecondaryTapDown: (details) { tapFunctions(context); Provider.of<DataBus>(context, listen: false) .setPos(details.globalPosition); }, onTap: () { if (!mounted) return; tapFunctions(context); }, child: Container( height: size.height, width: size.width, child: ViewWallpaper(location: dataBus.getWallpaper.location,)), ), ///Desktop Items //...desktopItems, /// Folders ...folders, ///Applications ...apps, ///Right Click Context Menu RightClick(initPos: dataBus.getPos,), ///Folder Right Click Menu FolderRightClick( initPos: dataBus.getPos, ), /// file menu FileMenu(), //TODO State change of widgets under this will cause iFrame HTMLView to reload. Engine Fix required. /// Track the issue here: https://github.com/flutter/flutter/issues/80524 ///LaunchPad LaunchPad(), ///Notification Notifications(), ///docker bar Docker(), ///Click to dismiss Control Centre Visibility( visible: ccOpen, child: InkWell( onTap: () { Provider.of<OnOff>(context, listen: false).offCc(); }, mouseCursor: SystemMouseCursors.basic, child: Container( height: screenHeight(context), width: screenWidth(context), ), ), ), ///Control Centre Positioned( top: screenHeight(context, mulBy: 0.035), child: Container( padding: EdgeInsets.symmetric( vertical: screenHeight(context, mulBy: 0.007), horizontal: screenWidth(context, mulBy: 0.005)), height: screenHeight(context) - (screenHeight(context, mulBy: 0.140)), width: screenWidth(context), child: ControlCentre()), ), ///Control Night Shift IgnorePointer( ignoring: true, child: BlendMask( opacity: 1.0, blendMode: BlendMode.colorBurn, child: AnimatedContainer( duration: Duration(milliseconds: 700), width: screenWidth(context), height: screenHeight(context), color: Colors.orange.withOpacity(dataBus.getNS ? 0.2 : 0), ), ), ), ///Control Brightness IgnorePointer( ignoring: true, child: Opacity( opacity: 1 - (dataBus.getBrightness! / 95.98), child: Container( width: screenWidth(context), height: screenHeight(context), color: Colors.black.withOpacity(0.7), ), ), ), ], ), ), ); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/system/openApps.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../apps/feedback/feedback.dart'; import '../data/analytics.dart'; import '../sizes.dart'; class Apps extends ChangeNotifier{ late Widget temp; List<Widget> apps= [ ]; String onTop="Finder"; void bringToTop(ObjectKey? appKey){ temp= apps.singleWhere((element) => element.key==appKey); apps.removeWhere((element) => element.key==appKey); apps.add(temp); setTop(); notifyListeners(); } List<Widget> get getApps { return apps; } void openApp(Widget app, void minMax, ){ if(!apps.any((element) => element.key==app.key)) { apps.add(app); setTop(); notifyListeners(); } else { bringToTop(app.key as ObjectKey?); minMax; } } void openIApp(Widget app,){ apps.add(app); notifyListeners(); } void closeApp(String appKey){ apps.removeWhere((element) => element.key==ObjectKey(appKey)); notifyListeners(); setTop(); } void closeIApp(){ apps.clear(); notifyListeners(); } bool isOpen(ObjectKey appKey){ return apps.any((element) => element.key==appKey); } String get getTop { return onTop; } void setTop() { //onTop=top; if(apps.isEmpty) onTop="Finder"; else if(apps.last.key==ObjectKey("finder")) onTop="Finder"; else if(apps.last.key==ObjectKey("safari")) onTop="Safari"; else if(apps.last.key==ObjectKey("spotify")) onTop="Spotify"; else if(apps.last.key==ObjectKey("terminal")) onTop="Terminal"; else if(apps.last.key==ObjectKey("vscode")) onTop="VS Code"; else if(apps.last.key==ObjectKey("calendar")) onTop="Calendar"; else if(apps.last.key==ObjectKey("feedback")) onTop="Feedback"; else if(apps.last.key==ObjectKey("messages")) onTop="Messages"; else if(apps.last.key==ObjectKey("systemPreferences")) onTop="System Preferences"; else if(apps.last.key==ObjectKey("about")) onTop="About Me"; notifyListeners(); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/system/componentsOnOff.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; // var finderOpen = Provider.of<OnOff>(context).getFinder; // Provider.of<OnOff>(context, listen: false).toggleFinder(); /// toggle{App}() toggles between the minimized and regular view of the app. Opening /// the app is managed by Apps state management. class OnOff extends ChangeNotifier{ String fs=""; bool ccOpen =false; bool finderMax =false; bool finderFS = false; bool safariMax =false; bool safariFS = false; bool safariPan = false; bool finderPan = false; bool vsMax = false; bool vsFS = false; bool vsPan = false; bool spotifyMax = false; bool spotifyFS = false; bool spotifyPan = false; bool fsAni= false; bool feedBackOpen = false; bool feedBackFS = false; bool feedBackPan = false; bool aboutOpen = false; bool aboutFS = false; bool aboutPan = false; bool calendarMax = false; bool calendarFS = false; bool calendarPan = false; bool terminalMax = false; bool terminalFS = false; bool terminalPan = false; bool messagesMax = false; bool messagesFS = false; bool messagesPan = false; bool rightClickMenu = false; bool folderRightClickMenu = false; bool notificationOn =false; bool launchPadOn=false; bool appOpen=false; bool sysPrefOpen = false; bool sysPrefPan = false; bool get getAppOpen { return appOpen; } void toggleAppOpen(){ appOpen=!appOpen; notifyListeners(); } String get getFS { return fs; } bool get getFSAni{ return fsAni; } bool get getFinder { return finderMax; } bool get getFinderFS { return finderFS; } void toggleFinder() { finderMax= !finderMax; notifyListeners(); } void toggleFinderFS() { bool localFs= fsAni; finderFS= !finderFS; fs=(fs=="")?"Finder":""; if(!localFs){ fsAni = true; } notifyListeners(); if(localFs){ Future.delayed(Duration(milliseconds: 400), () { fsAni = false; notifyListeners(); }); } } void offFinderFS() { finderFS= false; fs=""; notifyListeners(); Future.delayed(Duration(milliseconds: 400),(){ fsAni=false; notifyListeners(); }); } void maxFinder() { finderMax= true; notifyListeners(); } bool get getFinderPan { return finderPan; } void offFinderPan() { finderPan= false; notifyListeners(); } void onFinderPan() { finderPan= true; notifyListeners(); } bool get getSafari { return safariMax; } bool get getSafariFS { return safariFS; } void toggleSafari() { safariMax= !safariMax; notifyListeners(); } void toggleSafariFS() { bool localFs= fsAni; safariFS= !safariFS; fs=(fs=="")?"Safari":""; if(!localFs){ fsAni = true; } notifyListeners(); if(localFs){ Future.delayed(Duration(milliseconds: 400), () { fsAni = false; notifyListeners(); }); } } void offSafariFS() { safariFS= false; fs=""; notifyListeners(); Future.delayed(Duration(milliseconds: 400),(){ fsAni=false; notifyListeners(); }); } void maxSafari() { safariMax= true; notifyListeners(); } bool get getSafariPan { return safariPan; } void offSafariPan() { safariPan= false; notifyListeners(); } void onSafariPan() { safariPan= true; notifyListeners(); } bool get getVS { return vsMax; } bool get getVSFS { return vsFS; } void toggleVS() { vsMax= !vsMax; notifyListeners(); } void toggleVSFS() { bool localFs= fsAni; vsFS= !vsFS; fs=(fs=="")?"VS Code":""; if(!localFs){ fsAni = true; } notifyListeners(); if(localFs){ Future.delayed(Duration(milliseconds: 400), () { fsAni = false; notifyListeners(); }); } } void offVSFS() { vsFS= false; fs=""; notifyListeners(); Future.delayed(Duration(milliseconds: 400),(){ fsAni=false; notifyListeners(); }); } void maxVS() { vsMax= true; notifyListeners(); } bool get getVSPan { return vsPan; } void offVSPan() { vsPan= false; notifyListeners(); } void onVSPan() { vsPan= true; notifyListeners(); } bool get getSpotify { return spotifyMax; } bool get getSpotifyFS { return spotifyFS; } void toggleSpotify() { spotifyMax= !spotifyMax; notifyListeners(); } void toggleSpotifyFS() { bool localFs= fsAni; spotifyFS= !spotifyFS; fs=(fs=="")?"Spotify":""; if(!localFs){ fsAni = true; } notifyListeners(); if(localFs){ Future.delayed(Duration(milliseconds: 400), () { fsAni = false; notifyListeners(); }); } } void offSpotifyFS() { spotifyFS= false; fs=""; notifyListeners(); Future.delayed(Duration(milliseconds: 400),(){ fsAni=false; notifyListeners(); }); } void maxSpotify() { spotifyMax= true; notifyListeners(); } bool get getSpotifyPan { return spotifyPan; } void offSpotifyPan() { spotifyPan= false; notifyListeners(); } void onSpotifyPan() { spotifyPan= true; notifyListeners(); } bool get getCalendar { return calendarMax; } bool get getCalendarFS { return calendarFS; } void toggleCalendar() { calendarMax= !calendarMax; notifyListeners(); } void toggleCalendarFS() { bool localFs= fsAni; calendarFS= !calendarFS; fs=(fs=="")?"Calendar":""; if(!localFs){ fsAni = true; } notifyListeners(); if(localFs){ Future.delayed(Duration(milliseconds: 400), () { fsAni = false; notifyListeners(); }); } } void offCalendarFS() { calendarFS= false; fs=""; notifyListeners(); Future.delayed(Duration(milliseconds: 400),(){ fsAni=false; notifyListeners(); }); } void maxCalendar() { calendarMax= true; notifyListeners(); } bool get getCalendarPan { return calendarPan; } void offCalendarPan() { calendarPan= false; notifyListeners(); } void onCalendarPan() { calendarPan= true; notifyListeners(); } bool get getTerminal { return terminalMax; } bool get getTerminalFS { return terminalFS; } void toggleTerminal() { terminalMax= !terminalMax; notifyListeners(); } void toggleTerminalFS() { bool localFs= fsAni; terminalFS= !terminalFS; fs=(fs=="")?"Terminal":""; if(!localFs){ fsAni = true; } notifyListeners(); if(localFs){ Future.delayed(Duration(milliseconds: 400), () { fsAni = false; notifyListeners(); }); } } void offTerminalFS() { terminalFS= false; fs=""; notifyListeners(); Future.delayed(Duration(milliseconds: 400),(){ fsAni=false; notifyListeners(); }); } void maxTerminal() { terminalMax= true; notifyListeners(); } bool get getTerminalPan { return terminalPan; } void offTerminalPan() { terminalPan= false; notifyListeners(); } void onTerminalPan() { terminalPan= true; notifyListeners(); } bool get getMessages { return messagesMax; } bool get getMessagesFS { return messagesFS; } void toggleMessages() { messagesMax= !messagesMax; notifyListeners(); } void toggleMessagesFS() { bool localFs= fsAni; messagesFS= !messagesFS; fs=(fs=="")?"Messages":""; if(!localFs){ fsAni = true; } notifyListeners(); if(localFs){ Future.delayed(Duration(milliseconds: 400), () { fsAni = false; notifyListeners(); }); } } void offMessagesFS() { messagesFS= false; fs=""; notifyListeners(); Future.delayed(Duration(milliseconds: 400),(){ fsAni=false; notifyListeners(); }); } void maxMessages() { messagesMax= true; notifyListeners(); } bool get getMessagesPan { return messagesPan; } void offMessagesPan() { messagesPan= false; notifyListeners(); } void onMessagesPan() { messagesPan= true; notifyListeners(); } bool get getFeedBack { return feedBackOpen; } bool get getFeedBackFS { return feedBackFS; } void toggleFeedBack() { feedBackOpen= !feedBackOpen; notifyListeners(); } void toggleFeedBackFS() { bool localFs= fsAni; feedBackFS= !feedBackFS; fs=(fs=="")?"Feedback":""; if(!localFs){ fsAni = true; } notifyListeners(); if(localFs){ Future.delayed(Duration(milliseconds: 400), () { fsAni = false; notifyListeners(); }); } } void offFeedBackFS() { feedBackFS= false; fs=""; notifyListeners(); Future.delayed(Duration(milliseconds: 400),(){ fsAni=false; notifyListeners(); }); } void maxFeedBack() { feedBackOpen= true; notifyListeners(); } bool get getFeedBackPan { return feedBackPan; } void offFeedBackPan() { feedBackPan= false; notifyListeners(); } void onFeedBackPan() { feedBackPan= true; notifyListeners(); } bool get getAbout { return aboutOpen; } bool get getAboutFS { return aboutFS; } void toggleAbout() { aboutOpen= !aboutOpen; notifyListeners(); } void toggleAboutFS() { bool localFs= fsAni; aboutFS= !aboutFS; fs=(fs=="")?"About Me":""; if(!localFs){ fsAni = true; } notifyListeners(); if(localFs){ Future.delayed(Duration(milliseconds: 400), () { fsAni = false; notifyListeners(); }); } } void offAboutFS() { aboutFS= false; fs=""; notifyListeners(); Future.delayed(Duration(milliseconds: 400),(){ fsAni=false; notifyListeners(); }); } void maxAbout() { aboutOpen= true; notifyListeners(); } bool get getAboutPan { return aboutPan; } void offAboutPan() { aboutPan= false; notifyListeners(); } void onAboutPan() { aboutPan= true; notifyListeners(); } bool get getCc { return ccOpen; } void toggleCc() { ccOpen= !ccOpen; notifyListeners(); } void offCc() { ccOpen= false; notifyListeners(); } bool get getRCM { return rightClickMenu; } void onRCM() { rightClickMenu= true; notifyListeners(); } void offRCM() { rightClickMenu= false; notifyListeners(); } bool get getFRCM { return folderRightClickMenu; } void onFRCM() { folderRightClickMenu= true; notifyListeners(); } void offFRCM() { folderRightClickMenu= false; notifyListeners(); } void onNotifications() { notificationOn= true; Future.delayed(Duration(seconds: 4), (){ offNotifications(); }); notifyListeners(); } void offNotifications() { notificationOn= false; notifyListeners(); } bool get getSysPref { return sysPrefOpen; } void toggleSysPref() { sysPrefOpen= !sysPrefOpen; notifyListeners(); } void maxSysPref() { sysPrefOpen= true; notifyListeners(); } bool get getSysPrefPan { return sysPrefPan; } void offSysPrefPan() { sysPrefPan= false; notifyListeners(); } void onSysPrefPan() { sysPrefPan= true; notifyListeners(); } get getNotificationOn=> notificationOn; void toggleLaunchPad() { launchPadOn= !launchPadOn; notifyListeners(); } void offLaunchPad() { launchPadOn= false; notifyListeners(); } get getLaunchPad => launchPadOn; }
0
mirrored_repositories/chrishub/lib/system
mirrored_repositories/chrishub/lib/system/folders/folders.dart
import 'dart:async'; import 'dart:developer'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:hive/hive.dart'; import 'package:mac_dt/system/folders/folders_CRUD.dart'; import 'package:provider/provider.dart'; import '../../apps/systemPreferences.dart'; import '../../data/analytics.dart'; import '../componentsOnOff.dart'; import '../../providers.dart'; import '../../sizes.dart'; import '../openApps.dart'; part 'folders.g.dart'; class Folders extends ChangeNotifier{ Widget? temp; List<Folder> folders= FoldersDataCRUD.getFolders(); List<DesktopItem> desktopItems=[]; List<Folder> get getFolders { return folders; } List<DesktopItem> get getDesktopItems { return desktopItems; } void createFolder(context, {String name="untitled folder", bool? renaming}){ Offset initPos= Offset(200, 150); int x,y,folderNum=0; if(folders.isEmpty) initPos=Offset(screenWidth(context, mulBy: 0.91), screenHeight(context, mulBy: 0.09)); else{ for(int element=0; element<folders.length; element++) { if(folders[element].name==name) { if(int.tryParse(folders[element].name!.split(" ").last)!=null) { ///for not changing "untitled folder" to "untitled 1" folderNum = int.parse(folders[element].name!.split(" ").last) ?? folderNum; name = "${name.substring(0, name.lastIndexOf(" "))} ${++folderNum}"; element=0; ///for checking if changed name == name in already checked folders } else{ name = "$name ${++folderNum}"; } } } x= (folders.length)~/6; y= (folders.length)%6; if(x==0) initPos=Offset(screenWidth(context, mulBy: 0.91), y*screenHeight(context, mulBy: 0.129)+screenHeight(context, mulBy: 0.09)); else initPos=Offset(screenWidth(context, mulBy: 0.98)-(x+1)*screenWidth(context, mulBy: 0.07), (y)*screenHeight(context, mulBy: 0.129)+screenHeight(context, mulBy: 0.09)); } log(initPos.dy.toString()); folders.add(Folder(key: UniqueKey(), name: name, renaming: renaming, initPos: initPos, )); FoldersDataCRUD.addFolder(FolderProps(name: name, x: initPos.dx, y: initPos.dy,)); Provider.of<AnalyticsService>(context, listen: false) .logFolder(name); notifyListeners(); } void deleteFolder(BuildContext context){ Offset posAfterDel= Offset(200, 150); int x,y; String name=folders.firstWhere((element) => element.selected==true).name!; folders.removeWhere((element) => element.selected==true); deSelectAll(); for(int i=0; i<folders.length; i++) { x= (i)~/6; y= (i)%6; if(x==0) posAfterDel=Offset(screenWidth(context, mulBy: 0.91), y*screenHeight(context, mulBy: 0.129)+screenHeight(context, mulBy: 0.09)); else posAfterDel=Offset(screenWidth(context, mulBy: 0.98)-(x+1)*screenWidth(context, mulBy: 0.07), (y)*screenHeight(context, mulBy: 0.129)+screenHeight(context, mulBy: 0.09)); folders[i].initPos=posAfterDel; } FoldersDataCRUD.deleteFolder(name, folders); notifyListeners(); } void renameFolder(){ folders.forEach((element) { if(element.selected==true) { element.renameFolder(); } }); } void deSelectAll(){ desktopItems.forEach((element) { element.deSelectFolder(); }); folders.forEach((element) { element.deSelectFolder(); }); } } class Folder extends StatefulWidget { String? name; Offset? initPos; bool? renaming; bool selected; late VoidCallback deSelectFolder; late VoidCallback renameFolder; Folder({Key? key, this.name, this.initPos, this.renaming= false, this.selected=false,}): super(key: key); @override _FolderState createState() => _FolderState(); } class _FolderState extends State<Folder> { Offset? position= Offset(200, 150); TextEditingController? controller; FocusNode _focusNode = FocusNode(); bool pan= false; bool bgVisible= false; @override void initState() { super.initState(); controller = new TextEditingController(text: widget.name, ); controller!.selection=TextSelection.fromPosition(TextPosition(offset: controller!.text.length)); position=widget.initPos; selectText(); widget.renameFolder=(){ if (!mounted) return; setState(() { widget.renaming=true; }); }; widget.deSelectFolder= (){ if (!mounted) return; setState(() { widget.selected=false; widget.renaming=false; //widget.name=controller.text.toString(); }); }; } void selectText(){ _focusNode.addListener(() { if(_focusNode.hasFocus) { controller!.selection = TextSelection(baseOffset: 0, extentOffset: controller!.text.length); } }); } @override Widget build(BuildContext context) { List<Folder> folders= Provider.of<Folders>(context).getFolders; if(!pan) position=widget.initPos; return Container( height: screenHeight(context), width: screenWidth(context), child: Stack( children: [ Visibility( visible: bgVisible, child: Positioned( top: widget.initPos!.dy, left: widget.initPos!.dx, child: Container( width: screenWidth(context, mulBy: 0.08), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Container( height: screenHeight(context, mulBy: 0.1), padding: EdgeInsets.symmetric(horizontal: screenWidth(context,mulBy: 0.0005)), decoration: BoxDecoration( color: Colors.black.withOpacity(0.25), border: Border.all( color: Colors.grey.withOpacity(0.4), width: 2 ), borderRadius: BorderRadius.circular(4) ), child: Image.asset("assets/icons/folder.png", height: screenHeight(context, mulBy: 0.085), width: screenWidth(context, mulBy: 0.045), ), ), SizedBox(height: screenHeight(context, mulBy: 0.005), ), Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( height: screenHeight(context, mulBy: 0.024), padding: EdgeInsets.symmetric(horizontal: screenWidth(context,mulBy: 0.005)), alignment: Alignment.center, decoration:BoxDecoration( color: Color(0xff0058d0), borderRadius: BorderRadius.circular(3) ), child: Text(widget.name??"", textAlign: TextAlign.center, style: TextStyle(color: Colors.white, fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 12,), maxLines: 1, overflow: TextOverflow.ellipsis, ), ), ], ) ], ), ), ), ), AnimatedPositioned( duration: Duration(milliseconds: pan?0:200), top: position!.dy, left: position!.dx, child: GestureDetector( onPanUpdate: (tapInfo){ if (!mounted) return; setState(() { position = Offset(position!.dx + tapInfo.delta.dx, position!.dy + tapInfo.delta.dy); }); }, onPanStart: (e){ tapFunctions(context); if (!mounted) return; setState(() { widget.renaming=false; widget.selected=false; widget.name=controller!.text.toString(); pan=true; bgVisible=true; }); }, onPanEnd: (e){ if (!mounted) return; setState(() { pan=false; position=widget.initPos; }); Timer(Duration(milliseconds: 200), (){ if (!mounted) return; setState(() { bgVisible=false; widget.selected=true; });}); }, onTap: (){ tapFunctions(context); if (!mounted) return; setState(() { widget.selected=true; }); }, onSecondaryTap: (){ if (!mounted) return; setState(() { widget.selected=true; }); Provider.of<OnOff>(context, listen: false).onFRCM(); }, onSecondaryTapDown: (details){ tapFunctions(context); Provider.of<DataBus>(context, listen: false).setPos(details.globalPosition); }, child: Container( width: screenWidth(context, mulBy: 0.08), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Container( height: screenHeight(context, mulBy: 0.1), padding: EdgeInsets.symmetric(horizontal: screenWidth(context,mulBy: 0.0005)), decoration: (widget.renaming!||widget.selected)?BoxDecoration( color: Colors.black.withOpacity(0.25), border: Border.all( color: Colors.grey.withOpacity(0.4), width: 2 ), borderRadius: BorderRadius.circular(4) ):BoxDecoration( border: Border.all( color: Colors.grey.withOpacity(0.0), width: 2 ), ), child: Image.asset("assets/icons/folder.png", height: screenHeight(context, mulBy: 0.085), width: screenWidth(context, mulBy: 0.045), ), ), SizedBox(height: screenHeight(context, mulBy: 0.005), ), widget.renaming!? Container( height: screenHeight(context, mulBy: 0.024), width: screenWidth(context, mulBy: 0.06), decoration: BoxDecoration( color: Color(0xff1a6cc4).withOpacity(0.7), border: Border.all( color: Colors.blueAccent ), borderRadius: BorderRadius.circular(3) ), child: Theme( data: ThemeData(textSelectionTheme: TextSelectionThemeData( selectionColor: Colors.transparent)), child: TextField( controller: controller, autofocus: true, focusNode: _focusNode, textAlign: TextAlign.center, inputFormatters: [ LengthLimitingTextInputFormatter(18), ], decoration: InputDecoration( isDense: true, contentPadding: EdgeInsets.only(top: 4.5, bottom: 0, left: 0, right: 0), border: InputBorder.none, focusedBorder: InputBorder.none, enabledBorder: InputBorder.none, errorBorder: InputBorder.none, disabledBorder: InputBorder.none, ), cursorColor: Colors.white60, style: TextStyle( color: Colors.white, fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 12 ), onSubmitted: (s){ if (!mounted) return; setState(() { widget.renaming=false; if(controller!.text=="") ///changes controller to sys found name if empty. controller!.text=widget.name!; int folderNum=0; for(int element=0; element<folders.length; element++) { if(folders[element].name==controller!.text) { if(int.tryParse(folders[element].name!.split(" ").last)!=null) { ///for not changing "untitled folder" to "untitled 1" folderNum = int.parse(folders[element].name!.split(" ").last) ?? folderNum; controller!.text = "${controller!.text.substring(0, controller!.text.lastIndexOf(" "))} ${++folderNum}"; element=0; ///for checking if changed name == name in already checked folders } else{ controller!.text = "${controller!.text} ${++folderNum}"; } } } FoldersDataCRUD.renameFolder(widget.name!, controller!.text.toString()); widget.name=controller!.text.toString(); }); }, ), ), ) :Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( height: screenHeight(context, mulBy: 0.024), padding: EdgeInsets.symmetric(horizontal: screenWidth(context,mulBy: 0.005)), alignment: Alignment.center, decoration: widget.selected?BoxDecoration( color: Color(0xff0058d0), borderRadius: BorderRadius.circular(3) ):BoxDecoration(), child: Text(widget.name??"", textAlign: TextAlign.center, style: TextStyle(color: Colors.white, fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 12,), maxLines: 1, overflow: TextOverflow.ellipsis, ), ), ], ) ], ), ), ), ), ], ), ); } } class DesktopItem extends StatefulWidget { String? name; Offset? initPos; bool selected; late VoidCallback deSelectFolder; VoidCallback onDoubleTap; DesktopItem({Key? key, this.name, this.initPos, this.selected=false, required this.onDoubleTap}): super(key: key); @override _DesktopItemState createState() => _DesktopItemState(); } class _DesktopItemState extends State<DesktopItem> { Offset? position= Offset(135, 150); TextEditingController? controller; FocusNode _focusNode = FocusNode(); bool pan= false; bool bgVisible= false; @override void initState() { super.initState(); controller = new TextEditingController(text: widget.name, ); controller!.selection=TextSelection.fromPosition(TextPosition(offset: controller!.text.length)); position=widget.initPos; selectText(); widget.deSelectFolder= (){ if (!mounted) return; setState(() { widget.selected=false; //widget.name=controller.text.toString(); }); }; } void selectText(){ _focusNode.addListener(() { if(_focusNode.hasFocus) { controller!.selection = TextSelection(baseOffset: 0, extentOffset: controller!.text.length); } }); } @override Widget build(BuildContext context) { if(!pan) position=Offset(screenWidth(context, mulBy: widget.initPos!.dx),screenHeight(context, mulBy: widget.initPos!.dy)); return Container( height: screenHeight(context), width: screenWidth(context), child: Stack( children: [ Visibility( visible: bgVisible, child: Positioned( top: screenHeight(context, mulBy: widget.initPos!.dy), left: screenWidth(context, mulBy: widget.initPos!.dx), child: Container( width: screenWidth(context, mulBy: 0.08), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Container( height: screenHeight(context, mulBy: 0.1), padding: EdgeInsets.symmetric(horizontal: screenWidth(context,mulBy: 0.0005)), decoration: BoxDecoration( color: Colors.black.withOpacity(0.25), border: Border.all( color: Colors.grey.withOpacity(0.4), width: 2 ), borderRadius: BorderRadius.circular(4) ), child: Image.asset("assets/icons/server.png", height: screenHeight(context, mulBy: 0.085), width: screenWidth(context, mulBy: 0.045), ), ), SizedBox(height: screenHeight(context, mulBy: 0.005), ), Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( height: screenHeight(context, mulBy: 0.024), padding: EdgeInsets.symmetric(horizontal: screenWidth(context,mulBy: 0.005)), alignment: Alignment.center, decoration:BoxDecoration( color: Color(0xff0058d0), borderRadius: BorderRadius.circular(3) ), child: Text(widget.name??"", textAlign: TextAlign.center, style: TextStyle(color: Colors.white, fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 12,), maxLines: 1, overflow: TextOverflow.ellipsis, ), ), ], ) ], ), ), ), ), AnimatedPositioned( duration: Duration(milliseconds: pan?0:200), top: position!.dy, left: position!.dx, child: GestureDetector( onDoubleTap: (){ tapFunctions(context); if (!mounted) return; setState(() { widget.selected=true; }); widget.onDoubleTap(); }, onPanUpdate: (tapInfo){ if (!mounted) return; setState(() { position = Offset(position!.dx + tapInfo.delta.dx, position!.dy + tapInfo.delta.dy); }); }, onPanStart: (e){ tapFunctions(context); if (!mounted) return; setState(() { widget.selected=false; widget.name=controller!.text.toString(); pan=true; bgVisible=true; }); }, onPanEnd: (e){ if (!mounted) return; setState(() { pan=false; position=widget.initPos; }); Timer(Duration(milliseconds: 200), (){ if (!mounted) return; setState(() { bgVisible=false; widget.selected=true; });}); }, onTap: (){ tapFunctions(context); if (!mounted) return; setState(() { widget.selected=true; }); }, onSecondaryTap: (){ if (!mounted) return; setState(() { widget.selected=true; }); Provider.of<OnOff>(context, listen: false).onFRCM(); }, onSecondaryTapDown: (details){ tapFunctions(context); Provider.of<DataBus>(context, listen: false).setPos(details.globalPosition); }, child: Container( width: 122, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Container( height: 74.5, padding: EdgeInsets.symmetric(horizontal: screenWidth(context,mulBy: 0.0005)), decoration: (widget.selected)?BoxDecoration( color: Colors.black.withOpacity(0.25), border: Border.all( color: Colors.grey.withOpacity(0.4), width: 2 ), borderRadius: BorderRadius.circular(4) ):BoxDecoration( border: Border.all( color: Colors.grey.withOpacity(0.0), width: 2 ), ), child: Image.asset("assets/icons/server.png", height: 63.3, width: 69.12, ), ), SizedBox(height: screenHeight(context, mulBy: 0.005), ), Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( height: 18, padding: EdgeInsets.symmetric(horizontal: screenWidth(context,mulBy: 0.005)), alignment: Alignment.center, decoration: widget.selected?BoxDecoration( color: Color(0xff0058d0), borderRadius: BorderRadius.circular(3) ):BoxDecoration(), child: Text(widget.name??"", textAlign: TextAlign.center, style: TextStyle(color: Colors.white, fontFamily: "HN", fontWeight: FontWeight.w500, fontSize: 12,), maxLines: 1, overflow: TextOverflow.ellipsis, ), ), ], ) ], ), ), ), ), ], ), ); } } ///Declared as HiveObject for hive database @HiveType(typeId: 2) class FolderProps extends HiveObject{ @HiveField(0,) String? name; @HiveField(1,) double? x; @HiveField(2,) double? y; FolderProps({this.name="", this.x, this.y,}); }
0
mirrored_repositories/chrishub/lib/system
mirrored_repositories/chrishub/lib/system/folders/folders_CRUD.dart
import 'dart:developer'; import 'package:flutter/cupertino.dart'; import 'package:hive/hive.dart'; import 'package:mac_dt/system/folders/folders.dart'; class FoldersDataCRUD{ static Box<FolderProps> getFoldersBox() => Hive.box<FolderProps>('folders'); ///Gets data from local database. static List<Folder> getFolders(){ final box= getFoldersBox(); List<Folder> folders=[]; folders=box.values.map((e) => Folder(name: e.name, key: UniqueKey(), initPos: Offset(e.x!, e.y!), renaming:false,)).toList(); return folders; } ///Sets data to local database. static addFolder(FolderProps? folderProps){ final box= getFoldersBox(); box.put(folderProps!.name, folderProps); } static renameFolder(String oldName, String newName){ final box= getFoldersBox(); FolderProps? folderProps= box.get(oldName); folderProps!.delete(); folderProps.name=newName; addFolder(folderProps); } static deleteFolder(String name, List<Folder> folders){ final box= getFoldersBox(); FolderProps? folderProps= box.get(name); folderProps!.delete(); List keys=box.keys.toList(); for(int i=0; i<folders.length; i++) { box.putAt(keys.indexOf(folders[i].name), FolderProps(name: folders[i].name, x: folders[i].initPos!.dx, y: folders[i].initPos!.dy)); } } }
0
mirrored_repositories/chrishub/lib/system
mirrored_repositories/chrishub/lib/system/folders/folders.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'folders.dart'; // ************************************************************************** // TypeAdapterGenerator // ************************************************************************** class FolderPropsAdapter extends TypeAdapter<FolderProps> { @override final int typeId = 2; @override FolderProps read(BinaryReader reader) { final numOfFields = reader.readByte(); final fields = <int, dynamic>{ for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), }; return FolderProps( name: fields[0] as String?, x: fields[1] as double?, y: fields[2] as double?, ); } @override void write(BinaryWriter writer, FolderProps obj) { writer ..writeByte(3) ..writeByte(0) ..write(obj.name) ..writeByte(1) ..write(obj.x) ..writeByte(2) ..write(obj.y); } @override int get hashCode => typeId.hashCode; @override bool operator ==(Object other) => identical(this, other) || other is FolderPropsAdapter && runtimeType == other.runtimeType && typeId == other.typeId; }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/fileMenu/controlCentre.dart
import 'dart:ui'; import 'dart:math' as math; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mac_dt/providers.dart'; import '../data/analytics.dart'; import '../theme/theme.dart'; import 'package:mac_dt/widgets.dart'; import 'package:provider/provider.dart'; import '../system/componentsOnOff.dart'; import '../sizes.dart'; class ControlCentre extends StatelessWidget { const ControlCentre({Key? key}) : super(key: key); @override Widget build(BuildContext context) { var ccOpen = Provider.of<OnOff>(context).getCc; return ccOpen ? ControlCentreData() : Nothing(); } } class ControlCentreData extends StatefulWidget { const ControlCentreData({Key? key}) : super(key: key); @override State<ControlCentreData> createState() => _ControlCentreDataState(); } class _ControlCentreDataState extends State<ControlCentreData> { double? brightness; late double sound; @override void initState() { brightness = 95.98; sound= 35; Provider.of<AnalyticsService>(context, listen: false) .logCurrentScreen("controlCentre"); super.initState(); } @override Widget build(BuildContext context) { brightness = Provider.of<DataBus>(context).getBrightness; BoxDecoration ccDecoration = BoxDecoration( color: Theme.of(context).backgroundColor, border: Border.all(color: Theme.of(context).cardColor, width: .55), borderRadius: BorderRadius.all(Radius.circular(10)), // backgroundBlendMode: BlendMode.luminosity, ); CustomBoxShadow ccShadow = CustomBoxShadow( color: Theme.of(context).accentColor, spreadRadius: 0, blurRadius: 3, //offset: Offset(0, .5), blurStyle: BlurStyle.outer); final themeNotifier = Provider.of<ThemeNotifier>(context); bool NSOn = Provider.of<DataBus>( context, ).getNS; return Container( child: Align( alignment: Alignment.topRight, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(18)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.15), spreadRadius: 4, blurRadius: 6, offset: Offset(0, 1), // changes position of shadow ), ], ), child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(18)), child: BackdropFilter( filter: ImageFilter.blur( sigmaX: 15.0, sigmaY: 15.0, ), child: Container( height: screenHeight(context, mulBy: 0.45) + 1, width: screenWidth(context, mulBy: 0.2) + 1, decoration: BoxDecoration( color: Theme.of(context).backgroundColor.withOpacity(0.1), borderRadius: BorderRadius.all(Radius.circular(18)), border: Border.all( color: Theme.of(context).splashColor, width: 1.1), ), child: Container( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.007), vertical: screenHeight(context, mulBy: 0.014)), margin: EdgeInsets.zero, height: screenHeight(context, mulBy: 0.45), width: screenWidth(context, mulBy: 0.2), decoration: BoxDecoration( color: Theme.of(context) .backgroundColor .withOpacity(0.1), borderRadius: BorderRadius.all(Radius.circular(18)), border: Border.all( color: Theme.of(context).cardColor, width: 1), ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( padding: EdgeInsets.zero, margin: EdgeInsets.zero, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(10)), boxShadow: [ccShadow], ), child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(10)), child: BackdropFilter( filter: ImageFilter.blur( sigmaX: 15.0, sigmaY: 15.0), child: BrdrContainer( height: 0.17, width: 0.09, child: Container( margin: EdgeInsets.zero, padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.007), vertical: screenHeight(context, mulBy: 0.012)), height: screenHeight(context, mulBy: 0.17), width: screenWidth(context, mulBy: 0.09), decoration: ccDecoration, child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Container( height: 31, width: 31, decoration: BoxDecoration( shape: BoxShape.circle, color: Color(0xff0b84ff) ), alignment: Alignment.center, child: Icon( CupertinoIcons.wifi, color: Colors.white, size: 19.5, ), ), SizedBox( width: 8, ), Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Wi-Fi", style: TextStyle( fontSize: 12, color: Theme.of(context).cardColor.withOpacity(1), fontWeight: FontWeight.w600, letterSpacing: 0.5 ), ), Text( "DLink Home", style: TextStyle( fontSize: 10, color: Theme.of(context).cardColor.withOpacity(0.8), fontWeight: FontWeight.w300, letterSpacing: 0.5 ), ) ], ) ], ), Row( children: [ Container( height: 31, width: 31, decoration: BoxDecoration( shape: BoxShape.circle, color: Color(0xff0b84ff) ), alignment: Alignment.center, child: Icon( CupertinoIcons.bluetooth, color: Colors.white, size: 19.5, ), ), SizedBox( width: 8, ), Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Bluetooth", style: TextStyle( fontSize: 12, color: Theme.of(context).cardColor.withOpacity(1), fontWeight: FontWeight.w600, letterSpacing: 0.5 ), ), Text( "On", style: TextStyle( fontSize: 10, color: Theme.of(context).cardColor.withOpacity(0.8), fontWeight: FontWeight.w300, letterSpacing: 0.5 ), ) ], ) ], ), Row( children: [ Container( height: 31, width: 31, decoration: BoxDecoration( shape: BoxShape.circle, color: Color(0xff0b84ff) ), alignment: Alignment.center, child:Image.network( "https://img.icons8.com/ios-filled/50/000000/airdrop.png", color: Colors.white, height: 19.5, ), ), SizedBox( width: 8, ), Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "AirDrop", style: TextStyle( fontSize: 12, color: Theme.of(context).cardColor.withOpacity(1), fontWeight: FontWeight.w600, letterSpacing: 0.5 ), ), Text( "Contacts only", style: TextStyle( fontSize: 10, color: Theme.of(context).cardColor.withOpacity(0.8), fontWeight: FontWeight.w300, letterSpacing: 0.5 ), ) ], ) ], ) ], ), ), ), ), ), ), Container( height: screenHeight(context, mulBy: 0.17), width: screenWidth(context, mulBy: 0.09), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(10)), boxShadow: [ccShadow], ), child: ClipRRect( borderRadius: BorderRadius.all( Radius.circular(10)), child: BackdropFilter( filter: ImageFilter.blur( sigmaX: 15.0, sigmaY: 15.0), child: BrdrContainer( height: 0.08, width: 0.09, child: InkWell( mouseCursor: MouseCursor.defer, onTap: () { Provider.of<DataBus>(context, listen: false).toggleNS(); }, child: Container( height: screenHeight(context, mulBy: 0.08), width: screenWidth(context, mulBy: 0.09), decoration: ccDecoration, child: Row( mainAxisAlignment: MainAxisAlignment .spaceEvenly, children: [ ClipRRect( borderRadius: BorderRadius.all( Radius.circular( 10)), child: BackdropFilter( filter: ImageFilter.blur( sigmaX: 15.0, sigmaY: 15.0), child: Container( height: screenHeight( context, mulBy: 0.0456), width: screenWidth( context, mulBy: 0.0219), decoration: BoxDecoration( shape: BoxShape .circle, color: NSOn? Colors.orange.withOpacity(0.8):Colors.black.withOpacity(.13), ), child: Center( child: Icon( CupertinoIcons.brightness, color: Colors.white.withOpacity(0.7), size: 18, ), ), ), ), ), Flexible( child: MBPText( overflow: TextOverflow.visible, maxLines: 2, text: "Night Shift\n${NSOn ? "On" : "Off"}", color: Theme.of(context) .cardColor .withOpacity(1), )) ], ), ), ), ), ), ), ), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(10)), boxShadow: [ccShadow], ), child: ClipRRect( borderRadius: BorderRadius.all( Radius.circular(10)), child: BackdropFilter( filter: ImageFilter.blur( sigmaX: 15.0, sigmaY: 15.0), child: BrdrContainer( height: 0.08, width: 0.09, child: InkWell( mouseCursor: MouseCursor.defer, onTap: () { themeNotifier.isDark() ? themeNotifier.setTheme( ThemeNotifier .lightTheme) : themeNotifier.setTheme( ThemeNotifier .darkTheme); }, child: Container( height: screenHeight(context, mulBy: 0.08), width: screenWidth(context, mulBy: 0.09), decoration: ccDecoration, child: Row( mainAxisAlignment: MainAxisAlignment .spaceEvenly, children: [ ClipRRect( borderRadius: BorderRadius.all( Radius.circular( 10)), child: BackdropFilter( filter: ImageFilter.blur( sigmaX: 15.0, sigmaY: 15.0), child: Container( height: screenHeight( context, mulBy: 0.0456), width: screenWidth( context, mulBy: 0.0219), decoration: BoxDecoration( shape: BoxShape .circle, color: Theme.of( context) .highlightColor, ), child: Center( child: Image.asset( "assets/icons/darkBlack.png", height: screenHeight( context, mulBy: 0.032), fit: BoxFit .fitHeight, ), ), ), ), ), Flexible( child: MBPText( overflow: TextOverflow.visible, maxLines: 2, text: "Dark Mode\n${themeNotifier.isDark() ? "On" : "Off"}", color: Theme.of(context) .cardColor .withOpacity(1), )) ], ), ), ), ), ), ), ), ], ), ), ], ), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(10)), boxShadow: [ccShadow], ), child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(10)), child: BackdropFilter( filter: ImageFilter.blur( sigmaX: 15.0, sigmaY: 15.0), child: BrdrContainer( height: 0.08, width: 1, child: Container( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.005), vertical: screenHeight(context, mulBy: 0.005)), height: screenHeight(context, mulBy: 0.08), width: screenWidth( context, ), decoration: ccDecoration, child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, children: [ MBPText( overflow: TextOverflow.clip, text: "Display", color: Theme.of(context) .cardColor .withOpacity(1), ), Stack( clipBehavior: Clip.antiAlias, alignment: Alignment.centerLeft, children: [ SliderTheme( data: SliderTheme.of(context) .copyWith( trackHeight: 15, activeTrackColor: Colors.white, thumbColor: Colors.white, minThumbSeparation: 20, trackShape: SliderTrackShape(), inactiveTrackColor: Colors.white .withOpacity(0.25), thumbShape: RoundSliderThumbShape( enabledThumbRadius: 8.4, elevation: 10, pressedElevation: 20 ), overlayShape: SliderComponentShape .noOverlay, ), child: Slider( value: brightness!, min: 0, max: 100, onChanged: (val) { if (val > 95.98) val = 95.98; else if (val < 6.7) val = 6.7; brightness = val; Provider.of<DataBus>(context, listen: false) .setBrightness(brightness); }, ), ), IgnorePointer( ignoring: true, child: Row( children: [ SizedBox(width: 2,), Image.asset( "assets/icons/brightness.png", height: 15, color: Colors.black.withOpacity(0.55), ), ], ), ) ], ), //CCSlider(height: 16, width: screenWidth(context),), ], ), ), ), ), ), ), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(10)), boxShadow: [ccShadow], ), child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(10)), child: BackdropFilter( filter: ImageFilter.blur( sigmaX: 15.0, sigmaY: 15.0), child: BrdrContainer( height: 0.08, width: 1, child: Container( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.005), vertical: screenHeight(context, mulBy: 0.005)), height: screenHeight(context, mulBy: 0.08), width: screenWidth( context, ), decoration: ccDecoration, child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, children: [ MBPText( overflow: TextOverflow.clip, text: "Sound", color: Theme.of(context) .cardColor .withOpacity(1), ), Stack( clipBehavior: Clip.antiAlias, alignment: Alignment.centerLeft, children: [ SliderTheme( data: SliderTheme.of(context) .copyWith( trackHeight: 15, activeTrackColor: Colors.white, thumbColor: Colors.white, minThumbSeparation: 20, trackShape: SliderTrackShape(), inactiveTrackColor: Colors.white .withOpacity(0.25), thumbShape: RoundSliderThumbShape( enabledThumbRadius: 8.4, elevation: 10, pressedElevation: 20 ), overlayShape: SliderComponentShape .noOverlay, ), child: Slider( value: sound, min: 0, max: 100, onChanged: (val) { if (val > 95.98) val = 95.98; else if (val < 6.7) val = 6.7; setState(() { sound = val; }); }, ), ), IgnorePointer( ignoring: true, child: Row( children: [ SizedBox(width: 4,), Image.asset( "assets/icons/sound.png", height: 13, color: Colors.black.withOpacity(0.55), ), ], ), ) ], ), //CCSlider(height: 16, width: screenWidth(context),), ], ), ), ), ), ), ), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(10)), boxShadow: [ccShadow], ), child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(10)), child: BackdropFilter( filter: ImageFilter.blur( sigmaX: 15.0, sigmaY: 15.0), child: BrdrContainer( height: 0.075, width: 1, child: Container( padding: EdgeInsets.symmetric( horizontal: screenWidth(context, mulBy: 0.005), vertical: screenHeight(context, mulBy: 0.005)), height: screenHeight(context, mulBy: 0.075), width: screenWidth( context, ), decoration: ccDecoration, child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( height: screenHeight(context, mulBy: 0.059), width: screenWidth(context, mulBy: 0.028), decoration: BoxDecoration( color: Theme.of(context) .bottomAppBarColor, borderRadius: BorderRadius.circular(5) ), margin: EdgeInsets.only(right: screenWidth(context, mulBy: 0.005)), child: Center( child: Image.asset( "assets/apps/itunes.png", height: screenHeight( context, mulBy: 0.035), fit: BoxFit .fitHeight, ), ), ), MBPText( overflow: TextOverflow.clip, text: "Music", color: Theme.of(context) .cardColor .withOpacity(1), ), Spacer(), Icon( CupertinoIcons.play_arrow_solid, size: 17, color: Theme.of(context) .bottomAppBarColor.withOpacity(0.5), ), SizedBox( width: screenWidth(context, mulBy: 0.005), ), Icon( CupertinoIcons.forward_fill, size: 16, color: Theme.of(context) .bottomAppBarColor.withOpacity(0.3), ) ], ), ), ), ), ), ), ], ), ), ), ), ), ), ), ); } } class BrdrContainer extends StatelessWidget { final Widget? child; final double height; final double width; const BrdrContainer({this.height = 1, this.width = 1, this.child, Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Container( height: screenHeight(context, mulBy: height) + 1, width: screenWidth(context, mulBy: width) + 1, decoration: BoxDecoration( color: Theme.of(context).backgroundColor.withOpacity(0.00), borderRadius: BorderRadius.all(Radius.circular(10)), border: Border.all(color: Theme.of(context).shadowColor, width: 1), ), child: child, ); } } class SliderTrackShape extends RoundedRectSliderTrackShape { Rect getPreferredRect({ required RenderBox parentBox, Offset offset = Offset.zero, required SliderThemeData sliderTheme, bool isEnabled = false, bool isDiscrete = false, }) { final double trackHeight = sliderTheme.trackHeight!; final double trackLeft = offset.dx; final double trackTop = offset.dy + (parentBox.size.height - trackHeight) / 2; final double trackWidth = parentBox.size.width; return Rect.fromLTWH(trackLeft, trackTop, trackWidth, trackHeight); } }
0
mirrored_repositories/chrishub/lib
mirrored_repositories/chrishub/lib/fileMenu/fileMenu.dart
import 'dart:developer'; import 'dart:html'; import 'dart:math' as math; import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:intl/intl.dart'; import 'package:mac_dt/system/openApps.dart'; import 'package:mac_dt/sizes.dart'; import 'package:provider/provider.dart'; import '../components/alertDialog.dart'; import '../system/componentsOnOff.dart'; import '../system/folders/folders.dart'; class FileMenu extends StatefulWidget { FileMenu({ Key? key, }) : super(key: key); @override _FileMenuState createState() => _FileMenuState(); } class _FileMenuState extends State<FileMenu> { var rand = new math.Random(); late int num; @override void initState() { num= rand.nextInt(20); alertCaller(); super.initState(); } alertCaller() async { Future.delayed(Duration(seconds: 1), () { showDialog( barrierColor: Colors.black.withOpacity(0.15), context: context, builder: (context) { return MacOSAlertDialog(); }, ); }); } @override Widget build(BuildContext context) { var size= MediaQuery.of(context).size; String topApp= Provider.of<Apps>(context).getTop; return RawKeyboardListener( autofocus: true, focusNode: FocusNode(), onKey: (event) async { if (event.isKeyPressed(LogicalKeyboardKey.escape)) { document.exitFullscreen(); } }, child: ClipRect( child: new BackdropFilter( filter: new ImageFilter.blur(sigmaX: 70.0, sigmaY: 70.0), child: new Container( height: 25, width: screenWidth(context,), padding: EdgeInsets.all(3), decoration: new BoxDecoration( color: Theme.of(context).canvasColor, border: Border( bottom: BorderSide( color: Colors.white.withOpacity(0.0), width: 0.5, ), ),), child: Row( children: [ Row( children: [ SizedBox(width: size.width*0.012,), Image.asset("assets/icons/apple_file.png",), SizedBox(width: size.width*0.013,), //TODO FittedBox(fit: BoxFit.fitHeight, child: Text(topApp, style: TextStyle(fontFamily: 'HN', fontWeight: FontWeight.w600, color: Colors.white),)), SizedBox(width: size.width*0.014,), FittedBox(fit: BoxFit.fitHeight, child:Text("File", style: TextStyle(fontFamily: 'HN', fontWeight: FontWeight.w400, color: Colors.white),),), SizedBox(width: size.width*0.014,), FittedBox(fit: BoxFit.fitHeight, child:Text("Edit", style: TextStyle(fontFamily: 'HN', fontWeight: FontWeight.w400, color: Colors.white),),), SizedBox(width: size.width*0.014,), FittedBox(fit: BoxFit.fitHeight, child:Text("View", style: TextStyle(fontFamily: 'HN', fontWeight: FontWeight.w400, color: Colors.white),),), SizedBox(width: size.width*0.014,), FittedBox(fit: BoxFit.fitHeight, child: Text("Go", style: TextStyle(fontFamily: 'HN', fontWeight: FontWeight.w400, color: Colors.white),),), SizedBox(width: size.width*0.014,), FittedBox(fit: BoxFit.fitHeight, child: Text("Window", style: TextStyle(fontFamily: 'HN', fontWeight: FontWeight.w400, color: Colors.white),),), SizedBox(width: size.width*0.014,), FittedBox(fit: BoxFit.fitHeight, child: Text("Help", style: TextStyle(fontFamily: 'HN', fontWeight: FontWeight.w400, color: Colors.white),),), ], ), Spacer(), InkWell( onTap: (){ Provider.of<Folders>(context, listen: false).deSelectAll(); Provider.of<OnOff>(context, listen: false).toggleCc(); }, child: Row( children: [ FittedBox(fit: BoxFit.fitHeight, child:Text("${num+60}% ", style: TextStyle(fontFamily: 'HN', fontWeight: FontWeight.w400, fontSize: 12.5, color: Colors.white),),), Image.asset("assets/icons/battery.png", height: 12, ), SizedBox(width: size.width*0.014,), Image.asset("assets/icons/wifi.png", height: 13.5,), SizedBox(width: size.width*0.014,), Image.asset("assets/icons/spotlight.png", height: 14.5,), SizedBox(width: size.width*0.014,), Image.asset("assets/icons/cc.png", height: 16,filterQuality: FilterQuality.low,), SizedBox(width: size.width*0.014,), Image.asset("assets/icons/siri.png", height: 15), SizedBox(width: size.width*0.014,), // FittedBox(fit: BoxFit.fitHeight, // child: Text( // "${DateFormat('E d LLL hh:mm a').format(DateTime.now())}", // style: TextStyle(fontFamily: 'HN', // fontWeight: FontWeight.w400, // color: Colors.white),),), StreamBuilder( stream: Stream.periodic(const Duration(seconds: 1)), builder: (context, snapshot){ return FittedBox(fit: BoxFit.fitHeight, child: Text( "${DateFormat('E d LLL hh:mm a').format(DateTime.now())}", style: TextStyle(fontFamily: 'HN', fontWeight: FontWeight.w400, color: Colors.white),),); },), SizedBox(width: size.width*0.014,), ], ), ), ], ) ), ), ), ); } }
0
mirrored_repositories/chrishub
mirrored_repositories/chrishub/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 that Flutter provides. 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/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mac_dt/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/gatrabali-app
mirrored_repositories/gatrabali-app/lib/auth.dart
import 'dart:async'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:gatrabali/config.dart'; import 'package:google_sign_in/google_sign_in.dart'; import 'package:flutter_facebook_login/flutter_facebook_login.dart'; import 'package:gatrabali/repository/subscriptions.dart'; import 'package:gatrabali/scoped_models/app.dart'; import 'package:gatrabali/models/user.dart'; class Auth { final FirebaseAuth _auth = FirebaseAuth.instance; final AppModel model; Auth(this.model); Future<User> anonymousSignIn() { return _auth.signInAnonymously().then((authResult) { return Auth.userFromFirebaseUser(authResult.user); }); } Future<User> googleSignIn({bool linkAccount = false}) { final GoogleSignIn _googleSignIn = GoogleSignIn(); return _googleSignIn.signIn().then((user) { return user.authentication; }).then((auth) { return GoogleAuthProvider.getCredential( idToken: auth.idToken, accessToken: auth.accessToken); }).then((credential) { if (linkAccount) { return _auth .currentUser() .then((currentUser) => currentUser.linkWithCredential(credential)); } else { return _auth.signInWithCredential(credential); } }).then((authResult) { return Auth.userFromFirebaseUser(authResult.user); }); } Future<User> facebookSignIn({bool linkAccount = false}) { final _facebookSignin = FacebookLogin(); return _facebookSignin.logIn(['email']).then((result) { if (result.status == FacebookLoginStatus.cancelledByUser) { throw Exception('Facebook login cancelled'); } if (result.status == FacebookLoginStatus.error) { throw Exception(result.errorMessage); } return FacebookAuthProvider.getCredential( accessToken: result.accessToken.token); }).then((credential) { if (linkAccount) { return _auth .currentUser() .then((currentUser) => currentUser.linkWithCredential(credential)); } else { return _auth.signInWithCredential(credential); } }).then((authResult) { return Auth.userFromFirebaseUser(authResult.user); }); } Future<User> currentUser() { return _auth.currentUser().then((firebaseUser) { if (firebaseUser == null) throw Exception('User not found'); return Auth.userFromFirebaseUser(firebaseUser); }); } Future<void> signOut() async { // Delete FCM token before logout try { final user = model.currentUser; if (user != null && user.fcmToken != null) { await SubscriptionService.updateMessagingToken(user.id, user.fcmToken, delete: true); } } catch (err) { print(err); } finally { await _auth.signOut(); } return; } static User userFromFirebaseUser(FirebaseUser firebaseUser) { var isAnon = firebaseUser.isAnonymous; var provider = firebaseUser.providerId; var name = isAnon ? "Anonim" : firebaseUser.displayName; var avatar = isAnon ? DEFAULT_AVATAR_IMAGE : firebaseUser.photoUrl; if (!isAnon && firebaseUser.providerData.isNotEmpty) { var info = firebaseUser.providerData.firstWhere((i) { return i.displayName != null && i.displayName.trim().length > 0; }); provider = info.providerId; name = info.displayName; avatar = info.photoUrl != null ? info.photoUrl : DEFAULT_AVATAR_IMAGE; } return User( id: firebaseUser.uid, name: name, provider: provider, isAnonymous: isAnon, avatar: avatar); } static void onAuthStateChanged(Function callback) { FirebaseAuth.instance.onAuthStateChanged.listen((firebaseUser) { if (firebaseUser == null) { callback(null); } else { callback(Auth.userFromFirebaseUser(firebaseUser)); } }); } }
0
mirrored_repositories/gatrabali-app
mirrored_repositories/gatrabali-app/lib/config.dart
const API_HOST = "https://gatrabali.web.app/api/v1"; const APP_VERSION = "1.0.11"; const FEED_SOURCES = "balebengong.id, balipost.com, balipuspanews.com, jawapos.com, metrobali.com"; const DEFAULT_AVATAR_IMAGE = "https://firebasestorage.googleapis.com/v0/b/gatrabali.appspot.com/o/app%2Favatar.png?alt=media"; const KRIMINAL_CATEGORY_ID = 11; const BALIUNITED_CATEGORY_ID = 12; const BALEBENGONG_FEED_IDS = [33, 34, 35, 36, 37, 38, 39, 40]; const ANDROID_APP_ID = "com.gatrabali.android"; const IOS_APP_ID = "0"; // not yet supported
0
mirrored_repositories/gatrabali-app
mirrored_repositories/gatrabali-app/lib/icons.dart
/// Flutter icons GatraBaliIcons /// Copyright (C) 2019 by original authors @ fluttericon.com, fontello.com /// This font was generated by FlutterIcon.com, which is derived from Fontello. /// /// To use this font, place it in your fonts/ directory and include the /// following in your pubspec.yaml /// /// flutter: /// fonts: /// - family: GatraBaliIcons /// fonts: /// - asset: fonts/GatraBaliIcons.ttf /// /// /// import 'package:flutter/widgets.dart'; class GatraBaliIcons { GatraBaliIcons._(); static const _kFontFam = 'GatraBaliIcons'; static const IconData balebengong = const IconData(0xe800, fontFamily: _kFontFam); }
0
mirrored_repositories/gatrabali-app
mirrored_repositories/gatrabali-app/lib/main.dart
import 'package:flutter/material.dart'; import 'package:gatrabali/models/entry.dart'; import 'package:scoped_model/scoped_model.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:gatrabali/auth.dart'; import 'package:gatrabali/repository/subscriptions.dart'; import 'package:gatrabali/repository/remote_config.dart'; import 'package:gatrabali/scoped_models/app.dart'; import 'package:gatrabali/models/user.dart'; import 'package:gatrabali/icons.dart'; import 'package:gatrabali/view/profile.dart'; import 'package:gatrabali/view/latest_news.dart'; import 'package:gatrabali/view/category_news_tabbed.dart'; import 'package:gatrabali/view/bookmarks.dart'; import 'package:gatrabali/view/category_news.dart'; import 'package:gatrabali/view/single_news.dart'; import 'package:gatrabali/view/balebengong.dart'; import 'package:gatrabali/view/about.dart'; import 'package:gatrabali/view/comments.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { final AppModel _model = AppModel(); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'BaliFeed', theme: ThemeData(primarySwatch: Colors.green), onGenerateRoute: _generateRoute, home: ScopedModel<AppModel>( model: _model, child: GatraBali(), )); } // We use this so we can pass _model to the widget. Route<dynamic> _generateRoute(settings) { // handles /CategoryNews if (settings.name == CategoryNews.routeName) { final CategoryNewsArgs args = settings.arguments; return MaterialPageRoute( builder: (context) => CategoryNews( categoryId: args.id, categoryName: args.name, model: _model)); } // handles /SingleNews if (settings.name == SingleNews.routeName) { final SingleNewsArgs args = settings.arguments; return MaterialPageRoute( builder: (context) => SingleNews( title: args.title, entry: args.entry, model: _model, id: args.id, showAuthor: args.showAuthor, )); } // handles /Profile if (settings.name == Profile.routeName) { var closeAfterLogin = settings.arguments as bool == true; return MaterialPageRoute( builder: (context) => Profile(auth: Auth(_model), closeAfterLogin: closeAfterLogin), fullscreenDialog: true); } // handles /About if (settings.name == About.routeName) { return MaterialPageRoute( builder: (context) => About(), fullscreenDialog: true); } // handles /Comments if (settings.name == Comments.routeName) { final CommentsArgs args = settings.arguments; return MaterialPageRoute( builder: (context) => Comments(model: _model, entry: args.entry), fullscreenDialog: true); } return null; } } class GatraBali extends StatefulWidget { final _appBarTitles = [ Text("Bali Terkini"), Text("Berita Daerah"), Text("Bale Bengong"), Text("Berita Disimpan") ]; @override _GatraBaliState createState() => _GatraBaliState(); } class _GatraBaliState extends State<GatraBali> { int _selectedIndex; List<Widget> _pages; final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); @override void initState() { _selectedIndex = 0; _pages = [ LatestNews(), CategoryNewsTabbed(), BaleBengong(), Bookmarks(), ]; // Get remote config and store it to model setupRemoteConfig().then((config) async { AppModel.of(context).setRemoteConfig(config); try { // Using default duration to force fetching from remote server. await config.fetch(expiration: const Duration(seconds: 0)); await config.activateFetched(); AppModel.of(context).setRemoteConfig(config); } catch (err) { print(err); } }); // Listen for Firebase auth changed Auth.onAuthStateChanged((User user) { AppModel.of(context).setUser(user); if (user != null) { _enableMessaging(user); } }); super.initState(); } // TODO: Move this code to its own package void _enableMessaging(User user) { _firebaseMessaging.configure( onMessage: (Map<String, dynamic> message) async { print("onMessage: $message"); }, onLaunch: (Map<String, dynamic> message) async { print("onLaunch: $message"); _handleMessagingData(message); }, onResume: (Map<String, dynamic> message) async { print("onResume: $message"); _handleMessagingData(message); }, ); _firebaseMessaging.requestNotificationPermissions( const IosNotificationSettings(sound: true, badge: true, alert: true)); _firebaseMessaging.onIosSettingsRegistered .listen((IosNotificationSettings settings) { print("IosNotificationSettings registered: $settings"); }); _firebaseMessaging.getToken().then((String token) async { if (token != null) { try { await SubscriptionService.updateMessagingToken(user.id, token); user.fcmToken = token; AppModel.of(context).setUser(user); } catch (err) { print(err); } } }); } // TODO: Move this code to its own package void _handleMessagingData(Map<String, dynamic> message) { final data = message["data"]; final dataType = data["data_type"]; final entryId = int.parse(data["entry_id"]); final entryTitle = data["entry_title"]; final categoryId = int.parse(data["category_id"]); final categoryTitle = data["category_title"]; final feedId = int.parse(data["feed_id"]); final publishedAt = int.parse(data["published_at"]); var entry = Entry(); entry.id = entryId; entry.categoryId = categoryId; entry.feedId = feedId; entry.publishedAt = publishedAt; entry.title = entryTitle; if (dataType == "entry") { Navigator.of(context).pushNamed(SingleNews.routeName, arguments: SingleNewsArgs(categoryTitle, entry, id: entryId)); } if (dataType == "response") { Navigator.of(context) .pushNamed(Comments.routeName, arguments: CommentsArgs(entry)); } } @override Widget build(BuildContext ctx) { var user = AppModel.of(ctx).currentUser; Widget profileIcon = Icon(Icons.account_circle); if (user != null) { profileIcon = CircleAvatar(backgroundImage: NetworkImage(user.avatar), radius: 12); } return Scaffold( appBar: AppBar( title: widget._appBarTitles[_selectedIndex], elevation: 0, actions: [ IconButton( icon: profileIcon, onPressed: () { Navigator.of(ctx).pushNamed(Profile.routeName); }), Padding( padding: EdgeInsets.only(right: 10.0), child: IconButton( icon: Icon(Icons.help), onPressed: () { Navigator.of(ctx).pushNamed(About.routeName); })), ]), body: IndexedStack( children: _pages, index: _selectedIndex, ), bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.fixed, currentIndex: _selectedIndex, onTap: (int index) { setState(() { _selectedIndex = index; }); }, items: [ BottomNavigationBarItem( icon: Icon(Icons.home), title: Text("Terbaru")), BottomNavigationBarItem( icon: Icon(Icons.grain), title: Text("Daerah")), BottomNavigationBarItem( icon: Icon(GatraBaliIcons.balebengong, size: 20), title: Text("Bale Bengong")), BottomNavigationBarItem( icon: Icon(Icons.bookmark), title: Text("Disimpan")), ], ), drawer: Drawer( child: ListView( children: _drawerItems(), ), )); } List<Widget> _drawerItems() { var items = <Widget>[]; AppModel.of(context).categories.forEach((id, title) { // Don;t show balebengong categories. if (id < 13) { items.add(Card( elevation: 0, margin: EdgeInsets.symmetric(horizontal: 0, vertical: 1.0), child: ListTile( leading: Icon(Icons.folder_open, color: Colors.green), contentPadding: EdgeInsets.symmetric(vertical: 0, horizontal: 20), title: Text('Berita $title'), onTap: () { Navigator.of(context).popAndPushNamed(CategoryNews.routeName, arguments: CategoryNewsArgs(id, title)); }, ))); } }); return items; } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/repository/responses.dart
import 'dart:async'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:gatrabali/models/response.dart'; import 'package:gatrabali/models/entry.dart'; const RESPONSES_COLLECTION = "entry_responses"; class ResponseService { static Future<Response> getUserReaction(Entry entry, String userId) { return Firestore.instance .collection(RESPONSES_COLLECTION) .where("user_id", isEqualTo: userId) .where("entry_id", isEqualTo: entry.id) .where("type", isEqualTo: TYPE_REACTION) .limit(1) .getDocuments() .then((docs) { if (docs.documents.isEmpty) throw Exception("Reaction not found"); return Response.fromDocument(docs.documents[0]); }); } static Future<Response> saveUserReaction(Response reaction) { final now = DateTime.now().millisecondsSinceEpoch; if (reaction.id != null) { // Update reaction.updatedAt = now; return Firestore.instance .collection(RESPONSES_COLLECTION) .document(reaction.id) .updateData(reaction.toJson()) .then((_) => reaction); } else { // Create return Firestore.instance .collection(RESPONSES_COLLECTION) .add(reaction.toJson()) .then((docref) { reaction.id = docref.documentID; return reaction; }); } } static Future<List<Response>> getEntryComments(int entryId, {int cursor, int limit = 10}) { var query = Firestore.instance .collection(RESPONSES_COLLECTION) .where("entry_id", isEqualTo: entryId) .where("type", isEqualTo: TYPE_COMMENT) .where("parent_id", isNull: true) .orderBy("created_at", descending: true) .limit(limit); if (cursor != null) { query = query.startAfter([cursor]); } return query.getDocuments().then((snaps) { return snaps.documents.map((doc) { return Response.fromDocument(doc); }).toList(); }).catchError((err) { print(err); return List<Response>(); }); } static Future<List<Response>> getCommentReplies(String commentId, {int cursor, int limit = 10}) { var query = Firestore.instance .collection(RESPONSES_COLLECTION) .where("type", isEqualTo: TYPE_COMMENT) .where("thread_id", isEqualTo: commentId) .orderBy("created_at", descending: true) .limit(limit); if (cursor != null) { query = query.startAfter([cursor]); } return query.getDocuments().then((snaps) { return snaps.documents.map((doc) { return Response.fromDocument(doc); }).toList(); }).catchError((err) { print(err); return List<Response>(); }); } static Future<void> deleteComment(Response comment) { return Firestore.instance .collection(RESPONSES_COLLECTION) .document(comment.id) .delete(); } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/repository/subscriptions.dart
import 'dart:async'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:gatrabali/models/subscription.dart'; class SubscriptionService { // Register or deregister FCM token static Future<void> updateMessagingToken(String userID, String token, {bool delete = false}) async { final tokensField = 'fcm_tokens'; var user = await Firestore.instance.collection('/users').document(userID).get(); // user record not exists, not delete -> create user if (!user.exists && !delete) { final tokens = {token: true}; await Firestore.instance .collection('/users') .document(userID) .setData({tokensField: tokens}); print("new user + fcm token created"); return; } // user record exists if (user.exists) { var userData = user.data; var tokens = userData[tokensField] == null ? {} : userData[tokensField]; if (delete) { tokens.remove(token); } else { tokens[token] = true; } await user.reference.updateData({tokensField: tokens}); } print("user + fcm token updated/deleted"); return; } // Get user's alert subscription for a category static Future<Subscription> getCategorySubscription( String userId, String categoryId) { return Firestore.instance .collection('/categories/$categoryId/subscribers') .document(userId) .get() .then((doc) { if (!doc.exists) throw Exception('entry ${doc.reference.path} not exists'); return Subscription.fromDocument(doc); }); } // Subscribe to a category static Future<void> subscribeToCategory(String userId, String categoryId, {bool delete = false}) { var collectionName = '/categories/$categoryId/subscribers'; if (!delete) { var sub = Subscription( userId: userId, subscribedAt: DateTime.now().millisecondsSinceEpoch); return Firestore.instance .collection(collectionName) .document(userId) .setData(sub.toMap()); } else { return Firestore.instance .collection(collectionName) .document(userId) .delete(); } } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/repository/remote_config.dart
import 'dart:async'; import 'package:firebase_remote_config/firebase_remote_config.dart'; Future<RemoteConfig> setupRemoteConfig() async { final RemoteConfig remoteConfig = await RemoteConfig.instance; remoteConfig.setConfigSettings(RemoteConfigSettings(debugMode: false)); remoteConfig.setDefaults(<String, dynamic>{ 'cloudinary_fetch_url': '', }); return remoteConfig; }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/repository/feeds.dart
import 'dart:async'; import 'package:http/http.dart' as http; import 'dart:convert' as convert; import 'package:gatrabali/config.dart'; import 'package:gatrabali/models/feed.dart'; class FeedService { /// Returns all feeds. static Future<List<Feed>> fetchFeeds() { print('FeedService.fetchFeeds()...'); return http.get('$API_HOST/feeds').then((resp) { print('FeedService.fetchFeeds() finished.'); if (resp.statusCode == 200) { List<dynamic> feeds = convert.jsonDecode(resp.body); return Future.value(feeds.map((f) => Feed.fromJson(f)).toList()); } throw Exception(resp.body); }); } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/repository/entries.dart
import 'dart:async'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:http/http.dart' as http; import 'dart:convert' as convert; import 'package:gatrabali/config.dart'; import 'package:gatrabali/models/entry.dart'; class EntryService { /// Returns all entries. static Future<List<Entry>> fetchEntries( {int categoryId, int cursor, int limit = 10}) { var category = categoryId == null ? '' : categoryId; if (category == KRIMINAL_CATEGORY_ID) { return fetchKriminalEntries(cursor: cursor, limit: limit); } else if (category == BALIUNITED_CATEGORY_ID) { return fetchBaliUnitedEntries(cursor: cursor, limit: limit); } var url = cursor == null ? '$API_HOST/entries?categoryId=$category&limit=$limit' : '$API_HOST/entries?categoryId=$category&cursor=$cursor&limit=$limit'; print('EntryService.fetchEntries() => $url ...'); return http.get(url).then((resp) { print('EntryService.fetchEntries() finished.'); if (resp.statusCode == 200) { List<dynamic> entries = convert.jsonDecode(resp.body); return entries.map((f) => Entry.fromJson(f)).toList(); } throw Exception(resp.body); }); } /// Returns all Kriminal entries. static Future<List<Entry>> fetchKriminalEntries( {int cursor = 0, int limit = 10}) { var url = '$API_HOST/kriminal/entries?cursor=$cursor&limit=$limit'; print('EntryService.fetchKriminalEntries() => $url ...'); return http.get(url).then((resp) { print('EntryService.fetchKriminalEntries() finished.'); if (resp.statusCode == 200) { List<dynamic> entries = convert.jsonDecode(resp.body); return entries.map((f) => Entry.fromJson(f)).toList(); } throw Exception(resp.body); }); } /// Returns all BU entries. static Future<List<Entry>> fetchBaliUnitedEntries( {int cursor = 0, int limit = 10}) { var url = '$API_HOST/baliunited/entries?cursor=$cursor&limit=$limit'; print('EntryService.fetchBaliUnitedEntries() => $url ...'); return http.get(url).then((resp) { print('EntryService.fetchBaliUnitedEntries() finished.'); if (resp.statusCode == 200) { List<dynamic> entries = convert.jsonDecode(resp.body); return entries.map((f) => Entry.fromJson(f)).toList(); } throw Exception(resp.body); }); } /// Returns all entries in Balebengong. static Future<List<Entry>> fetchBalebengongEntries( {int categoryId, int cursor = 0, int limit = 10}) { var category = categoryId == 0 ? '' : categoryId; var url = '$API_HOST/balebengong/entries?categoryId=$category&cursor=$cursor&limit=$limit'; print('EntryService.fetchBalebengongEntries() => $url ...'); return http.get(url).then((resp) { print('EntryService.fetchBalebengongEntries() finished.'); if (resp.statusCode == 200) { List<dynamic> entries = convert.jsonDecode(resp.body); return entries.map((f) => Entry.fromJson(f)).toList(); } throw Exception(resp.body); }); } /// Check to see if an entry is bookmarked by user static Future<bool> isBookmarked(String userId, int entryId) { return Firestore.instance .collection('/users/$userId/bookmarks') .document(entryId.toString()) .get() .then((bookmark) { if (bookmark.exists) return true; return false; }); } /// Bookmark an entry static Future<void> bookmark(String userId, Entry entry, {bool delete = false}) { var collectionName = '/users/$userId/bookmarks'; if (!delete) { return Firestore.instance .collection(collectionName) .document(entry.id.toString()) .setData({ 'entry_id': entry.id, 'bookmarked_at': FieldValue.serverTimestamp(), 'title': entry.title, 'picture': entry.picture, 'feed_id': entry.feedId, 'category_id': entry.categoryId, 'published_at': entry.publishedAt }); } else { return Firestore.instance .collection(collectionName) .document(entry.id.toString()) .delete(); } } /// Returns all user bookmarks static Future<List<BookmarkEntry>> getBookmarks(String userId, {int cursor = 0, limit = 20}) { return Firestore.instance .collection('/users/$userId/bookmarks') // .startAfter([cursor.toString()]) .limit(limit) .orderBy('bookmarked_at', descending: true) .getDocuments() .then((result) { return result.documents .map((doc) => BookmarkEntry.fromDocument(doc)) .toList(); }).catchError((err) => print(err)); } /// Returns bookmarks snapshot static Stream<QuerySnapshot> bookmarksSnapshot(String userId) { return Firestore.instance .collection('users/$userId/bookmarks') .orderBy('bookmarked_at', descending: true) .snapshots(); } /// Return entry by ID static Future<Entry> getEntryById(int id, {int categoryID, int feedID}) { var url = '$API_HOST/entries/$id'; // Override url if category is kriminal or baliunited if (categoryID != null) { if (categoryID == 11) { url = '$API_HOST/kriminal/entries/$id'; } else if (categoryID == 12) { url = '$API_HOST/baliunited/entries/$id'; } } // Override url if feed ID is belongs to BaleBengong if (feedID != null) { if (BALEBENGONG_FEED_IDS.indexOf(feedID) != -1) { url = '$API_HOST/balebengong/entries/$id'; } } print('EntryService.getEntryById() => $url ...'); return http.get(url).then((resp) { print('EntryService.getEntryById() finished.'); if (resp.statusCode == 200) { Map<String, dynamic> e = convert.jsonDecode(resp.body); return Entry.fromJson(e); } throw Exception(resp.body); }); } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/view/profile.dart
import 'package:flutter/material.dart'; import 'package:toast/toast.dart'; import 'package:gatrabali/auth.dart'; import 'package:gatrabali/models/user.dart'; class Profile extends StatefulWidget { static final routeName = 'Profile'; final Auth auth; final bool closeAfterLogin; Profile({this.auth, this.closeAfterLogin = false}); @override _ProfileState createState() => _ProfileState(); } class _ProfileState extends State<Profile> { User _user; bool _isLoggedIn = false; bool _loggingOut = false; bool _loading = false; String _loginWith = ""; TextStyle _style = TextStyle(color: Colors.white, fontSize: 20); @override void initState() { widget.auth.currentUser().then((user) { setState(() { _user = user; _isLoggedIn = true; }); }).catchError((err) { print(err); setState(() { _isLoggedIn = false; }); }); super.initState(); } // --- LOGIN & LOGOUT METHODS --- // // Start Anonymous Signin void _anonymousSignIn() async { if (_loading) return; setState(() { _loading = true; _loginWith = "anonymous"; }); try { var user = await widget.auth.anonymousSignIn(); setState(() { _loading = false; _loginWith = ""; _user = user; _isLoggedIn = true; }); _toast(context, "Login sebagai Anonim berhasil", Colors.black); if (widget.closeAfterLogin) { Navigator.of(context).pop(true); } } catch (err) { print(err); _toast(context, 'Gagal membuat akun anonim', Colors.red); } finally { setState(() { _loginWith = ""; _loading = false; }); } } // Start Google Signin void _googleSignIn({bool linkAccount = false}) async { if (_loading) return; setState(() { _loading = true; _loginWith = "google"; }); try { var user = await widget.auth.googleSignIn(linkAccount: linkAccount); setState(() { _loading = false; _loginWith = ""; _user = user; _isLoggedIn = true; }); _toast(context, "Login dengan Google berhasil", Colors.black); if (widget.closeAfterLogin) { Navigator.of(context).pop(true); } } catch (err) { print(err); _toast(context, 'Gagal login dengan Google', Colors.red); } finally { setState(() { _loginWith = ""; _loading = false; }); } } // Start Facebook Signin void _facebookSignIn({bool linkAccount = false}) async { if (_loading) return; setState(() { _loading = true; _loginWith = "facebook"; }); try { var user = await widget.auth.facebookSignIn(linkAccount: linkAccount); setState(() { _loading = false; _loginWith = ""; _user = user; _isLoggedIn = true; }); _toast(context, "Login dengan Facebook berhasil", Colors.black); if (widget.closeAfterLogin) { Navigator.of(context).pop(true); } } catch (err) { print(err); setState(() { _loginWith = ""; _loading = false; }); _toast(context, 'Gagal login dengan Facebook', Colors.red); } } // Link anon account to Google void _googleLinkAccount() async { _googleSignIn(linkAccount: true); } // Link anon account to facebook void _facebookLinkAccount() async { _facebookSignIn(linkAccount: true); } // Start Signout void _signOut() async { if (_loading) return; if (_user.isAnonymous) { var confirm = await showDialog( context: context, builder: (BuildContext ctx) { return AlertDialog( title: new Text("Konfirmasi"), content: new Text( "Anda akan logout dari akun Anonim, semua berita yang anda simpan akan hilang."), actions: [ new FlatButton( child: new Text("BATALKAN"), onPressed: () { Navigator.of(context).pop(false); }, ), new FlatButton( textColor: Colors.red, child: new Text("LOGOUT"), onPressed: () { Navigator.of(context).pop(true); }, ), ], ); }); if (!confirm) { return; } } setState(() { _loggingOut = true; }); try { await widget.auth.signOut(); setState(() { _isLoggedIn = false; _loggingOut = false; _user = null; _toast(context, 'Anda berhasil logout', Colors.black); }); } catch (err) { print(err); _toast(context, 'Logout gagal', Colors.red); } finally { setState(() { _loggingOut = false; }); } } // -- END LOGIN & LOGOUT METHODS -- // // -- BUTTONS -- // Widget _anonymousButton(VoidCallback cb) { return Material( elevation: 0, borderRadius: BorderRadius.circular(5.0), color: Colors.black, child: MaterialButton( minWidth: MediaQuery.of(context).size.width, padding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), onPressed: cb, child: Text("Buat Akun Anonim", textAlign: TextAlign.center, style: _style), ), ); } Widget _facebookButton(VoidCallback cb) { return Material( elevation: 0, borderRadius: BorderRadius.circular(5.0), color: Color(0xff3b5998), child: MaterialButton( minWidth: MediaQuery.of(context).size.width, padding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), onPressed: cb, child: Text("Facebook", textAlign: TextAlign.center, style: _style), ), ); } Widget _googleButton(VoidCallback cb) { return Material( elevation: 0, borderRadius: BorderRadius.circular(5.0), color: Color(0xffDB4437), child: MaterialButton( minWidth: MediaQuery.of(context).size.width, padding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), onPressed: cb, child: Text("Google", textAlign: TextAlign.center, style: _style), ), ); } Widget _signOutButton(VoidCallback cb) { return Material( elevation: 0, borderRadius: BorderRadius.circular(5.0), color: Colors.grey, child: MaterialButton( minWidth: MediaQuery.of(context).size.width, onPressed: cb, child: Text("Log out", textAlign: TextAlign.center, style: _style), ), ); } // -- END BUTTONS --// // Display toast void _toast(BuildContext ctx, String message, Color color) { Toast.show(message, ctx, duration: Toast.LENGTH_LONG, gravity: Toast.BOTTOM, backgroundColor: color, backgroundRadius: 5.0); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Profil'), elevation: 0, ), body: SingleChildScrollView( child: Container( padding: EdgeInsets.symmetric(vertical: 50, horizontal: 30), child: _isLoggedIn ? _buildProfileScreen() : _buildLoginScreen())), ); } // Profile screeen for loggedin user Widget _buildProfileScreen() { final logoutLoading = CircularProgressIndicator(strokeWidth: 2); return Container( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ CircleAvatar( backgroundColor: Colors.grey, backgroundImage: NetworkImage(_user.avatar), radius: 50.0), SizedBox(height: 10.0), Text( _user.name, textAlign: TextAlign.center, style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold), ), SizedBox(height: 30.0), Divider(), SizedBox(height: 20.0), !_user.isAnonymous ? Text( 'Terima kasih telah membuat akun di BaliFeed. Anda bisa menyimpan, mengaktifkan notifikasi berita serta otomatis tersingkronisasi dengan perangkat lain apabila anda login dengan akun yang sama.', textAlign: TextAlign.center, style: TextStyle(fontSize: 14.0, color: Colors.grey), ) : _buildAccountLinker(), SizedBox(height: 20.0), Divider(), SizedBox(height: 30.0), (_loggingOut ? logoutLoading : _signOutButton(_signOut)) ], ), ); } Widget _buildAccountLinker() { return Column( children: [ Text("Hubungkan Akun", style: TextStyle( fontSize: 16.0, color: Colors.black, fontWeight: FontWeight.w600)), SizedBox(height: 10), Text( 'Akun anda adalah akun anonim, untuk dapat menggunakan fitur Komentar, Komunitas, dll. (akan hadir di versi berikutnya) silahkan hubungkan akun Anonim anda dengan salah satu akun berikut ini:', textAlign: TextAlign.center, style: TextStyle(fontSize: 14.0, color: Colors.grey), ), SizedBox(height: 25.0), _loginButton('google', _googleButton(_googleLinkAccount)), SizedBox(height: 15.0), _loginButton('facebook', _facebookButton(_facebookLinkAccount)), SizedBox(height: 15.0), ], ); } // Screen for non loggedin user Widget _buildLoginScreen() { return Container( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset('assets/images/icon.png', width: 80, height: 80), SizedBox(height: 30.0), Text( 'Untuk dapat menyimpan berita, menerima notifikasi, silahkan buat akun terlebih dahulu:', textAlign: TextAlign.center, style: TextStyle(fontSize: 16.0), ), SizedBox(height: 30.0), _loginButton('anonymous', _anonymousButton(_anonymousSignIn)), SizedBox(height: 15.0), Text( 'Akun Anonim adalah akun yang bisa anda buat tanpa perlu data pribadi seperti Nama, Email dan Foto.', textAlign: TextAlign.center, style: TextStyle(fontSize: 13.0, color: Colors.grey), ), SizedBox(height: 30.0), Text( 'Atau dengan akun media sosial berikut ini:', textAlign: TextAlign.center, style: TextStyle(fontSize: 16.0), ), SizedBox(height: 25.0), _loginButton('google', _googleButton(_googleSignIn)), SizedBox(height: 25.0), _loginButton('facebook', _facebookButton(_facebookSignIn)), SizedBox(height: 15.0), Text( 'Login dengan akun Facebook atau Google membuat anda secara otomatis bisa menggunakan fitur Komentar, Komunitas, dll. yang akan hadir di versi BaliFeed berikutnya.', textAlign: TextAlign.center, style: TextStyle(fontSize: 13.0, color: Colors.grey), ) ], ), ); } Widget _loginButton(String provider, Widget btn) { if (_loading && _loginWith == provider) { return CircularProgressIndicator(strokeWidth: 2); } return btn; } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/view/comments.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:scoped_model/scoped_model.dart'; import 'package:toast/toast.dart'; import 'package:gatrabali/models/response.dart'; import 'package:gatrabali/models/entry.dart'; import 'package:gatrabali/scoped_models/app.dart'; import 'package:gatrabali/view/profile.dart'; import 'package:gatrabali/view/single_news.dart'; import 'package:gatrabali/repository/responses.dart'; class CommentsArgs { Entry entry; CommentsArgs(this.entry); } class Comments extends StatelessWidget { static final routeName = '/Comments'; final Entry entry; final AppModel model; Comments({this.model, this.entry}); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white.withOpacity(0.95), appBar: AppBar( title: Text(entry.title), actions: [ IconButton( icon: Icon(Icons.description), onPressed: () { Navigator.of(context).pushNamed(SingleNews.routeName, arguments: SingleNewsArgs("", entry, id: entry.id)); }, padding: EdgeInsets.only(right: 15.0), ) ], ), body: ScopedModel(model: this.model, child: ChatScreen(this.entry)), ); } } class ChatScreen extends StatefulWidget { final Entry entry; ChatScreen(this.entry); @override State createState() => ChatScreenState(); } class ChatScreenState extends State<ChatScreen> { final ScrollController _scrollController = ScrollController(); final TextEditingController _textEditingController = TextEditingController(); final FocusNode _focusNode = FocusNode(); final _limit = 10; bool _loading = true; bool _loadingMore = false; String _loadingRepliesFor; bool _posting = false; int _cursor; Response _replyTo; Response _replyToThread; List<Response> _comments = List<Response>(); @override void initState() { super.initState(); _loadComments(); } @override void dispose() { _scrollController.dispose(); _textEditingController.dispose(); _focusNode.dispose(); super.dispose(); } // handles back button/ device backpress Future<bool> _onBackPress() { Navigator.pop(context); return Future.value(false); } // open login/profile screen void _login() { Navigator.of(context).pushNamed(Profile.routeName, arguments: true); } void _loadComments({bool loadmore = false}) { if (loadmore) { setState(() { _loadingMore = true; }); } ResponseService.getEntryComments( widget.entry.id, limit: _limit, cursor: _cursor, ).then((comments) { setState(() { // set cursor value if (comments.length < _limit) { _cursor = null; } else { _cursor = comments.last.createdAt; } if (loadmore) { // append _loadingMore = false; _comments.addAll(comments); } else { // replace _loading = false; _comments = comments; } }); }); } void _loadReplies(Response comment) { if (_loadingRepliesFor != null) return; setState(() { _loadingRepliesFor = comment.id; }); ResponseService.getCommentReplies(comment.id).then((comments) { setState(() { _comments.forEach((c) { if (c.id == comment.id) { c.replies = comments; } }); _loadingRepliesFor = null; }); }); } // send the comment void _postComment() async { if (_textEditingController.text.trim().length == 0) return; final user = AppModel.of(context).currentUser; var comment = Response.create( TYPE_COMMENT, widget.entry, user, comment: _textEditingController.text, parentId: (_replyTo != null) ? _replyTo.id : null, threadId: (_replyToThread != null) ? _replyToThread.id : null, ); try { setState(() { _posting = true; }); comment = await ResponseService.saveUserReaction(comment); // add to main list or to parent if (_replyToThread == null) { setState(() { _comments.add(comment); }); _scrollController .jumpTo(_scrollController.position.maxScrollExtent + 100.0); } else { _comments.forEach((c) { if (c.id == _replyToThread.id) { c.replies.add(comment); } }); } // clear text edit _textEditingController.clear(); // remove focus from text edit _focusNode.unfocus(); // reset reply to _resetReplyTo(); } catch (err) { print(err); Toast.show( 'Maaf, komentar gagal terkirim!', context, backgroundColor: Colors.red, ); _textEditingController.text = comment.comment; } finally { setState(() { _posting = false; }); } } void _setReplyTo(Response comment, Response thread) { setState(() { _replyTo = comment; _replyToThread = thread; _focusNode.unfocus(); _focusNode.requestFocus(); if (comment.id != thread.id) { _textEditingController.text = "@${comment.user.name}, "; } }); } void _resetReplyTo() { setState(() { _replyTo = null; _replyToThread = null; _focusNode.unfocus(); _textEditingController.clear(); }); } void _deleteComment(Response comment) async { try { await ResponseService.deleteComment(comment); setState(() { // try to remove from top level final removed = _comments.remove(comment); // not top level, remove reply if (!removed) { final thread = _comments.firstWhere((c) => c.id == comment.threadId); thread.replies.remove(comment); } }); } catch (err) { print(err); Toast.show( 'Maaf, gagal menghapus komentar.', context, backgroundColor: Colors.red, ); } } @override Widget build(BuildContext context) { return WillPopScope( child: Stack( children: [ Column( children: [ // List of messages _buildListMessage(), _buildReplyBar(), // Input content _buildInput() ], ), // Loading _buildLoading() ], ), onWillPop: _onBackPress, ); } Widget _buildReplyBar() { if (_replyTo == null) return Container(); return Container( padding: EdgeInsets.all(12.0), width: double.infinity, color: Colors.green, child: Row( children: [ Text( "Membalas ${_replyTo.user.name}...", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, ), ), GestureDetector( child: Icon( Icons.close, color: Colors.white, size: 20.0, ), onTap: _resetReplyTo, ) ], mainAxisAlignment: MainAxisAlignment.spaceBetween, )); } Widget _buildLoading() { return Positioned( child: _loading ? Container( child: Center( child: CircularProgressIndicator(strokeWidth: 2), ), color: Colors.white.withOpacity(0.8), ) : Container(), ); } Widget _buildNeedLogin() { return Padding( child: ListTile( onTap: _login, leading: Icon(Icons.lock_outline, size: 40.0, color: Colors.green), title: Text( "Untuk bisa memberikan komentar silahkan login terlebih dahulu. Tap disini untuk login.")), padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 10.0)); } Widget _buildNeedUpgradeAccount() { return Padding( child: ListTile( onTap: _login, leading: Icon(Icons.person_outline, size: 40.0, color: Colors.green), title: Text( "Silahkan login dengan akun media sosial anda sebelum bisa memberi komentar. Tap disini untuk login.")), padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 10.0)); } Widget _buildInput() { final user = AppModel.of(context).currentUser; if (user == null) { return _buildNeedLogin(); } if (user != null && user.isAnonymous) { return _buildNeedUpgradeAccount(); } return Container( // height: height, width: double.infinity, decoration: BoxDecoration( border: Border(top: BorderSide(color: Colors.green, width: 0.5)), color: Colors.white), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ // Edit text Flexible( child: Container( padding: EdgeInsets.all(10.0), child: TextField( maxLines: 3, style: TextStyle(fontSize: 15.0), controller: _textEditingController, decoration: InputDecoration( isDense: true, contentPadding: EdgeInsets.all(10.0), filled: true, hintText: "Tulis komentar...", hintStyle: TextStyle(color: Colors.grey), border: InputBorder.none, ), focusNode: _focusNode, ), ), ), // Button send message Material( child: Container( padding: EdgeInsets.only(right: 20.0, left: 5.0), child: _posting ? Container( child: CircularProgressIndicator(strokeWidth: 2.0), width: 30.0, height: 30.0, ) : GestureDetector( child: Icon( Icons.send, size: 30.0, color: Colors.green, ), onTap: _postComment, ), ), color: Colors.white, ), ], )); } Widget _buildCommentMenu(Response comment) { final user = AppModel.of(context).currentUser; // only owner can delete if (user == null || user.isAnonymous || user.id != comment.userId) return Container(); return PopupMenuButton<int>( padding: EdgeInsets.all(1.0), child: Icon( Icons.more_horiz, size: 18, color: Colors.grey, ), itemBuilder: (context) => [ PopupMenuItem( value: 1, child: Text("Hapus", style: TextStyle(fontSize: 15.0)), ), ], onSelected: (int val) { if (val == 1) { _deleteComment(comment); } }, ); } Widget _buildItem(Response comment) { // render loadmore if (comment.type == "LOADMORE") { return Container( padding: EdgeInsets.all(15.0), margin: EdgeInsets.only(bottom: 5.0), color: Colors.white, child: _loadingMore ? Center( child: Container( child: CircularProgressIndicator(strokeWidth: 2), width: 20.0, height: 20.0, ), widthFactor: 1, heightFactor: 1, ) : GestureDetector( child: Text( "Komentar sebelumnya...", textAlign: TextAlign.center, style: TextStyle( color: Colors.grey, fontSize: 15.0, ), ), onTap: () { _loadComments(loadmore: true); }), ); } // render response return Container( padding: EdgeInsets.all(20.0), margin: EdgeInsets.only(bottom: 5.0), color: Colors.white, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row(children: [ CircleAvatar( backgroundColor: Colors.grey, backgroundImage: NetworkImage(comment.user.avatar), radius: 20.0, ), SizedBox(width: 10.0), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(comment.user.name, style: TextStyle( fontWeight: FontWeight.w600, fontSize: 15.0)), Text(comment.formattedDate, style: TextStyle( fontSize: 12.0, color: Colors.grey.withOpacity(0.5))), ]), ), _buildCommentMenu(comment), ]), SizedBox(height: 15.0), Text(comment.comment, style: TextStyle(fontSize: 15.0)), SizedBox(height: 15.0), Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: (comment.replyCount != null && comment.replyCount > 0) ? GestureDetector( onTap: () { _loadReplies(comment); }, child: Text( (_loadingRepliesFor != null && _loadingRepliesFor == comment.id) ? "Memuat balasan..." : "${comment.replyCount} balasan", style: TextStyle( fontSize: 12.0, fontWeight: FontWeight.w500, color: Colors.grey), )) : Container(), ), Icon( Icons.reply, size: 16.0, color: Colors.grey, ), GestureDetector( onTap: () { _setReplyTo( comment, comment); // parent and thread are the same }, child: Text( "Balas", style: TextStyle( fontSize: 12.0, fontWeight: FontWeight.w500, color: Colors.grey), )), ]), comment.replies.length == 0 ? Container() : Column(children: [ SizedBox(height: 15.0), _buildReplies(comment, comment) ]) ])); } Widget _buildReplies(Response comment, Response thread) { if (comment.replies.length == 0) return Container(); comment.replies.sort((a, b) => a.createdAt.compareTo(b.createdAt)); return Column( children: comment.replies.map((c) => _buildReply(c, thread)).toList(), ); } Widget _buildReply(Response comment, Response thread) { // render response return Container( padding: EdgeInsets.all(15.0), margin: EdgeInsets.only(bottom: 5.0), color: Colors.grey.withOpacity(0.1), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row(children: [ CircleAvatar( backgroundColor: Colors.grey, backgroundImage: NetworkImage(comment.user.avatar), radius: 15.0, ), SizedBox(width: 10.0), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(comment.user.name, style: TextStyle( fontWeight: FontWeight.w600, fontSize: 14.0)), Text(comment.formattedDate, style: TextStyle( fontSize: 12.0, color: Colors.grey.withOpacity(0.5))), ])), _buildCommentMenu(comment), ]), SizedBox(height: 15.0), Text(comment.comment, style: TextStyle(fontSize: 15.0)), SizedBox(height: 15.0), Row(mainAxisAlignment: MainAxisAlignment.end, children: [ Icon( Icons.reply, size: 16.0, color: Colors.grey, ), GestureDetector( onTap: () { _setReplyTo( comment, thread); // thread is the level 0 response. }, child: Text( "Balas", style: TextStyle( fontSize: 12.0, fontWeight: FontWeight.w500, color: Colors.grey), )), ]) ])); } Widget _buildListMessage() { final comments = List<Response>.from(_comments); comments.sort((a, b) => a.createdAt.compareTo(b.createdAt)); // if more comments possibly still available // add fake response to commenrs so it will be rendered as Load more button. // only loggedin user can load previous comments. final user = AppModel.of(context).currentUser; if (_cursor != null && user != null && !user.isAnonymous) { final resp = Response(); resp.type = "LOADMORE"; comments.insertAll(0, [resp]); } return Flexible( child: ListView.builder( // reverse: true, controller: _scrollController, itemCount: comments.length, itemBuilder: (ctx, index) { return _buildItem(comments[index]); }), ); } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/view/balebengong.dart
import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:toast/toast.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:gatrabali/view/widgets/balebengong_entries.dart'; import 'package:gatrabali/scoped_models/app.dart'; import 'package:gatrabali/repository/subscriptions.dart'; import 'package:gatrabali/models/subscription.dart'; import 'package:gatrabali/view/profile.dart'; class BaleBengong extends StatefulWidget { @override _BaleBengongState createState() => _BaleBengongState(); } class _BaleBengongState extends State<BaleBengong> { String _subscriptionTopic = 'balebengong'; Subscription _subscription; bool _showDescription = true; final String _spShowDescriptionKey = 'balebengong.description.show'; @override void initState() { _loadSharedPreferences(); // Listen for auth state changes AppModel.of(context).addListener(() { if (!mounted) return; final model = AppModel.of(context); if (model.currentUser == null) { setState(() { _subscription = null; }); } else { _loadSubscription(); } }); _loadSubscription(); super.initState(); } void _loadSharedPreferences() async { SharedPreferences prefs = await SharedPreferences.getInstance(); setState(() { var showDesc = prefs.getBool(_spShowDescriptionKey); _showDescription = (showDesc == null || showDesc == true) ? true : false; }); } bool _allowSubscription() { if (AppModel.of(context).currentUser == null) return false; return true; } void _loadSubscription() { if (!_allowSubscription()) return; var currentUser = AppModel.of(context).currentUser; SubscriptionService.getCategorySubscription( currentUser.id, _subscriptionTopic) .then((sub) { setState(() { _subscription = sub; }); }).catchError((err) { print(err); }); } void _subscribe() async { if (!_allowSubscription()) { var isLogin = await Navigator.of(context) .pushNamed(Profile.routeName, arguments: true); if (isLogin == true) { _loadSubscription(); } return; } var currentUser = AppModel.of(context).currentUser; var delete = _subscription != null; setState(() { if (delete) { _subscription = null; } else { _subscription = Subscription(); } }); SubscriptionService.subscribeToCategory(currentUser.id, _subscriptionTopic, delete: delete) .then((_) { if (!delete) { Toast.show('Notifikasi diaktifkan', context, backgroundColor: Colors.black); } else { Toast.show('Notifikasi dinonaktifkan', context, backgroundColor: Colors.black); } }).catchError((err) { print(err); }); } void _openLink() async { await launch("https://balebengong.id/about/", forceSafariVC: false); } void _toggleDescription() async { SharedPreferences prefs = await SharedPreferences.getInstance(); var showDesc = _showDescription ? false : true; await prefs.setBool(_spShowDescriptionKey, showDesc); setState(() { _showDescription = showDesc; }); } @override Widget build(BuildContext context) { var preferredHeight = 280.0; if (!_showDescription) { preferredHeight = 108; } var headerHeight = preferredHeight - 50.0; return DefaultTabController( length: 9, child: new Scaffold( appBar: new PreferredSize( preferredSize: Size.fromHeight(preferredHeight), child: new Container( child: new SafeArea( child: Column( children: [ Container( height: headerHeight, width: double.infinity, color: Colors.white, child: Stack( children: [ _header(), Positioned( right: 0, top: 5, child: IconButton( icon: Icon( _showDescription ? Icons.close : Icons.arrow_drop_down_circle, color: Colors.green), onPressed: _toggleDescription)) ], ), ), Divider(height: 1), new TabBar( isScrollable: true, labelColor: Colors.black, tabs: [ Tab(child: Text("Semua")), Tab(child: Text("Opini")), Tab(child: Text("Sosial")), Tab(child: Text("Budaya")), Tab(child: Text("Lingkungan")), Tab(child: Text("Sosok")), Tab(child: Text("Teknologi")), Tab(child: Text("Agenda")), Tab(child: Text("Travel")), ], ), ], ), ), ), ), body: TabBarView( children: [ BalebengongEntries(0, "Semua"), BalebengongEntries(13, "Opini"), BalebengongEntries(18, "Sosial"), BalebengongEntries(17, "Budaya"), BalebengongEntries(15, "Lingkungan"), BalebengongEntries(16, "Sosok"), BalebengongEntries(14, "Teknologi"), BalebengongEntries(19, "Agenda"), BalebengongEntries(20, "Travel"), ], ), ), ); } Widget _description() { return Column(children: [ SizedBox(height: 30), Image.asset('assets/images/balebengong.png', width: 255), Padding( padding: EdgeInsets.symmetric(horizontal: 30, vertical: 20), child: Text( "BaleBengong adalah portal media jurnalisme warga di Bali. Warga terlibat aktif untuk menulis atau sekadar merespon sebuah kabar.", textAlign: TextAlign.center, style: TextStyle(fontWeight: FontWeight.w400))), ]); } Widget _header() { var notificationText = "Notifikasi "; var notificationColor = Colors.grey; var notificationIcon = Icons.notifications_none; if (_subscription != null) { notificationText = "Notifikasi aktif "; notificationColor = Colors.green; notificationIcon = Icons.notifications_active; } return Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ _showDescription ? _description() : Container(), Padding( padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5), child: Column( children: [ Row( mainAxisAlignment: _showDescription ? MainAxisAlignment.spaceBetween : MainAxisAlignment.start, children: [ FlatButton( child: Row(children: [ Icon(Icons.link, color: Colors.blue), Text(" balebengong.id", style: TextStyle(color: Colors.blue)) ]), onPressed: _openLink), Container( color: Colors.grey.withOpacity(0.5), height: 20, width: 1), FlatButton( child: Row(children: [ Text(notificationText, style: TextStyle(color: notificationColor)), Icon(notificationIcon, color: notificationColor) ]), onPressed: _subscribe) ], ) ], )) ], ); } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/view/about.dart
import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:share/share.dart'; import 'package:launch_review/launch_review.dart'; import 'package:gatrabali/config.dart'; class About extends StatelessWidget { static final routeName = 'About'; void _rate() { LaunchReview.launch(androidAppId: ANDROID_APP_ID, iOSAppId: IOS_APP_ID); } void _share() { Share.share( "Dapatkan berita bali terkini dengan aplikasi BaliFeed. Download disini http://bit.ly/balifeed"); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Tentang BaliFeed'), elevation: 0, ), body: SingleChildScrollView( child: Container( padding: EdgeInsets.symmetric(horizontal: 30, vertical: 40), child: Column( children: [ Image.asset('assets/images/icon.png', width: 80, height: 80), SizedBox(height: 20), Text( 'BaliFeed mengumpulkan berita dari berbagai sumber berita online membuatnya mudah dibaca hanya dengan satu aplikasi.', textAlign: TextAlign.center, style: TextStyle(fontSize: 15.0), ), SizedBox( height: 10.0, ), Text( 'Sumber berita:', textAlign: TextAlign.center, style: TextStyle(fontSize: 15.0), ), Text( FEED_SOURCES, textAlign: TextAlign.center, style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold), ), SizedBox( height: 20.0, ), Divider(), SizedBox( height: 10.0, ), Text('Dukung BaliFeed:', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0)), SizedBox( height: 10.0, ), Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Column(children: [ IconButton( icon: Icon(Icons.star), iconSize: 40, onPressed: _rate, color: Colors.orange, ), Text('Beri Rating') ]), Column( children: [ IconButton( icon: Icon(Icons.share), iconSize: 40, onPressed: _share, color: Colors.green, ), Text('Bagikan') ], ), Column( children: [ IconButton( icon: Icon(Icons.feedback), iconSize: 40, onPressed: () async { await launch( 'https://docs.google.com/forms/d/e/1FAIpQLSehiyEcmkX_FHpG4tkAtmdP0CrAK0UpdAOf7DJc8_PBdDI3Yw/viewform?usp=sf_link', forceSafariVC: false); }, color: Colors.blue, ), Text('Beri Masukan') ], ) ]), SizedBox( height: 10.0, ), Divider(), SizedBox(height: 10.0), Text( 'BaliFeed merupakan sebuah proyek Open Source (Sumber Terbuka), apabila anda ingin berkontribusi dalam pengembangannya silahkan cek kodenya di:', textAlign: TextAlign.center, style: TextStyle(fontSize: 13.0, color: Colors.grey), ), GestureDetector( child: Text( 'https://github.com/apps4bali/gatrabali-app.', textAlign: TextAlign.center, style: TextStyle(fontSize: 13.0, color: Colors.green), ), onTap: () async { await launch('https://github.com/apps4bali/gatrabali-app', forceSafariVC: false); }), SizedBox( height: 10.0, ), Text( 'Anda menemukan bug/kendala, permintaan fitur dan memberi saran juga bisa melalui situs tersebut atau langsung email ke [email protected].', textAlign: TextAlign.center, style: TextStyle(fontSize: 13.0, color: Colors.grey), ), SizedBox( height: 20.0, ), Text( 'BaliFeed v$APP_VERSION', textAlign: TextAlign.center, style: TextStyle( fontSize: 13.0, color: Colors.grey, fontWeight: FontWeight.bold), ), ], ), ))); } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/view/latest_news.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:gatrabali/scoped_models/app.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:gatrabali/repository/entries.dart'; import 'package:gatrabali/models/entry.dart'; import 'package:gatrabali/view/widgets/single_news_card.dart'; import 'package:gatrabali/view/widgets/single_news_nocard.dart'; import 'package:gatrabali/view/widgets/main_cover.dart'; import 'package:gatrabali/view/widgets/main_featured.dart'; class LatestNews extends StatefulWidget { @override _LatestNewsState createState() => _LatestNewsState(); } class _LatestNewsState extends State<LatestNews> { List<Entry> _entries; int _cursor; StreamSubscription _sub; RefreshController _refreshController; @override void initState() { _refreshEntries(); _refreshController = RefreshController(initialRefresh: false); super.initState(); } @override void dispose() { if (_sub != null) { _sub.cancel(); } _refreshController.dispose(); super.dispose(); } void _refreshEntries() { _sub = EntryService.fetchEntries().asStream().listen((entries) { setState(() { if (entries.isNotEmpty) { _cursor = entries.last.publishedAt; _entries = entries; } _refreshController.refreshCompleted(); }); }); _sub.onError((err) { print(err); _refreshController.refreshFailed(); }); } void _loadMoreEntries() { _sub = EntryService.fetchEntries(cursor: _cursor).asStream().listen((entries) { setState(() { if (entries.isNotEmpty) { _cursor = entries.last.publishedAt; _entries.addAll(entries); _refreshController.loadComplete(); } else { _refreshController.loadNoData(); } }); }); _sub.onError((err) => print(err)); } @override Widget build(BuildContext ctx) { return SmartRefresher( controller: _refreshController, enablePullDown: true, enablePullUp: true, onRefresh: () { _refreshEntries(); }, onLoading: () { _loadMoreEntries(); }, child: _buildList(ctx), ); } Widget _buildList(BuildContext ctx) { final cloudinaryFetchUrl = AppModel.of(ctx).getCloudinaryUrl(); var entries = _entries == null ? [] : _entries .map<Entry>((e) => e.setCloudinaryPicture(cloudinaryFetchUrl)) .toList(); return CustomScrollView( slivers: [ SliverList( delegate: SliverChildListDelegate([ Column(children: [ MainCover(), MainFeatured(), Divider(height: 1), SizedBox(height: 15) ]) ])), SliverList( delegate: SliverChildListDelegate(entries .asMap() .map((index, entry) => MapEntry(index, _listItem(ctx, index, entry))) .values .toList())) ], ); } Widget _listItem(BuildContext ctx, int index, Entry entry) { return Padding( padding: new EdgeInsets.symmetric(horizontal: 10, vertical: 6), child: index > 0 // the first item use card ? SingleNewsNoCard( key: ValueKey(entry.id), entry: entry, showCategoryName: true) : SingleNewsCard( key: ValueKey(entry.id), entry: entry, showCategoryName: true)); } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/view/bookmarks.dart
import 'package:flutter/material.dart'; import 'package:toast/toast.dart'; import 'dart:async'; import 'package:gatrabali/scoped_models/app.dart'; import 'package:gatrabali/repository/entries.dart'; import 'package:gatrabali/models/entry.dart'; import 'package:gatrabali/view/widgets/cover_image_decoration.dart'; import 'package:gatrabali/view/widgets/char_thumbnail.dart'; import 'package:gatrabali/view/single_news.dart'; class Bookmarks extends StatefulWidget { @override _BookmarksState createState() => _BookmarksState(); } class _BookmarksState extends State<Bookmarks> { StreamSubscription _snapshotSubscription; List<BookmarkEntry> _entries = <BookmarkEntry>[]; @override void initState() { AppModel.of(context).addListener(() { if (!mounted) return; final model = AppModel.of(context); // - listen for bookmarks changes when user state changed from loggged-out to logged-in. if (model.currentUser != null) { _snapshotSubscription = EntryService.bookmarksSnapshot(model.currentUser.id) .listen((snaps) { setState(() { _entries = snaps.documents .map((d) => BookmarkEntry.fromDocument(d)) .toList(); }); }); } }); super.initState(); } @override void dispose() { if (_snapshotSubscription != null) _snapshotSubscription.cancel(); super.dispose(); } void _deleteBookmark(BookmarkEntry bookmarkEntry) { var user = AppModel.of(context).currentUser; var entry = Entry(); entry.id = bookmarkEntry.entryId; EntryService.bookmark(user.id, entry, delete: true).then((_) { Toast.show('Berita dihapus', context, backgroundColor: Colors.black); }).catchError((err) { print(err); Toast.show('Gagal menghapus berita', context, backgroundColor: Colors.black); }); } @override Widget build(BuildContext ctx) { var user = AppModel.of(ctx).currentUser; if (user == null) { return _buildPlaceholder( 'Silahkan login untuk mengakses berita yang telah anda simpan.'); } if (_entries == null || _entries.isEmpty) { return _buildPlaceholder('Anda belum memiliki berita disimpan.'); } return _buildList(ctx, _entries); } Widget _buildPlaceholder(String message) { return Padding( padding: EdgeInsets.all(30), child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Icon(Icons.bookmark, size: 80, color: Colors.grey), SizedBox(height: 20), Text(message, textAlign: TextAlign.center, style: TextStyle(fontSize: 15.0, color: Colors.grey)) ], ))); } Widget _buildList(BuildContext ctx, List<BookmarkEntry> entries) { final cloudinaryFetchUrl = AppModel.of(ctx).getCloudinaryUrl(); entries = entries .map<BookmarkEntry>((e) => e.setCloudinaryPicture(cloudinaryFetchUrl)) .toList(); return ListView( padding: EdgeInsets.symmetric(vertical: 10.0), children: entries.map((entry) => _listItem(ctx, entry)).toList()); } Widget _listItem(BuildContext ctx, BookmarkEntry bookmark) { var categories = AppModel.of(ctx).categories; Widget thumbnail; if (bookmark.hasPicture) { thumbnail = CoverImageDecoration( url: bookmark.cdnPicture != null ? bookmark.cdnPicture : bookmark.picture, width: 70, height: 50, borderRadius: 5.0); } else { thumbnail = CharThumbnail(char: bookmark.title[0]); } return Padding( padding: EdgeInsets.symmetric(horizontal: 5.0, vertical: 2.0), child: ListTile( onTap: () { var entry = Entry.fromBookmarkEntry(bookmark); Navigator.of(ctx).pushNamed(SingleNews.routeName, arguments: SingleNewsArgs( bookmark.getCategoryName(categories), entry, id: bookmark.entryId, showAuthor: true)); }, leading: thumbnail, trailing: GestureDetector( child: Icon(Icons.delete), onTap: () { _deleteBookmark(bookmark); }), title: Text(bookmark.title, maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle( color: Colors.black87, fontSize: 14.0, fontWeight: FontWeight.bold)), subtitle: Padding( padding: EdgeInsets.only(top: 3.0), child: Text("${bookmark.formattedDate}", maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 12)), ))); } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/view/single_news.dart
import 'package:flutter/material.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:scoped_model/scoped_model.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:share/share.dart'; import 'package:toast/toast.dart'; import 'package:gatrabali/repository/entries.dart'; import 'package:gatrabali/scoped_models/app.dart'; import 'package:gatrabali/models/entry.dart'; import 'package:gatrabali/view/widgets/cover_image_decoration.dart'; import 'package:gatrabali/view/widgets/picture_view.dart'; import 'package:gatrabali/view/widgets/related_entries.dart'; import 'package:gatrabali/view/widgets/reaction_block.dart'; import 'package:gatrabali/view/profile.dart'; class SingleNewsArgs { int id; String title; Entry entry; bool showAuthor; SingleNewsArgs(this.title, this.entry, {this.id, this.showAuthor = false}); } class SingleNews extends StatefulWidget { static final String routeName = '/SingleNews'; final int id; final String title; final Entry entry; final AppModel model; final bool showAuthor; SingleNews( {this.title, this.entry, this.model, this.id, this.showAuthor = false}); @override _SingleNews createState() => _SingleNews(); } class _SingleNews extends State<SingleNews> { Entry _entry; bool _bookmarked = false; bool _loading = false; bool _notFound = false; @override void initState() { _entry = widget.entry; if (widget.id != null) { _loading = true; EntryService.getEntryById(widget.id, categoryID: widget.entry.categoryId, feedID: widget.entry.feedId) .then((entry) { setState(() { _entry = entry; _loading = false; }); }).catchError((err) { print(err); setState(() { _notFound = true; }); }); } if (widget.model.currentUser != null) { _checkBookmark(); } super.initState(); } void _checkBookmark() { EntryService.isBookmarked(widget.model.currentUser.id, _entry.id) .then((bookmarked) { setState(() { _bookmarked = bookmarked; }); }).catchError((err) => print(err)); } bool _allowBookmark() { if (widget.model.currentUser == null) return false; return true; } void _bookmark(BuildContext ctx) async { if (!_allowBookmark()) { var isLogin = await Navigator.of(ctx).pushNamed(Profile.routeName, arguments: true); if (isLogin == true) { _checkBookmark(); } return; } var delete = _bookmarked; setState(() { if (_bookmarked) { _bookmarked = false; } else { _bookmarked = true; } }); EntryService.bookmark(widget.model.currentUser.id, _entry, delete: delete) .then((_) { if (!delete) { Toast.show('Berita disimpan', ctx, backgroundColor: Colors.black); } }).catchError((err) { print(err); }); } @override Widget build(BuildContext ctx) { return Scaffold( body: ScopedModel( model: widget.model, child: _loading ? _loader() : _getBody(ctx))); } Widget _loader() { if (_notFound) { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text('Berita tidak ditemukan.', style: TextStyle(color: Colors.grey, fontSize: 16)), SizedBox(height: 10), RaisedButton( color: Colors.green, textColor: Colors.white, child: Text('Kembali'), onPressed: () { Navigator.of(context).pop(); }, ) ], )); } return Center(child: CircularProgressIndicator(strokeWidth: 2)); } Widget _getBody(BuildContext ctx) { var title = Text(_entry.title, style: TextStyle( color: Colors.white, fontWeight: FontWeight.w600, fontSize: 18.0)); return CustomScrollView(slivers: [ SliverAppBar( floating: true, title: Text(widget.title == null ? _entry.title : widget.title), actions: [ IconButton( onPressed: () { _bookmark(ctx); }, icon: Icon(Icons.bookmark, color: _bookmarked ? Colors.yellow : Colors.white)), Padding( padding: EdgeInsets.only(right: 10), child: IconButton( onPressed: () { Share.share( "${_entry.url} via BaliFeed App (http://bit.ly/balifeed)"); }, icon: Icon(Icons.share))) ]), SliverList( delegate: SliverChildListDelegate([ Stack(children: [ _cover(ctx), Container( height: 250, width: double.infinity, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.bottomLeft, end: Alignment.topLeft, colors: const [Colors.black87, Colors.transparent])), child: Padding(padding: new EdgeInsets.all(20), child: title), alignment: Alignment.bottomLeft, ), Positioned( top: 10, right: 15, child: IconButton( icon: Icon(Icons.fullscreen, size: 40, color: Colors.white), onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (_) { return PictureView(tag: 'fullscreen', url: _entry.picture); })); }), ) ]), SizedBox(height: 20), Html( useRichText: true, data: _entry.content, padding: EdgeInsets.symmetric(horizontal: 20), defaultTextStyle: TextStyle(fontSize: 16), linkStyle: const TextStyle( color: Colors.green, ), onLinkTap: (url) { Toast.show( 'Silahkan buka link tersebut di halaman asli berita ini.', context, duration: Toast.LENGTH_LONG, backgroundColor: Colors.black); }), SizedBox(height: 10), Divider(), _author(), _publishDate(), _source(ctx), ReactionBlock(_entry), // TODO: related entries always re-initialized when its visible causing it always calls API RelatedEntries( title: "Berita lainnya", categoryId: _entry.categoryId, feedId: _entry.feedId, cursor: _entry.publishedAt, limit: 6) ])) ]); } Widget _cover(BuildContext ctx) { if (_entry.hasPicture) { final cloudinaryFetchUrl = widget.model.getCloudinaryUrl(); final entry = _entry.setCloudinaryPicture(cloudinaryFetchUrl); return CoverImageDecoration( url: entry.picture, height: 250.0, width: null); } else { return Container( width: double.infinity, height: 250.0, color: Colors.green, ); } } Widget _source(BuildContext ctx) { return GestureDetector( onTap: () async { await launch(_entry.url, forceSafariVC: false); }, child: Padding( padding: EdgeInsets.only(top: 5, left: 25, bottom: 5), child: Text("Link sumber berita", maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(color: Colors.green), textAlign: TextAlign.left))); } Widget _author() { if (!widget.showAuthor) return Container(); return Padding( padding: EdgeInsets.only(top: 10, left: 25), child: Text("Oleh: ${_entry.author}", style: TextStyle(color: Colors.black), textAlign: TextAlign.left)); } Widget _publishDate() { return Padding( padding: EdgeInsets.only(top: 5, left: 25), child: Text("Tanggal publikasi: ${_entry.formattedDateSimple()}", style: TextStyle(color: Colors.black), textAlign: TextAlign.left)); } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/view/category_news_tabbed.dart
import 'package:flutter/material.dart'; import 'package:gatrabali/view/widgets/category_entries.dart'; import 'package:gatrabali/scoped_models/app.dart'; class CategoryNewsTabbed extends StatefulWidget { @override _CategoryNewsTabbedState createState() => _CategoryNewsTabbedState(); } class _CategoryNewsTabbedState extends State<CategoryNewsTabbed> { @override Widget build(BuildContext context) { var preferredHeight = 50.0; List<Tab> tabs = <Tab>[]; List<Widget> tabViews = <Widget>[]; AppModel.of(context).categories.forEach((id, name) { if (id <= 10) { tabs.add(Tab(child: Text(name))); tabViews.add(CategoryEntries(id, name)); } }); return DefaultTabController( length: 9, child: new Scaffold( appBar: new PreferredSize( preferredSize: Size.fromHeight(preferredHeight), child: new Container( color: Colors.white, child: new SafeArea( child: Column( children: [ new TabBar( isScrollable: true, tabs: tabs, labelColor: Colors.black), Divider(height: 1) ], ), ), ), ), body: TabBarView(children: tabViews)), ); } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/view/category_news.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:scoped_model/scoped_model.dart'; import 'package:toast/toast.dart'; import 'package:gatrabali/scoped_models/app.dart'; import 'package:gatrabali/repository/entries.dart'; import 'package:gatrabali/repository/subscriptions.dart'; import 'package:gatrabali/models/entry.dart'; import 'package:gatrabali/models/subscription.dart'; import 'package:gatrabali/view/widgets/single_news_card.dart'; import 'package:gatrabali/view/widgets/single_news_nocard.dart'; import 'package:gatrabali/view/profile.dart'; class CategoryNewsArgs { int id; String name; CategoryNewsArgs(this.id, this.name); } class CategoryNews extends StatefulWidget { static final String routeName = 'CategoryNews'; final int categoryId; final String categoryName; final AppModel model; CategoryNews({this.categoryId, this.categoryName, this.model}); @override _CategoryNewsState createState() => _CategoryNewsState(); } class _CategoryNewsState extends State<CategoryNews> { List<Entry> _entries; int _cursor; StreamSubscription _sub; // entries RefreshController _refreshController; // notification Subscription _subscription; StreamSubscription _subNotification; @override void initState() { _refreshEntries(); _refreshController = RefreshController(initialRefresh: false); _loadSubscription(); super.initState(); } @override void dispose() { if (_sub != null) { _sub.cancel(); } if (_subNotification != null) { _subNotification.cancel(); } _refreshController.dispose(); super.dispose(); } bool _allowSubscription() { if (widget.model.currentUser == null) return false; return true; } void _loadSubscription() { if (!_allowSubscription()) return; _subNotification = SubscriptionService.getCategorySubscription( widget.model.currentUser.id, widget.categoryId.toString()) .asStream() .listen((sub) { setState(() { _subscription = sub; }); }); _subNotification.onError((err) { print(err); }); } void _subscribe() async { if (!_allowSubscription()) { var isLogin = await Navigator.of(context) .pushNamed(Profile.routeName, arguments: true); if (isLogin == true) { _loadSubscription(); } return; } var delete = _subscription != null; setState(() { if (delete) { _subscription = null; } else { _subscription = Subscription(); } }); SubscriptionService.subscribeToCategory( widget.model.currentUser.id, widget.categoryId.toString(), delete: delete) .then((_) { if (!delete) { Toast.show('Notifikasi diaktifkan', context, backgroundColor: Colors.black); } else { Toast.show('Notifikasi dinonaktifkan', context, backgroundColor: Colors.black); } }).catchError((err) { print(err); }); } void _refreshEntries() { _sub = EntryService.fetchEntries(categoryId: widget.categoryId) .asStream() .listen((entries) { setState(() { if (entries.isNotEmpty) { _cursor = entries.last.publishedAt; _entries = entries; } _refreshController.refreshCompleted(); }); }); _sub.onError((err) { print(err); _refreshController.refreshFailed(); }); } void _loadMoreEntries() { _sub = EntryService.fetchEntries( categoryId: widget.categoryId, cursor: _cursor) .asStream() .listen((entries) { setState(() { if (entries.isNotEmpty) { _cursor = entries.last.publishedAt; _entries.addAll(entries); _refreshController.loadComplete(); } else { _refreshController.loadNoData(); } }); }); _sub.onError((err) => print(err)); } @override Widget build(BuildContext ctx) { var notificationIcon = Icons.notifications; var notificationIconColor = Colors.white; if (_subscription != null) { notificationIcon = Icons.notifications_active; notificationIconColor = Colors.yellow; } return ScopedModel<AppModel>( model: widget.model, child: Scaffold( appBar: AppBar( title: Text('Berita ${widget.categoryName}'), elevation: 0, actions: [ Padding( padding: EdgeInsets.only(right: 10), child: IconButton( icon: Icon(notificationIcon), color: notificationIconColor, onPressed: _subscribe)) ], ), body: SmartRefresher( controller: _refreshController, enablePullDown: true, enablePullUp: true, onRefresh: () { _refreshEntries(); }, onLoading: () { _loadMoreEntries(); }, child: _buildList(ctx), ))); } Widget _buildList(BuildContext ctx) { final cloudinaryFetchUrl = widget.model.getCloudinaryUrl(); var entries = _entries == null ? [] : _entries .map<Entry>((e) => e.setCloudinaryPicture(cloudinaryFetchUrl)) .toList(); return ListView( padding: EdgeInsets.symmetric(vertical: 10.0), children: entries .asMap() .map( (index, entry) => MapEntry(index, _listItem(ctx, index, entry))) .values .toList()); } Widget _listItem(BuildContext ctx, int index, Entry entry) { return Padding( padding: new EdgeInsets.symmetric(horizontal: 10, vertical: 4), child: index > 0 // the first item use card ? SingleNewsNoCard( key: ValueKey(entry.id), entry: entry, showCategoryName: false) : SingleNewsCard( key: ValueKey(entry.id), entry: entry, showCategoryName: false), ); } }
0
mirrored_repositories/gatrabali-app/lib/view
mirrored_repositories/gatrabali-app/lib/view/widgets/featured_card.dart
import 'package:flutter/material.dart'; import 'package:gatrabali/scoped_models/app.dart'; import 'package:gatrabali/models/entry.dart'; import 'package:gatrabali/view/single_news.dart'; import 'package:gatrabali/view/widgets/cover_image_decoration.dart'; class FeaturedCard extends StatelessWidget { final Entry entry; final int maxLines; FeaturedCard({Key key, this.entry, this.maxLines = 3}) : super(key: key); @override Widget build(BuildContext ctx) { final categories = AppModel.of(ctx).categories; final categoryName = entry.getCategoryName(categories); final subTitle = "$categoryName, ${entry.formattedDate}"; return ListTile( contentPadding: EdgeInsets.all(15), leading: CoverImageDecoration( url: entry.cdnPicture != null ? entry.cdnPicture : entry.picture, width: 70, height: 50, borderRadius: 5.0, ), title: Text( entry.title, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 15, color: Colors.white), maxLines: 2, overflow: TextOverflow.ellipsis, ), subtitle: Padding( padding: EdgeInsets.only(top: 3), child: Text( subTitle, maxLines: 1, style: TextStyle(fontSize: 12, color: Colors.white.withOpacity(0.7)), )), onTap: () { _openDetail(ctx, categoryName); }, ); } // Open detail page void _openDetail(BuildContext ctx, String categoryName) { Navigator.of(ctx).pushNamed(SingleNews.routeName, arguments: SingleNewsArgs(categoryName, entry)); } }
0
mirrored_repositories/gatrabali-app/lib/view
mirrored_repositories/gatrabali-app/lib/view/widgets/related_entries.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:gatrabali/models/entry.dart'; import 'package:gatrabali/repository/entries.dart'; import 'package:gatrabali/view/widgets/single_news_nocard.dart'; import 'package:gatrabali/config.dart'; class RelatedEntries extends StatefulWidget { final String title; final int cursor; final int categoryId; final int feedId; final int limit; RelatedEntries( {this.title, this.cursor, this.categoryId, this.feedId, this.limit = 5}); @override _RelatedEntries createState() => _RelatedEntries(); } class _RelatedEntries extends State<RelatedEntries> { List<Entry> _entries; StreamSubscription _sub; bool _loading = true; bool _isBalebengong = false; @override void initState() { _isBalebengong = BALEBENGONG_FEED_IDS.indexOf(this.widget.feedId) != -1; if (_isBalebengong) { _sub = EntryService.fetchBalebengongEntries( categoryId: this.widget.categoryId, cursor: this.widget.cursor, limit: this.widget.limit) .asStream() .listen((entries) { setState(() { _loading = false; _entries = entries; }); }); } else { _sub = EntryService.fetchEntries( categoryId: this.widget.categoryId, cursor: this.widget.cursor, limit: this.widget.limit) .asStream() .listen((entries) { setState(() { _loading = false; _entries = entries; }); }); } _sub.onError((err) { setState(() { _loading = false; }); print(err); }); super.initState(); } @override void dispose() { if (_sub != null) { _sub.cancel(); } super.dispose(); } @override Widget build(BuildContext context) { return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsets.only(top: 10, left: 25), child: Text(_isBalebengong ? "Artikel Lainnya" : "Berita Lainnya", style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600), textAlign: TextAlign.start)), Padding( padding: EdgeInsets.all(0), child: _loading ? Center(child: CircularProgressIndicator(strokeWidth: 2)) : ListView.builder( padding: EdgeInsets.only(top: 20, right: 10, bottom: 50, left: 10), shrinkWrap: true, physics: ClampingScrollPhysics(), itemCount: _entries.length, itemBuilder: (BuildContext context, int index) { Entry entry = _entries[index]; return SingleNewsNoCard( key: ValueKey(entry.id), entry: entry, maxLines: 2, showCategoryName: false); }), ) ]); } }
0
mirrored_repositories/gatrabali-app/lib/view
mirrored_repositories/gatrabali-app/lib/view/widgets/category_summary_card.dart
import 'package:flutter/material.dart'; import 'package:basic_utils/basic_utils.dart'; import 'package:gatrabali/models/entry.dart'; import 'package:gatrabali/view/widgets/cover_image_decoration.dart'; import 'package:gatrabali/view/single_news.dart'; import 'package:gatrabali/view/category_news.dart'; class CategorySummaryCard extends StatelessWidget { final int categoryId; final String categoryName; final List<Entry> entries; CategorySummaryCard({this.categoryId, this.categoryName, this.entries}); @override Widget build(BuildContext ctx) { final firstEntry = entries.first; final subTitle = StringUtils.capitalize(firstEntry.formattedDate); return Card( clipBehavior: Clip.antiAlias, child: Column( children: [ _header(ctx, firstEntry), ListTile( title: Padding( padding: EdgeInsets.only(top: 7), child: Text(firstEntry.title, style: TextStyle(fontWeight: FontWeight.bold))), subtitle: Padding( padding: new EdgeInsets.only(top: 5), child: Text(subTitle, maxLines: 1)), onTap: () { _openDetail(ctx, firstEntry); }, ), Divider(), _relatedNews(ctx, entries.sublist(1)), _moreNews(ctx) ], ), ); } Widget _header(BuildContext ctx, Entry entry) { var titleWidget = Text(categoryName.toUpperCase(), style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, color: Colors.white)); return Stack( children: [ CoverImageDecoration( url: entry.cdnPicture != null ? entry.cdnPicture : entry.picture, width: null, height: 150, onTap: () { _openDetail(ctx, entry); }), Container( height: 50, width: double.infinity, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomLeft, colors: const [Colors.black87, Colors.transparent])), child: Padding(padding: new EdgeInsets.all(15), child: titleWidget), ) ], ); } Widget _relatedNews(BuildContext ctx, List<Entry> related) { return Column( children: related.map((entry) { return Column( children: [ ListTile( leading: ClipRRect( child: Image.network( entry.cdnPicture != null ? entry.cdnPicture : entry.picture, width: 60), borderRadius: BorderRadius.circular(3.0)), title: Text(entry.title, maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500)), onTap: () { _openDetail(ctx, entry); }, ), Divider(), ], ); }).toList()); } Widget _moreNews(BuildContext ctx) { return GestureDetector( child: Padding( padding: new EdgeInsets.fromLTRB(0, 7, 0, 15), child: Text( "Berita $categoryName lainnya...", style: TextStyle(color: Colors.green, fontWeight: FontWeight.w500), ), ), onTap: () { Navigator.of(ctx).pushNamed(CategoryNews.routeName, arguments: CategoryNewsArgs(categoryId, categoryName)); }, ); } // Open detail page void _openDetail(BuildContext ctx, Entry entry) { Navigator.of(ctx).pushNamed(SingleNews.routeName, arguments: SingleNewsArgs(categoryName, entry)); } }
0
mirrored_repositories/gatrabali-app/lib/view
mirrored_repositories/gatrabali-app/lib/view/widgets/main_cover.dart
import 'package:flutter/material.dart'; import 'package:gatrabali/repository/entries.dart'; import 'package:gatrabali/models/entry.dart'; import 'package:gatrabali/scoped_models/app.dart'; import 'package:gatrabali/view/single_news.dart'; import 'package:gatrabali/view/category_news.dart'; class MainCover extends StatefulWidget { @override _MainCover createState() => _MainCover(); } class _MainCover extends State<MainCover> { Entry _entry; String _status = 'loading'; @override void initState() { EntryService.fetchKriminalEntries(limit: 1).then((entries) { setState(() { _entry = entries.first; _status = 'loaded'; }); }).catchError((err) { print(err); setState(() { _status = 'error'; }); }); super.initState(); } @override Widget build(BuildContext context) { var child = _buildLoading(); if (_status == 'error') { child = _buildError(); } else if (_status == 'loaded') { child = _buildCover(context, _entry); } return Container(height: 250, width: double.infinity, child: child); } Widget _buildError() { return Center( child: Text("Ampura nggih, wenten gangguan :)", style: TextStyle(color: Colors.grey))); } Widget _buildLoading() { return Center(child: CircularProgressIndicator(strokeWidth: 2)); } void _onTitleTap(BuildContext context, String categoryName, Entry entry) { Navigator.of(context).pushNamed(SingleNews.routeName, arguments: SingleNewsArgs(categoryName, entry)); } void _onCategoryTap() { Navigator.of(context).pushNamed(CategoryNews.routeName, arguments: CategoryNewsArgs(11, 'Hukum & Kriminal')); } Widget _buildCover(BuildContext context, Entry entry) { var categories = AppModel.of(context).categories; var categoryName = entry.getCategoryName(categories); return Stack( children: [ Container( decoration: BoxDecoration( image: DecorationImage( image: NetworkImage(entry.picture), fit: BoxFit.cover)), ), Container( height: 250, width: double.infinity, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.bottomLeft, end: Alignment.topLeft, colors: const [Colors.black, Colors.transparent])), child: Padding( padding: new EdgeInsets.only(top: 0, right: 25, bottom: 10, left: 25), child: Column( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.start, children: [ GestureDetector( onTap: () { _onTitleTap(context, categoryName, entry); }, child: Text(entry.title, textAlign: TextAlign.start, style: TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.w600))), SizedBox(height: 5), Text("${entry.formattedDate}".toUpperCase(), textAlign: TextAlign.start, style: TextStyle( color: Colors.white.withOpacity(0.6), fontSize: 12)), Padding( padding: EdgeInsets.only(top: 10, bottom: 5), child: Divider( color: Colors.white.withOpacity(0.5), height: 1.0), ), FlatButton( onPressed: _onCategoryTap, padding: EdgeInsets.all(0), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Icon(Icons.arrow_right, color: Colors.yellow), Text( "Hukum & Kriminal".toUpperCase(), style: TextStyle( color: Colors.yellow, fontWeight: FontWeight.w600), ), ], )) ], )), alignment: Alignment.bottomLeft, ) ], ); } }
0
mirrored_repositories/gatrabali-app/lib/view
mirrored_repositories/gatrabali-app/lib/view/widgets/char_thumbnail.dart
import 'package:flutter/material.dart'; class CharThumbnail extends StatelessWidget { final String char; final double width; final double height; final double fontSize; final Color color; CharThumbnail( {@required this.char, this.color = Colors.green, this.width = 50.0, this.height = 50.0, this.fontSize = 28.0}); @override Widget build(BuildContext ctx) { return Container( color: color, alignment: Alignment.center, width: width, height: height, child: Text(char.toUpperCase(), style: TextStyle( color: Colors.white, fontSize: fontSize, fontWeight: FontWeight.w300)), ); } }
0
mirrored_repositories/gatrabali-app/lib/view
mirrored_repositories/gatrabali-app/lib/view/widgets/reaction_labels.dart
import 'package:flutter/material.dart'; import 'package:gatrabali/models/entry.dart'; class ReactionLabels extends StatelessWidget { final Entry entry; final double imgWidth; ReactionLabels(this.entry, {this.imgWidth = 15}); @override Widget build(BuildContext context) { List<Widget> childs = <Widget>[]; if (entry.reactionHappyCount != null && entry.reactionHappyCount > 0) { childs .add(_wrap(Image.asset("assets/images/happy.png", width: imgWidth))); } if (entry.reactionSurpriseCount != null && entry.reactionSurpriseCount > 0) { childs.add( _wrap(Image.asset("assets/images/surprise.png", width: imgWidth))); } if (entry.reactionSadCount != null && entry.reactionSadCount > 0) { childs.add(_wrap(Image.asset("assets/images/sad.png", width: imgWidth))); } if (entry.reactionAngryCount != null && entry.reactionAngryCount > 0) { childs .add(_wrap(Image.asset("assets/images/angry.png", width: imgWidth))); } if (childs.isNotEmpty) { childs.add(SizedBox(width: 6)); } return Row(children: childs); } Widget _wrap(Widget child) { return Padding(padding: EdgeInsets.only(right: 1), child: child); } }
0
mirrored_repositories/gatrabali-app/lib/view
mirrored_repositories/gatrabali-app/lib/view/widgets/single_news_card.dart
import 'package:flutter/material.dart'; import 'package:basic_utils/basic_utils.dart'; import 'package:gatrabali/scoped_models/app.dart'; import 'package:gatrabali/models/entry.dart'; import 'package:gatrabali/view/widgets/cover_image_decoration.dart'; import 'package:gatrabali/view/widgets/reaction_labels.dart'; import 'package:gatrabali/view/single_news.dart'; class SingleNewsCard extends StatelessWidget { final Entry entry; final bool showCategoryName; final bool showAuthor; SingleNewsCard( {Key key, this.entry, this.showCategoryName, this.showAuthor = false}) : super(key: key); @override Widget build(BuildContext ctx) { final categories = AppModel.of(ctx).categories; final categoryName = entry.getCategoryName(categories); final commentText = (entry.commentCount != null && entry.commentCount > 0) ? " · ${entry.commentCount} komentar" : ""; final subTitle = showCategoryName ? "$categoryName, ${entry.formattedDate}$commentText" : "${StringUtils.capitalize(entry.formattedDate)}$commentText"; return Card( clipBehavior: Clip.antiAlias, child: Column( children: [ _header(ctx, categoryName), ListTile( title: Padding( padding: EdgeInsets.only(top: 7), child: Text( entry.title, style: TextStyle(fontWeight: FontWeight.bold), maxLines: 2, overflow: TextOverflow.ellipsis, )), subtitle: Padding( padding: EdgeInsets.only(top: 5, bottom: 10), child: Row(children: [ Opacity(opacity: 0.8, child: ReactionLabels(entry)), Text(subTitle, maxLines: 1) ])), onTap: () { _openDetail(ctx, categoryName); }, ), ], ), ); } Widget _header(BuildContext ctx, String categoryName) { if (entry.hasPicture) { return Stack( children: [ CoverImageDecoration( url: entry.cdnPicture != null ? entry.cdnPicture : entry.picture, width: null, height: 120.0, onTap: () { _openDetail(ctx, categoryName); }), ], ); } else { return Container( width: double.infinity, height: 120.0, color: Colors.green, ); } } // Open detail page void _openDetail(BuildContext ctx, String categoryName) { Navigator.of(ctx).pushNamed(SingleNews.routeName, arguments: SingleNewsArgs(categoryName, entry, showAuthor: showAuthor)); } }
0
mirrored_repositories/gatrabali-app/lib/view
mirrored_repositories/gatrabali-app/lib/view/widgets/balebengong_entries.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:gatrabali/models/entry.dart'; import 'package:gatrabali/repository/entries.dart'; import 'package:gatrabali/view/widgets/single_news_card.dart'; import 'package:gatrabali/view/widgets/single_news_nocard.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; class BalebengongEntries extends StatefulWidget { final int categoryId; final String name; BalebengongEntries(this.categoryId, this.name); @override _BalebengongEntriesState createState() => _BalebengongEntriesState(); } class _BalebengongEntriesState extends State<BalebengongEntries> with AutomaticKeepAliveClientMixin { @override bool get wantKeepAlive => true; RefreshController _refreshController; StreamSubscription _sub; List<Entry> _entries = <Entry>[]; int _cursor = 0; @override void initState() { _refreshController = RefreshController(initialRefresh: false); _refreshEntries(); super.initState(); } @override void dispose() { if (_sub != null) { _sub.cancel(); } _refreshController.dispose(); super.dispose(); } void _refreshEntries() { _sub = EntryService.fetchBalebengongEntries(categoryId: widget.categoryId) .asStream() .listen((entries) { _refreshController.refreshCompleted(); if (entries.isNotEmpty) { setState(() { _cursor = entries.last.publishedAt; _entries = entries; }); } }); _sub.onError((err) { _refreshController.refreshFailed(); print(err); }); } void _loadEntries() { _sub = EntryService.fetchBalebengongEntries( categoryId: widget.categoryId, cursor: _cursor) .asStream() .listen((entries) { if (entries.isNotEmpty) { _refreshController.loadComplete(); setState(() { _cursor = entries.last.publishedAt; _entries.addAll(entries); }); } else { _refreshController.loadNoData(); } }); _sub.onError((err) { _refreshController.loadNoData(); print(err); }); } Widget _listItem(BuildContext ctx, int index, Entry entry) { return Padding( padding: new EdgeInsets.symmetric(horizontal: 10, vertical: 6), child: index == 0 ? SingleNewsCard( key: ValueKey(entry.id), entry: entry, showCategoryName: widget.categoryId == 0, showAuthor: true) : SingleNewsNoCard( key: ValueKey(entry.id), entry: entry, showCategoryName: widget.categoryId == 0, showAuthor: true)); } @override Widget build(BuildContext context) { super.build(context); return SmartRefresher( controller: _refreshController, enablePullDown: true, enablePullUp: true, onRefresh: () { _refreshEntries(); }, onLoading: () { _loadEntries(); }, child: _buildList(), ); } Widget _buildList() { return ListView.builder( physics: NeverScrollableScrollPhysics(), padding: EdgeInsets.symmetric(vertical: 10), itemCount: _entries.length, itemBuilder: (BuildContext ctx, int index) { return _listItem(ctx, index, _entries[index]); }, ); } }
0
mirrored_repositories/gatrabali-app/lib/view
mirrored_repositories/gatrabali-app/lib/view/widgets/picture_view.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:cached_network_image/cached_network_image.dart'; class PictureView extends StatefulWidget { final String tag; final String url; PictureView({Key key, @required this.tag, @required this.url}) : assert(tag != null), assert(url != null), super(key: key); @override _PictureViewState createState() => _PictureViewState(); } class _PictureViewState extends State<PictureView> { @override initState() { SystemChrome.setEnabledSystemUIOverlays([]); super.initState(); } @override void dispose() { SystemChrome.restoreSystemUIOverlays(); SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, body: GestureDetector( child: Center( child: Hero( tag: widget.tag, child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ CachedNetworkImage( imageUrl: widget.url, placeholder: (context, url) => CircularProgressIndicator(strokeWidth: 2), errorWidget: (context, url, error) => Icon(Icons.error), ), SizedBox(height: 10), Text('Tekan gambar untuk kembali', style: TextStyle(color: Colors.grey, fontSize: 13)) ], ), ), ), onTap: () { Navigator.pop(context); }, ), ); } }
0
mirrored_repositories/gatrabali-app/lib/view
mirrored_repositories/gatrabali-app/lib/view/widgets/reaction_block.dart
import 'package:flutter/material.dart'; import 'package:toast/toast.dart'; import 'package:gatrabali/scoped_models/app.dart'; import 'package:gatrabali/models/entry.dart'; import 'package:gatrabali/models/response.dart'; import 'package:gatrabali/repository/responses.dart'; import 'package:gatrabali/view/profile.dart'; import 'package:gatrabali/view/comments.dart'; class ReactionBlock extends StatefulWidget { final Entry entry; ReactionBlock(this.entry); @override State<StatefulWidget> createState() => _ReactionBlock(); } class _ReactionBlock extends State<ReactionBlock> { Response _reaction; @override void initState() { _loadReaction(); super.initState(); } bool _allowToReact() { return AppModel.of(context).currentUser != null; } void _react(String r) async { if (!_allowToReact()) { var isLogin = await Navigator.of(context) .pushNamed(Profile.routeName, arguments: true); if (isLogin == true) { _loadReaction(); } return; } final user = AppModel.of(context).currentUser; Response reaction; if (_reaction == null) { reaction = Response.create(TYPE_REACTION, widget.entry, user, reaction: r); } else if (_reaction != null && _reaction.reaction != r) { reaction = _reaction; reaction.reaction = r; } if (reaction != null) { setState(() { // to make the reaction UI changes faster. _reaction = reaction; }); try { reaction = await ResponseService.saveUserReaction(reaction); Toast.show('Reaksi berhasil disimpan', context, backgroundColor: Colors.black); setState(() { _reaction = reaction; }); } catch (err) { print(err); } } } void _loadReaction() { if (!_allowToReact()) return; ResponseService.getUserReaction( widget.entry, AppModel.of(context).currentUser.id) .then((resp) { if (resp != null) { setState(() { _reaction = resp; }); } }).catchError(print); } @override Widget build(BuildContext context) { final commentText = (widget.entry.commentCount == null) || (widget.entry.commentCount == 0) ? "Berikan komentar" : "${widget.entry.commentCount} komentar"; return Container( color: Colors.green, margin: EdgeInsets.symmetric(vertical: 15), padding: EdgeInsets.symmetric(vertical: 30, horizontal: 25), child: Column(children: [ Text("Bagaimana reaksi anda?", style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, color: Colors.white)), SizedBox(height: 20), Row(mainAxisAlignment: MainAxisAlignment.center, children: [ _iconButton( "assets/images/happy.png", (_reaction != null && _reaction.reaction == REACTION_HAPPY) ? true : false, () { _react(REACTION_HAPPY); }), _iconButton( "assets/images/surprise.png", (_reaction != null && _reaction.reaction == REACTION_SURPRISE) ? true : false, () { _react(REACTION_SURPRISE); }), _iconButton( "assets/images/sad.png", (_reaction != null && _reaction.reaction == REACTION_SAD) ? true : false, () { _react(REACTION_SAD); }), _iconButton( "assets/images/angry.png", (_reaction != null && _reaction.reaction == REACTION_ANGRY) ? true : false, () { _react(REACTION_ANGRY); }) ]), SizedBox(height: 25), SizedBox( width: double.maxFinite, child: RaisedButton( elevation: 1, padding: EdgeInsets.all(15), onPressed: () { Navigator.of(context).pushNamed(Comments.routeName, arguments: CommentsArgs(this.widget.entry)); }, color: Colors.white, child: Text(commentText, style: TextStyle(fontSize: 15)))) ])); } Widget _iconButton(String image, bool selected, VoidCallback onTap) { return GestureDetector( onTap: onTap, child: Padding( padding: EdgeInsets.symmetric(horizontal: 3), child: CircleAvatar( radius: 30, child: CircleAvatar( radius: 30, backgroundColor: selected ? Colors.white : null, child: Image.asset(image, width: 48)), ))); } }
0
mirrored_repositories/gatrabali-app/lib/view
mirrored_repositories/gatrabali-app/lib/view/widgets/cover_image_decoration.dart
import 'package:flutter/material.dart'; import 'package:cached_network_image/cached_network_image.dart'; class CoverImageDecoration extends StatelessWidget { final String url; final double width; final double height; final double borderRadius; final VoidCallback onTap; CoverImageDecoration( {this.url, this.height, this.width = 0, this.borderRadius = 0, this.onTap}); @override Widget build(BuildContext ctx) { final imgUrl = url == null ? "" : url; return GestureDetector( onTap: onTap, child: Container( width: width, height: height, decoration: BoxDecoration( borderRadius: BorderRadius.circular(borderRadius), color: Colors.grey, image: DecorationImage( image: CachedNetworkImageProvider(imgUrl), fit: BoxFit.cover), ), ), ); } }
0
mirrored_repositories/gatrabali-app/lib/view
mirrored_repositories/gatrabali-app/lib/view/widgets/main_featured.dart
import 'package:flutter/material.dart'; import 'package:gatrabali/repository/entries.dart'; import 'package:gatrabali/models/entry.dart'; import 'package:gatrabali/view/widgets/featured_card.dart'; import 'package:gatrabali/view/category_news.dart'; class MainFeatured extends StatefulWidget { @override _MainFeatured createState() => _MainFeatured(); } class _MainFeatured extends State<MainFeatured> { double _height = 100.0; List<Entry> _entries = []; String _status = 'loading'; @override void initState() { EntryService.fetchBaliUnitedEntries(limit: 3).then((entries) { setState(() { _status = 'loaded'; _entries = entries; }); }).catchError((err) { print(err); setState(() { _status = 'error'; }); }); super.initState(); } @override Widget build(BuildContext context) { var child = _buildLoading(); if (_status == 'error') { child = _buildError(); } else if (_status == 'loaded') { child = _buildEntries(context, _entries); } return Container( height: _height, width: double.infinity, child: Container( color: Colors.green, height: _height, width: double.infinity, child: child)); } Widget _buildError() { return Center( child: Text("Ampura nggih, wenten gangguan :)", style: TextStyle(color: Colors.white))); } Widget _buildLoading() { return Center( child: CircularProgressIndicator( strokeWidth: 2, backgroundColor: Colors.white)); } Widget _buildEntries(BuildContext context, List<Entry> entries) { final sWidth = MediaQuery.of(context).size.width * 0.8; var items = entries.map((e) { return Container( width: sWidth, height: _height, child: FeaturedCard(maxLines: 2, key: ValueKey(e.id), entry: e)); }).toList(); return Container( color: Colors.green, height: _height, width: double.infinity, child: ListView( padding: EdgeInsets.symmetric(horizontal: 10), scrollDirection: Axis.horizontal, children: items + [ Container( width: sWidth, height: 100, child: GestureDetector( onTap: () { Navigator.of(context).pushNamed(CategoryNews.routeName, arguments: CategoryNewsArgs(12, 'Bali United')); }, child: Center( child: Text("Berita Bali United lainnya...", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold))))) ], ), ); } }
0
mirrored_repositories/gatrabali-app/lib/view
mirrored_repositories/gatrabali-app/lib/view/widgets/category_entries.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:gatrabali/models/entry.dart'; import 'package:gatrabali/repository/entries.dart'; import 'package:gatrabali/view/widgets/single_news_card.dart'; import 'package:gatrabali/view/widgets/single_news_nocard.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:gatrabali/scoped_models/app.dart'; class CategoryEntries extends StatefulWidget { final int categoryId; final String name; CategoryEntries(this.categoryId, this.name); @override _CategoryEntriesState createState() => _CategoryEntriesState(); } class _CategoryEntriesState extends State<CategoryEntries> with AutomaticKeepAliveClientMixin { @override bool get wantKeepAlive => true; RefreshController _refreshController; StreamSubscription _sub; List<Entry> _entries = <Entry>[]; int _cursor = 0; @override void initState() { _refreshController = RefreshController(initialRefresh: false); _refreshEntries(); // Listen for auth state changes AppModel.of(context).addListener(() { final model = AppModel.of(context); if (model.currentUser == null) { setState(() { print('no user init'); // _subscription = null; }); } else { print('load subscription init'); // _loadSubscription(); } }); super.initState(); } @override void dispose() { if (_sub != null) { _sub.cancel(); } _refreshController.dispose(); super.dispose(); } void _refreshEntries() { _sub = EntryService.fetchEntries(categoryId: widget.categoryId) .asStream() .listen((entries) { _refreshController.refreshCompleted(); if (entries.isNotEmpty) { setState(() { _cursor = entries.last.publishedAt; _entries = entries; }); } }); _sub.onError((err) { _refreshController.refreshFailed(); print(err); }); } void _loadEntries() { _sub = EntryService.fetchEntries( categoryId: widget.categoryId, cursor: _cursor) .asStream() .listen((entries) { if (entries.isNotEmpty) { _refreshController.loadComplete(); setState(() { _cursor = entries.last.publishedAt; _entries.addAll(entries); }); } else { _refreshController.loadNoData(); } }); _sub.onError((err) { _refreshController.loadNoData(); print(err); }); } Widget _listItem(BuildContext ctx, int index, Entry entry) { return Padding( padding: new EdgeInsets.symmetric(horizontal: 10, vertical: 6), child: index == 0 ? SingleNewsCard( key: ValueKey(entry.id), entry: entry, showCategoryName: false, showAuthor: true) : SingleNewsNoCard( key: ValueKey(entry.id), entry: entry, showCategoryName: false, showAuthor: true)); } @override Widget build(BuildContext context) { super.build(context); return SmartRefresher( controller: _refreshController, enablePullDown: true, enablePullUp: true, onRefresh: () { _refreshEntries(); }, onLoading: () { _loadEntries(); }, child: _buildList(), ); } Widget _buildList() { return ListView.builder( physics: NeverScrollableScrollPhysics(), padding: EdgeInsets.symmetric(vertical: 10), itemCount: _entries.length, itemBuilder: (BuildContext ctx, int index) { return _listItem(ctx, index, _entries[index]); }, ); } }
0
mirrored_repositories/gatrabali-app/lib/view
mirrored_repositories/gatrabali-app/lib/view/widgets/single_news_nocard.dart
import 'package:flutter/material.dart'; import 'package:basic_utils/basic_utils.dart'; import 'package:gatrabali/scoped_models/app.dart'; import 'package:gatrabali/models/entry.dart'; import 'package:gatrabali/view/single_news.dart'; import 'package:gatrabali/view/widgets/cover_image_decoration.dart'; import 'package:gatrabali/view/widgets/reaction_labels.dart'; class SingleNewsNoCard extends StatelessWidget { final Entry entry; final int maxLines; final bool showCategoryName; final bool showAuthor; SingleNewsNoCard( {Key key, this.entry, this.showCategoryName, this.maxLines = 3, this.showAuthor = false}) : super(key: key); @override Widget build(BuildContext ctx) { final categories = AppModel.of(ctx).categories; final categoryName = entry.getCategoryName(categories); final commentText = (entry.commentCount != null && entry.commentCount > 0) ? " · ${entry.commentCount} komentar" : ""; final subTitle = showCategoryName ? "$categoryName, ${entry.formattedDate}$commentText" : "${StringUtils.capitalize(entry.formattedDate)}$commentText"; return ListTile( leading: CoverImageDecoration( url: entry.cdnPicture != null ? entry.cdnPicture : entry.picture, width: 70, height: 50, borderRadius: 5.0, ), title: Text( entry.title, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), maxLines: maxLines, overflow: TextOverflow.ellipsis, ), subtitle: Padding( padding: EdgeInsets.only(top: 3), child: Row(children: [ Opacity(opacity: 0.8, child: ReactionLabels(entry, imgWidth: 13)), Text( subTitle, maxLines: 1, style: TextStyle(fontSize: 12), ) ])), onTap: () { _openDetail(ctx, categoryName); }, ); } // Open detail page void _openDetail(BuildContext ctx, String categoryName) { Navigator.of(ctx).pushNamed(SingleNews.routeName, arguments: SingleNewsArgs(categoryName, entry, showAuthor: showAuthor)); } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/models/subscription.dart
import 'package:cloud_firestore/cloud_firestore.dart'; class Subscription { String userId; int subscribedAt; Subscription({this.userId, this.subscribedAt}); Map<String, dynamic> toMap() { return { 'user_id': userId, 'subscribed_at': subscribedAt, }; } static Subscription fromDocument(DocumentSnapshot doc) { final data = doc.data; var sub = Subscription(); sub.userId = data['user_id']; sub.subscribedAt = data['subscribed_at']; return sub; } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/models/entry.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:timeago/timeago.dart' as timeago; class Entry { int id; int categoryId; int feedId; int publishedAt; int reactionHappyCount; int reactionSurpriseCount; int reactionSadCount; int reactionAngryCount; int commentCount; String title; String url; String content; String picture; String cdnPicture; String author; Entry() { timeago.setLocaleMessages('id', timeago.IdMessages()); } bool get hasPicture => picture != null; String get formattedDate => timeago .format(DateTime.fromMillisecondsSinceEpoch(publishedAt), locale: 'id'); String formattedDateSimple() { var date = DateTime.fromMillisecondsSinceEpoch(publishedAt); return "${date.day.toString().padLeft(2, '0')}-${date.month.toString().padLeft(2, '0')}-${date.year}"; } String getCategoryName(Map<int, String> categories) { var title = categories[categoryId]; return title; } Entry setCloudinaryPicture(String cloudinaryFetchUrl) { if (this.picture == null || this.picture == "" || cloudinaryFetchUrl == "") { return this; } this.cdnPicture = "$cloudinaryFetchUrl${this.picture}"; return this; } static Entry fromJson(dynamic json) { var e = new Entry(); e.id = json['id']; e.title = json['title']; e.url = json['url']; e.content = json['content']; e.publishedAt = json["published_at"]; e.feedId = json['feed_id']; e.categoryId = json['category_id']; e.reactionHappyCount = json['reaction_happy_count']; e.reactionSurpriseCount = json['reaction_surprise_count']; e.reactionSadCount = json['reaction_sad_count']; e.reactionAngryCount = json['reaction_angry_count']; e.commentCount = json['comment_count']; if (json['author'] != null) e.author = json['author']; if (json['enclosures'] != null) e.picture = json['enclosures'][0]['url']; return e; } static Entry fromBookmarkEntry(BookmarkEntry bookmark) { var e = new Entry(); e.id = bookmark.entryId; e.title = bookmark.title; e.publishedAt = bookmark.publishedAt; e.feedId = bookmark.feedId; e.categoryId = bookmark.categoryId; e.picture = bookmark.picture; return e; } static List<Entry> emptyList() { return List<Entry>(); } } class BookmarkEntry { int entryId; int feedId; int categoryId; int publishedAt; DateTime bookmarkedAt; String title; String url; String picture; String cdnPicture; bool get hasPicture => picture != null; String get formattedDate => timeago .format(DateTime.fromMillisecondsSinceEpoch(publishedAt), locale: 'id'); String getCategoryName(Map<int, String> categories) { var title = categories[categoryId]; return title; } BookmarkEntry setCloudinaryPicture(String cloudinaryFetchUrl) { if (this.picture == null || this.picture == "" || cloudinaryFetchUrl == "") { return this; } this.cdnPicture = "$cloudinaryFetchUrl${this.picture}"; return this; } static BookmarkEntry fromDocument(DocumentSnapshot doc) { final data = doc.data; var be = new BookmarkEntry(); be.entryId = data['entry_id']; be.title = data['title']; be.picture = data['picture']; be.feedId = data['feed_id']; be.categoryId = data['category_id']; be.publishedAt = data["published_at"]; if (data["bookmarked_at"] == null) { be.bookmarkedAt = DateTime.now(); } else { // Ios and Android will not receive same type. // Ios receive the timestamps as TimeStamp and Android receive it as DateTime already. be.bookmarkedAt = data["bookmarked_at"] is DateTime ? data["bookmarked_at"] : data["bookmarked_at"].toDate(); } return be; } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/models/category.dart
import 'package:gatrabali/models/entry.dart'; class CategorySummary { int id; String title; List<dynamic> entries; static CategorySummary fromJson(dynamic json) { var cs = CategorySummary(); cs.id = json['id']; cs.title = json['title']; cs.entries = (json['entries'] as List<dynamic>).map((e) => Entry.fromJson(e)).toList(); return cs; } static List<CategorySummary> emptyList() { return List<CategorySummary>(); } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/models/response.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:timeago/timeago.dart' as timeago; import 'package:gatrabali/models/entry.dart'; import 'package:gatrabali/models/user.dart'; // Types of response const TYPE_COMMENT = "COMMENT"; const TYPE_REACTION = "REACTION"; // Types of reaction const REACTION_HAPPY = "HAPPY"; const REACTION_SURPRISE = "SURPRISE"; const REACTION_SAD = "SAD"; const REACTION_ANGRY = "ANGRY"; class Response { String id; String type; String parentId; String threadId; String reaction; String comment; int replyCount; int createdAt; int updatedAt; int entryId; int entryCategoryId; // for backward compatibility with backend int entryFeedId; // for backward compatibility with backend Entry entry; String userId; User user; List<Response> replies = List<Response>(); String get formattedDate => timeago .format(DateTime.fromMillisecondsSinceEpoch(createdAt), locale: 'id'); static Response create(String type, Entry entry, User user, {String reaction, String comment, String parentId, String threadId}) { final now = DateTime.now().millisecondsSinceEpoch; var r = Response(); r.type = type; r.userId = user.id; r.user = user; r.entryId = entry.id; r.entryCategoryId = entry.categoryId; r.entryFeedId = entry.feedId; r.entry = entry; r.reaction = reaction; r.comment = comment; r.parentId = parentId; r.threadId = threadId; r.createdAt = now; r.updatedAt = now; return r; } static Response fromDocument(DocumentSnapshot doc) { final data = doc.data; var reaction = new Response(); reaction.id = doc.documentID; reaction.type = data["type"]; reaction.parentId = data["parent_id"]; reaction.threadId = data["thread_id"]; reaction.reaction = data["reaction"]; reaction.comment = data["comment"]; reaction.replyCount = data["reply_count"]; reaction.createdAt = data["created_at"]; reaction.updatedAt = data["updated_at"]; reaction.userId = data["user_id"]; reaction.user = User( id: data["user"]["id"], name: data["user"]["name"], avatar: data["user"]["avatar"], ); reaction.entryId = data["entry_id"]; reaction.entryCategoryId = data["entry_category_id"]; reaction.entryFeedId = data["entry_feed_id"]; final entry = Entry(); entry.id = data["entry"]["id"]; entry.title = data["entry"]["title"]; entry.url = data["entry"]["url"]; entry.feedId = data["entry"]["feed_id"]; entry.categoryId = data["entry"]["category_id"]; entry.picture = data["entry"]["picture"]; entry.publishedAt = data["entry"]["published_at"]; reaction.entry = entry; return reaction; } // for simplicity we duplicate some of the user and entry data. Map<String, dynamic> toJson() => { "type": type, "parent_id": parentId, "thread_id": threadId, "reaction": reaction, "comment": comment, "reply_count": replyCount, "created_at": createdAt, "updated_at": updatedAt, "user_id": userId, "user": { "id": user.id, "name": user.name, "avatar": user.avatar, }, "entry_id": entryId, "entry_category_id": entryCategoryId, "entry_feed_id": entryFeedId, "entry": { "id": entry.id, "title": entry.title, "url": entry.url, "feed_id": entry.feedId, "category_id": entry.categoryId, "picture": entry.picture, "published_at": entry.publishedAt, } }; static List<Response> emptyList() { return List<Response>(); } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/models/feed.dart
class Feed { int id; String title; String feedUrl; String siteUrl; String iconData; static Feed fromJson(dynamic json) { var feed = new Feed(); feed.id = json['id']; feed.title = json['title']; // feed.feedUrl = json['feed_url']; // feed.siteUrl = json['site_url']; // if (json['icon_data'] != null) { // feed.iconData = json['icon_data']; // } return feed; } static List<Feed> emptyList() { return List<Feed>(); } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/models/user.dart
class User { String id; String provider; String name; String avatar; String fcmToken; bool isAnonymous; User({this.id, this.provider, this.name, this.avatar, this.isAnonymous}); @override String toString() { return '{id: $id, name: $name, provider: $provider, avatar: $avatar, isAnonymous: $isAnonymous, fcmToken: $fcmToken}'; } }
0
mirrored_repositories/gatrabali-app/lib
mirrored_repositories/gatrabali-app/lib/scoped_models/app.dart
import 'package:flutter/material.dart'; import 'package:scoped_model/scoped_model.dart'; import 'package:firebase_remote_config/firebase_remote_config.dart'; import 'package:gatrabali/models/feed.dart'; import 'package:gatrabali/models/user.dart'; class AppModel extends Model { List<Feed> feeds = <Feed>[]; User currentUser; RemoteConfig remoteConfig; Map<int, String> categories = { 11: 'Hukum & Kriminal', 12: 'Bali United', 2: 'Badung', 3: 'Bangli', 4: 'Buleleng', 5: 'Denpasar', 6: 'Gianyar', 7: 'Jembrana', 8: 'Karangasem', 9: 'Klungkung', 10: 'Tabanan', 13: 'Opini', 14: 'Teknologi', 15: 'Lingkungan', 16: 'Sosok', 17: 'Budaya', 18: 'Sosial', 19: 'Agenda', 20: 'Travel' }; void setFeeds(List<Feed> feeds) { this.feeds = feeds; notifyListeners(); } void setUser(User user) { this.currentUser = user; print("currentUser SET: $user"); notifyListeners(); } void setRemoteConfig(RemoteConfig config) { this.remoteConfig = config; print( "remoteConfig SET:cloudinary_fetch_url=${config.getString('cloudinary_fetch_url')}"); notifyListeners(); } String getCloudinaryUrl() { if (remoteConfig == null) return ''; return remoteConfig.getString('cloudinary_fetch_url'); } static AppModel of(BuildContext ctx) => ScopedModel.of<AppModel>(ctx, rebuildOnChange: false); }
0
mirrored_repositories/gatrabali-app
mirrored_repositories/gatrabali-app/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 that Flutter provides. 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('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. // await tester.pumpWidget(MyApp()); // // Verify that our counter starts at 0. // expect(find.text('0'), findsOneWidget); // expect(find.text('1'), findsNothing); // // Tap the '+' icon and trigger a frame. // await tester.tap(find.byIcon(Icons.add)); // await tester.pump(); // // Verify that our counter has incremented. // expect(find.text('0'), findsNothing); // expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/flutter21/i_am_poor
mirrored_repositories/flutter21/i_am_poor/lib/main.dart
import 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( backgroundColor: Colors.blue[900], appBar: AppBar( title: Text('I am poor'), ), body: Center( child: Image( image: NetworkImage( 'https://images.pexels.com/photos/46801/coal-briquette-black-46801.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500'), ), ), ), ), ); }
0
mirrored_repositories/flutter21/i_am_poor
mirrored_repositories/flutter21/i_am_poor/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 that Flutter provides. 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/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:i_am_poor/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. // await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/flutter21/xylophone-flutter
mirrored_repositories/flutter21/xylophone-flutter/lib/main.dart
import 'package:flutter/material.dart'; import 'package:audioplayers/audio_cache.dart'; void main() => runApp(XylophoneApp()); class XylophoneApp extends StatelessWidget { void playSound(int soundNumber) { final player = AudioCache(); player.play('note$soundNumber.wav'); } Expanded buildKey({Color color, int soundNumber}) { return Expanded( child: FlatButton( color: color, onPressed: () { playSound(soundNumber); }, ), ); } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( backgroundColor: Colors.black, body: SafeArea( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ buildKey(color: Colors.red, soundNumber: 1), buildKey(color: Colors.orange, soundNumber: 2), buildKey(color: Colors.yellow, soundNumber: 3), buildKey(color: Colors.green, soundNumber: 4), buildKey(color: Colors.teal, soundNumber: 5), buildKey(color: Colors.blue, soundNumber: 6), buildKey(color: Colors.purple, soundNumber: 7), ], ), ), ), ); } }
0
mirrored_repositories/flutter21/i_am_rich
mirrored_repositories/flutter21/i_am_rich/lib/main.dart
import 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( backgroundColor: Colors.blueGrey, appBar: AppBar( title: Text('I am rich'), backgroundColor: Colors.blueGrey[900], ), body: Center( child: Image( image: AssetImage('images/diamond.png'), ), ), ), ), ); }
0
mirrored_repositories/flutter21/i_am_rich
mirrored_repositories/flutter21/i_am_rich/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 that Flutter provides. 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/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:i_am_rich/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. // await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/flutter21/magic-8-ball-flutter
mirrored_repositories/flutter21/magic-8-ball-flutter/lib/main.dart
import 'package:flutter/material.dart'; import 'dart:math'; void main() => runApp( MaterialApp( home: BallPage(), ), ); class Ball extends StatefulWidget { @override _BallState createState() => _BallState(); } class _BallState extends State<Ball> { @override int ballNumber = 1; Widget build(BuildContext context) { return Container( child: Center( child: FlatButton( child: Image.asset('images/ball$ballNumber.png'), onPressed: () { setState(() { ballNumber = Random().nextInt(5) + 1; }); }, ), ), ); } } class BallPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.blue, appBar: AppBar( title: Text('Ask me anything'), backgroundColor: Colors.blue[800], ), body: Ball(), ); } }
0
mirrored_repositories/flutter21/quizzler-flutter
mirrored_repositories/flutter21/quizzler-flutter/lib/question.dart
class Question { String questionText; bool questionAnswer; Question(String q, bool a) { questionText = q; questionAnswer = a; } }
0
mirrored_repositories/flutter21/quizzler-flutter
mirrored_repositories/flutter21/quizzler-flutter/lib/quiz_brain.dart
import 'question.dart'; class QuizBrain { int _questionNumber = 0; List<Question> _questionBank = [ Question('Some cats are actually allergic to humans', true), Question('You can lead a cow down stairs but not up stairs.', false), Question('Approximately one quarter of human bones are in the feet.', true), Question('A slug\'s blood is green.', true), Question('Buzz Aldrin\'s mother\'s maiden name was \"Moon\".', true), Question('It is illegal to pee in the Ocean in Portugal.', true), Question( 'No piece of square dry paper can be folded in half more than 7 times.', false), Question( 'In London, UK, if you happen to die in the House of Parliament, you are technically entitled to a state funeral, because the building is considered too sacred a place.', true), Question( 'The loudest sound produced by any animal is 188 decibels. That animal is the African Elephant.', false), Question( 'The total surface area of two human lungs is approximately 70 square metres.', true), Question('Google was originally called \"Backrub\".', true), Question( 'Chocolate affects a dog\'s heart and nervous system; a few ounces are enough to kill a small dog.', true), Question( 'In West Virginia, USA, if you accidentally hit an animal with your car, you are free to take it home to eat.', true), ]; void getNextQuestion() { if (_questionNumber < _questionBank.length - 1) { _questionNumber++; } } String getQuestionText() { return _questionBank[_questionNumber].questionText; } bool getCorrectAnswer() { return _questionBank[_questionNumber].questionAnswer; } bool isFinished() { if (_questionNumber >= _questionBank.length - 1) { //TODO: Step 3 Part B - Use a print statement to check that isFinished is returning true when you are indeed at the end of the quiz and when a restart should happen. print('Now returning true'); return true; } else { return false; } } //TODO: Step 4 part B - Create a reset() method here that sets the questionNumber back to 0. void reset() { _questionNumber = 0; } }
0
mirrored_repositories/flutter21/quizzler-flutter
mirrored_repositories/flutter21/quizzler-flutter/lib/main.dart
import 'package:flutter/material.dart'; import 'quiz_brain.dart'; import 'package:rflutter_alert/rflutter_alert.dart'; QuizBrain quizBrain = QuizBrain(); void main() => runApp(Quizzler()); class Quizzler extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( backgroundColor: Colors.grey.shade900, body: SafeArea( child: Padding( padding: EdgeInsets.symmetric(horizontal: 10.0), child: QuizPage(), ), ), ), ); } } class QuizPage extends StatefulWidget { @override _QuizPageState createState() => _QuizPageState(); } class _QuizPageState extends State<QuizPage> { List<Widget> scoreKeeper = []; void checkAnswer(bool userPickedAnswer) { bool correctAnswer = quizBrain.getCorrectAnswer(); setState(() { if (quizBrain.isFinished() == true) { //TODO Step 4 Part A - show an alert using rFlutter_alert, //This is the code for the basic alert from the docs for rFlutter Alert: //Alert(context: context, title: "RFLUTTER", desc: "Flutter is awesome.").show(); //Modified for our purposes: Alert( context: context, title: 'Finished!', desc: 'You\'ve reached the end of the quiz.', ).show(); //TODO Step 4 Part C - reset the questionNumber, quizBrain.reset(); //TODO Step 4 Part D - empty out the scoreKeeper. scoreKeeper = []; } else { if (correctAnswer == userPickedAnswer) { scoreKeeper.add(Icon(Icons.check, color: Colors.green)); } else { scoreKeeper.add(Icon(Icons.close, color: Colors.red)); } } quizBrain.getNextQuestion(); }); } @override Widget build(BuildContext context) { return Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ Expanded( flex: 5, child: Padding( padding: EdgeInsets.all(10.0), child: Center( child: Text( quizBrain.getQuestionText(), textAlign: TextAlign.center, style: TextStyle( fontSize: 25.0, color: Colors.white, ), ), ), ), ), Expanded( child: Padding( padding: EdgeInsets.all(15.0), child: FlatButton( textColor: Colors.white, color: Colors.green, child: Text( 'True', style: TextStyle( color: Colors.white, fontSize: 20.0, ), ), onPressed: () { //The user picked true. checkAnswer(true); setState(() { quizBrain.getNextQuestion(); }); }, ), ), ), Expanded( child: Padding( padding: EdgeInsets.all(15.0), child: FlatButton( color: Colors.red, child: Text( 'False', style: TextStyle( fontSize: 20.0, color: Colors.white, ), ), onPressed: () { //The user picked false. checkAnswer(false); }, ), ), ), Row( children: scoreKeeper, ) ], ); } } /* question1: 'You can lead a cow down stairs but not up stairs.', false, question2: 'Approximately one quarter of human bones are in the feet.', true, question3: 'A slug\'s blood is green.', true, */
0
mirrored_repositories/flutter21/testing_app
mirrored_repositories/flutter21/testing_app/lib/main.dart
import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( // This is the theme of your application. // // Try running your application with "flutter run". You'll see the // application has a blue toolbar. Then, without quitting the app, try // changing the primarySwatch below to Colors.green and then invoke // "hot reload" (press "r" in the console where you ran "flutter run", // or simply save your changes to "hot reload" in a Flutter IDE). // Notice that the counter didn't reset back to zero; the application // is not restarted. primarySwatch: Colors.blue, ), home: MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key? key, required this.title}) : super(key: key); // This widget is the home page of your application. It is stateful, meaning // that it has a State object (defined below) that contains fields that affect // how it looks. // This class is the configuration for the state. It holds the values (in this // case the title) provided by the parent (in this case the App widget) and // used by the build method of the State. Fields in a Widget subclass are // always marked "final". final String title; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { int _counter = 0; void _incrementCounter() { setState(() { // This call to setState tells the Flutter framework that something has // changed in this State, which causes it to rerun the build method below // so that the display can reflect the updated values. If we changed // _counter without calling setState(), then the build method would not be // called again, and so nothing would appear to happen. _counter++; }); } @override Widget build(BuildContext context) { // This method is rerun every time setState is called, for instance as done // by the _incrementCounter method above. // // The Flutter framework has been optimized to make rerunning build methods // fast, so that you can just rebuild anything that needs updating rather // than having to individually change instances of widgets. return Scaffold( appBar: AppBar( // Here we take the value from the MyHomePage object that was created by // the App.build method, and use it to set our appbar title. title: Text(widget.title), ), body: Center( // Center is a layout widget. It takes a single child and positions it // in the middle of the parent. child: Column( // Column is also a layout widget. It takes a list of children and // arranges them vertically. By default, it sizes itself to fit its // children horizontally, and tries to be as tall as its parent. // // Invoke "debug painting" (press "p" in the console, choose the // "Toggle Debug Paint" action from the Flutter Inspector in Android // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) // to see the wireframe for each widget. // // Column has various properties to control how it sizes itself and // how it positions its children. Here we use mainAxisAlignment to // center the children vertically; the main axis here is the vertical // axis because Columns are vertical (the cross axis would be // horizontal). mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( 'You have pushed the button this many times:', ), Text( '$_counter', style: Theme.of(context).textTheme.headline4, ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: Icon(Icons.add), ), // This trailing comma makes auto-formatting nicer for build methods. ); } }
0
mirrored_repositories/flutter21/testing_app
mirrored_repositories/flutter21/testing_app/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 that Flutter provides. 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/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:testing_app/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/flutter21/dicee-flutter
mirrored_repositories/flutter21/dicee-flutter/lib/main.dart
import 'dart:math'; import 'package:flutter/material.dart'; void main() { return runApp( MaterialApp( home: Scaffold( backgroundColor: Colors.red, appBar: AppBar( title: Text('Dicee'), backgroundColor: Colors.red, ), body: DicePage(), ), ), ); } class DicePage extends StatefulWidget { @override _DicePageState createState() => _DicePageState(); } class _DicePageState extends State<DicePage> { int leftDiceNumber = 1; int rightDiceNumber = 1; void changeDiceFace() { setState(() { leftDiceNumber = Random().nextInt(6) + 1; rightDiceNumber = Random().nextInt(6) + 1; }); } @override Widget build(BuildContext context) { return Center( child: Row( children: [ Expanded( child: FlatButton( onPressed: () { changeDiceFace(); }, child: Image.asset('images/dice$leftDiceNumber.png'), ), ), Expanded( child: FlatButton( onPressed: () { changeDiceFace(); }, child: Image.asset('images/dice$rightDiceNumber.png'), ), ), ], ), ); } }
0