| 1 | import 'dart:convert'; |
| 2 | import 'package:cake_wallet/src/widgets/alert_background.dart'; |
| 3 | import 'package:cake_wallet/src/widgets/alert_close_button.dart'; |
| 4 | import 'package:cake_wallet/wallet_type_utils.dart'; |
| 5 | import 'package:flutter/material.dart'; |
| 6 | import 'package:flutter/services.dart'; |
| 7 | |
| 8 | class ReleaseNotesScreen extends StatelessWidget { |
| 9 | const ReleaseNotesScreen({ |
| 10 | required this.title, |
| 11 | }); |
| 12 | |
| 13 | final String title; |
| 14 | |
| 15 | Future<List<String>> _loadStrings() async { |
| 16 | String notesContent = await rootBundle.loadString( |
| 17 | isMoneroOnly ? 'assets/text/Monerocom_Release_Notes.txt' : 'assets/text/Release_Notes.txt'); |
| 18 | return LineSplitter().convert(notesContent); |
| 19 | } |
| 20 | |
| 21 | @override |
| 22 | Widget build(BuildContext context) { |
| 23 | return Stack( |
| 24 | alignment: Alignment.center, |
| 25 | children: [ |
| 26 | AlertBackground( |
| 27 | child: AlertDialog( |
| 28 | insetPadding: EdgeInsets.only(left: 16, right: 16, bottom: 48), |
| 29 | elevation: 0.0, |
| 30 | contentPadding: EdgeInsets.zero, |
| 31 | shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(30))), |
| 32 | content: Container( |
| 33 | decoration: BoxDecoration( |
| 34 | borderRadius: BorderRadius.circular(30.0), |
| 35 | gradient: LinearGradient(colors: [ |
| 36 | Theme.of(context).colorScheme.surface, |
| 37 | Theme.of(context).colorScheme.surfaceContainer, |
| 38 | ], begin: Alignment.topLeft, end: Alignment.bottomRight)), |
| 39 | child: Padding( |
| 40 | padding: const EdgeInsets.symmetric(horizontal: 24.0), |
| 41 | child: Stack( |
| 42 | children: [ |
| 43 | SingleChildScrollView( |
| 44 | child: Padding( |
| 45 | padding: const EdgeInsets.only(top: 16.0), |
| 46 | child: Container( |
| 47 | alignment: Alignment.bottomCenter, |
| 48 | child: DefaultTextStyle( |
| 49 | style: Theme.of(context).textTheme.bodyMedium!.copyWith( |
| 50 | decoration: TextDecoration.none, |
| 51 | fontSize: 24.0, |
| 52 | fontWeight: FontWeight.bold, |
| 53 | color: Theme.of(context).colorScheme.onSurface, |
| 54 | ), |
| 55 | child: Text(title), |
| 56 | ), |
| 57 | ), |
| 58 | ), |
| 59 | ), |
| 60 | SingleChildScrollView( |
| 61 | child: Padding( |
| 62 | padding: EdgeInsets.only(top: 48, bottom: 16), |
| 63 | child: Container( |
| 64 | width: double.maxFinite, |
| 65 | child: Column( |
| 66 | children: <Widget>[ |
| 67 | ConstrainedBox( |
| 68 | constraints: BoxConstraints( |
| 69 | maxHeight: MediaQuery.of(context).size.height * 0.7, |
| 70 | ), |
| 71 | child: _getNotesWidget(), |
| 72 | ) |
| 73 | ], |
| 74 | ), |
| 75 | ), |
| 76 | ), |
| 77 | ), |
| 78 | ], |
| 79 | ), |
| 80 | ), |
| 81 | ), |
| 82 | ), |
| 83 | ), |
| 84 | AlertCloseButton( |
| 85 | bottom: 30, |
| 86 | ) |
| 87 | ], |
| 88 | ); |
| 89 | } |
| 90 | |
| 91 | Widget _getNotesWidget() { |
| 92 | return FutureBuilder<List<String>>( |
| 93 | future: _loadStrings(), |
| 94 | builder: (BuildContext context, AsyncSnapshot<List<String>> snapshot) { |
| 95 | if (snapshot.hasData) { |
| 96 | return ListView.builder( |
| 97 | shrinkWrap: true, |
| 98 | itemCount: snapshot.data!.length, |
| 99 | itemBuilder: (BuildContext context, int index) { |
| 100 | return _getNoteItemWidget(snapshot.data![index], context); |
| 101 | }, |
| 102 | ); |
| 103 | } else if (snapshot.hasError) { |
| 104 | return Text('Error: ${snapshot.error}'); |
| 105 | } else { |
| 106 | return Center(child: CircularProgressIndicator()); |
| 107 | } |
| 108 | }, |
| 109 | ); |
| 110 | } |
| 111 | |
| 112 | Widget _getNoteItemWidget(String myString, BuildContext context) { |
| 113 | return Column( |
| 114 | children: [ |
| 115 | DefaultTextStyle( |
| 116 | style: Theme.of(context).textTheme.bodyMedium!.copyWith( |
| 117 | decoration: TextDecoration.none, |
| 118 | fontSize: 16.0, |
| 119 | color: Theme.of(context).colorScheme.onSurface, |
| 120 | ), |
| 121 | child: Row( |
| 122 | crossAxisAlignment: CrossAxisAlignment.start, |
| 123 | children: [ |
| 124 | Padding( |
| 125 | padding: const EdgeInsets.only(right: 8.0), |
| 126 | child: Text('•'), |
| 127 | ), |
| 128 | Expanded( |
| 129 | child: Text(myString), |
| 130 | ), |
| 131 | ], |
| 132 | )), |
| 133 | SizedBox( |
| 134 | height: 16.0, |
| 135 | ) |
| 136 | ], |
| 137 | ); |
| 138 | } |
| 139 | } |