-
Notifications
You must be signed in to change notification settings - Fork 0
Modify app #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
romanoprid
wants to merge
7
commits into
main
Choose a base branch
from
modify_app
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Modify app #2
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b300451
My Implementation: tip for user was added
romanoprid a9efc84
Individual Task: New functions were added
romanoprid 93a36d2
Update README.md
romanoprid 5e3226e
Delete main.dart
romanoprid 4846ade
Add files via upload
romanoprid 07e97e4
Class was renamed to more self-explanatory
romanoprid c969ac3
Merge branch 'modify_app' of https://github.com/romanoprid/FlutterCou…
romanoprid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,3 @@ | ||
| # FlutterCourse | ||
| It is the repsitory from mobile development subject | ||
|
|
||
| Here you can see screens from Part 1: | ||
|
|
||
| - Hello World | ||
|
|
||
|  | ||
|
|
||
| - Randomly generated word | ||
|
|
||
|  | ||
|
|
||
| - Randomly generated word with different size | ||
|
|
||
|  | ||
|
|
||
| And code result video you can see above | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,7 +43,7 @@ android { | |
|
|
||
| defaultConfig { | ||
| // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | ||
| applicationId "com.example.hometask_flutter_v2" | ||
| applicationId "com.example.hometask_v_3" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. version (v2, v3) shouldn't be a part of your app id (as your version will change regularly, while your package ID won't ever change after app is published) |
||
| minSdkVersion 16 | ||
| targetSdkVersion 30 | ||
| versionCode flutterVersionCode.toInteger() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
android/app/src/main/kotlin/com/example/hometask_v_3/MainActivity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package com.example.hometask_v_3 | ||
|
|
||
| import io.flutter.embedding.android.FlutterActivity | ||
|
|
||
| class MainActivity: FlutterActivity() { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <module type="JAVA_MODULE" version="4"> | ||
| <component name="FacetManager"> | ||
| <facet type="android" name="Android"> | ||
| <configuration> | ||
| <option name="ALLOW_USER_CONFIGURATION" value="false" /> | ||
| <option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/gen" /> | ||
| <option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/gen" /> | ||
| <option name="MANIFEST_FILE_RELATIVE_PATH" value="/app/src/main/AndroidManifest.xml" /> | ||
| <option name="RES_FOLDER_RELATIVE_PATH" value="/app/src/main/res" /> | ||
| <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/app/src/main/assets" /> | ||
| <option name="LIBS_FOLDER_RELATIVE_PATH" value="/app/src/main/libs" /> | ||
| <option name="PROGUARD_LOGS_FOLDER_RELATIVE_PATH" value="/app/src/main/proguard_logs" /> | ||
| </configuration> | ||
| </facet> | ||
| </component> | ||
| <component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
| <exclude-output /> | ||
| <content url="file://$MODULE_DIR$"> | ||
| <sourceFolder url="file://$MODULE_DIR$/app/src/main/java" isTestSource="false" /> | ||
| <sourceFolder url="file://$MODULE_DIR$/app/src/main/kotlin" isTestSource="false" /> | ||
| <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" /> | ||
| </content> | ||
| <orderEntry type="jdk" jdkName="Android API 29 Platform" jdkType="Android SDK" /> | ||
| <orderEntry type="sourceFolder" forTests="false" /> | ||
| <orderEntry type="library" name="Flutter for Android" level="project" /> | ||
| <orderEntry type="library" name="KotlinJavaRuntime" level="project" /> | ||
| </component> | ||
| </module> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| final appTheme = ThemeData( | ||
| primarySwatch: Colors.red, | ||
| textTheme: const TextTheme( | ||
| headline1: TextStyle( | ||
| fontFamily: 'Corben', | ||
| fontWeight: FontWeight.w700, | ||
| fontSize: 24, | ||
| color: Colors.black, | ||
| ), | ||
| ), | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,114 +1,39 @@ | ||
| import 'package:english_words/english_words.dart'; | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| void main() => runApp(MyApp()); | ||
|
|
||
| class MyApp extends StatelessWidget { | ||
| @override | ||
| Widget build(BuildContext context) { | ||
| return MaterialApp( | ||
| title: 'Startup Name Generator', | ||
| theme: ThemeData( | ||
| primaryColor: Colors.white, | ||
| ), | ||
| home: RandomWords(), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class _RandomWordsState extends State<RandomWords> { | ||
| final _suggestions = <WordPair>[]; | ||
| final _saved = <WordPair>{}; | ||
| final _biggerFont = const TextStyle(fontSize: 18.0); | ||
| Widget _buildSuggestions() { | ||
| return ListView.builder( | ||
| padding: const EdgeInsets.all(16.0), | ||
| itemBuilder: (context, i) { | ||
| if (i.isOdd) return const Divider(); | ||
|
|
||
| final index = i ~/ 2; | ||
| if (index >= _suggestions.length) { | ||
| _suggestions.addAll(generateWordPairs().take(10)); | ||
| } | ||
| return _buildRow(_suggestions[index]); | ||
| }); | ||
| } | ||
|
|
||
| Widget _buildRow(WordPair pair) { | ||
| final alreadySaved = _saved.contains(pair); | ||
| return ListTile( | ||
| title: Text( | ||
| pair.asPascalCase, | ||
| style: _biggerFont, | ||
| ), | ||
| trailing: Icon( | ||
| alreadySaved ? Icons.favorite : Icons.favorite_border, | ||
| color: alreadySaved ? Colors.red : null, | ||
| semanticLabel: alreadySaved ? 'Remove from saved' : 'Save', | ||
| ), | ||
| onTap: () { | ||
| setState(() { | ||
| if (alreadySaved) { | ||
| _saved.remove(pair); | ||
| } else { | ||
| _saved.add(pair); | ||
| } | ||
| }); | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Scaffold( | ||
| appBar: AppBar( | ||
| title: const Text('Startup Name Generator'), | ||
| actions: [ | ||
| IconButton( | ||
| icon: const Icon(Icons.list), | ||
| onPressed: _pushSaved, | ||
| tooltip: 'Saved Suggestions', | ||
| ), | ||
| ], | ||
| ), | ||
| body: _buildSuggestions(), | ||
| ); | ||
| } | ||
|
|
||
| void _pushSaved() { | ||
| Navigator.of(context).push( | ||
| MaterialPageRoute<void>( | ||
| builder: (context) { | ||
| final tiles = _saved.map( | ||
| (pair) { | ||
| return ListTile( | ||
| title: Text( | ||
| pair.asPascalCase, | ||
| style: _biggerFont, | ||
| ), | ||
| ); | ||
| }, | ||
| ); | ||
| final divided = tiles.isNotEmpty | ||
| ? ListTile.divideTiles( | ||
| context: context, | ||
| tiles: tiles, | ||
| ).toList() | ||
| : <Widget>[]; | ||
|
|
||
| return Scaffold( | ||
| appBar: AppBar( | ||
| title: const Text('Saved Suggestions'), | ||
| ), | ||
| body: ListView(children: divided), | ||
| ); | ||
| }, | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class RandomWords extends StatefulWidget { | ||
| @override | ||
| State<RandomWords> createState() => _RandomWordsState(); | ||
| } | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:provider/provider.dart'; | ||
| import 'package:hometask_v_3/common/theme.dart'; | ||
| import 'package:hometask_v_3/models/cart_methods.dart'; | ||
| import 'package:hometask_v_3/models/catalog_list.dart'; | ||
| import 'package:hometask_v_3/screens/cart.dart'; | ||
| import 'package:hometask_v_3/screens/catalog.dart'; | ||
|
|
||
| void main() { | ||
| runApp(MyApp()); | ||
| } | ||
|
|
||
| class MyApp extends StatelessWidget { | ||
| @override | ||
| Widget build(BuildContext context) { | ||
| return MultiProvider( | ||
| providers: [ | ||
| Provider(create: (context) => CatalogModel()), | ||
| ChangeNotifierProxyProvider<CatalogModel, CartModel>( | ||
| create: (context) => CartModel(), | ||
| update: (context, catalog, cart) { | ||
| if (cart == null) throw ArgumentError.notNull('cart'); | ||
| cart.catalog = catalog; | ||
| return cart; | ||
| }, | ||
| ), | ||
| ], | ||
| child: MaterialApp( | ||
| title: 'Provider Demo', | ||
| theme: appTheme, | ||
| initialRoute: '/', | ||
| routes: { | ||
| '/': (context) => MyCatalog(), | ||
| '/cart': (context) => MyCart(), | ||
| }, | ||
| ), | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import 'package:flutter/foundation.dart'; | ||
| import 'package:hometask_v_3/models/catalog_list.dart'; | ||
|
|
||
| class CartModel extends ChangeNotifier { | ||
| late CatalogModel _catalog; | ||
|
|
||
| final List<int> _itemIds = []; | ||
|
|
||
| CatalogModel get catalog => _catalog; | ||
|
|
||
| set catalog(CatalogModel newCatalog) { | ||
| _catalog = newCatalog; | ||
| notifyListeners(); | ||
| } | ||
|
|
||
| List<Item> get items => _itemIds.map((id) => _catalog.getById(id)).toList(); | ||
|
|
||
| int get totalPrice => | ||
| items.fold(0, (total, current) => total + current.price); | ||
|
|
||
| void add(Item item) { | ||
| _itemIds.add(item.id); | ||
| notifyListeners(); | ||
| } | ||
|
|
||
| void remove(Item item) { | ||
| _itemIds.remove(item.id); | ||
| notifyListeners(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| class CatalogModel { | ||
| static List<String> itemNames = [ | ||
| 'Code Smell', | ||
| 'Control Flow', | ||
| 'Interpreter', | ||
| 'Recursion', | ||
| 'Sprint', | ||
| 'Heisenbug', | ||
| 'Spaghetti', | ||
| 'Hydra Code', | ||
| 'Off-By-One', | ||
| 'Scope', | ||
| 'Callback', | ||
| 'Closure', | ||
| 'Automata', | ||
| 'Bit Shift', | ||
| 'Currying', | ||
| ]; | ||
|
|
||
| Item getById(int id) => Item(id, itemNames[id % itemNames.length]); | ||
|
|
||
| Item getByPosition(int position) { | ||
| return getById(position); | ||
| } | ||
| } | ||
|
|
||
| @immutable | ||
| class Item { | ||
| final int id; | ||
| final String name; | ||
| final Color color; | ||
| final int price = 42; | ||
|
|
||
| Item(this.id, this.name) | ||
| : color = Colors.primaries[id % Colors.primaries.length]; | ||
|
|
||
| @override | ||
| int get hashCode => id; | ||
|
|
||
| @override | ||
| bool operator ==(Object other) => other is Item && other.id == id; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "repository"