Compare commits

...

No commits in common. "lab_2" and "master" have entirely different histories.

15 changed files with 62 additions and 164 deletions

View File

@ -1,4 +1,4 @@
# identity
# mobilefl
A new Flutter project.

View File

@ -6,7 +6,7 @@ plugins {
}
android {
namespace = "com.example.identity"
namespace = "com.example.mobilefl"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
@ -21,7 +21,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.identity"
applicationId = "com.example.mobilefl"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion

View File

@ -1,6 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="identity"
android:label="mobilefl"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity

View File

@ -1,4 +1,4 @@
package com.example.identity
package com.example.mobilefl
import io.flutter.embedding.android.FlutterActivity

View File

@ -1,43 +0,0 @@
import 'dart:async';
enum CharacterType {
Survivor,
Hunter,
}
abstract class Character {
String name;
CharacterType type;
int level;
Character({required this.name, required this.type, this.level = 1});
Character.empty() : name = '', type = CharacterType.Survivor, level = 1;
String getInfo() {
return "Имя: $name, Тип: ${type.toString().split('.').last}, Уровень: $level";
}
Future<void> levelUp() async {
await Future.delayed(const Duration(seconds: 1));
level++;
print("$name поднял(а) уровень до $level.");
}
}
class Survivor extends Character {
Survivor({required String name}) : super(name: name, type: CharacterType.Survivor);
void useAbility() {
print("$name использовал(а) свою способность.");
}
}
class Hunter extends Character {
Hunter({required String name}) : super(name: name, type: CharacterType.Hunter);
void useAbility() {
print("$name использовал(а) свою способность.");
}
}

View File

@ -1,9 +0,0 @@
import 'character.dart';
import 'default_character.dart';
extension CharacterListExtension<T extends Character> on List<T> {
T findByName(String name) {
return firstWhere((character) => character.name == name,
orElse: () => DefaultCharacter() as T);
}
}

View File

@ -1,4 +0,0 @@
import 'character.dart';
class DefaultCharacter extends Character {
DefaultCharacter() : super.empty();
}

View File

@ -1,116 +1,70 @@
import 'package:flutter/material.dart';
import 'character.dart';
import 'character_list_extension.dart';
import 'default_character.dart';
void main() => runApp(MyApp());
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
@override
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Identity V Characters',
home: MyHomePage(title: 'Персонажи Identity V'),
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
useMaterial3: true,
),
home: const MyHomePage(title: 'Камчарова Ксения Алексеевна'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
const MyHomePage({super.key, required this.title});
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final List<Character> _characters = [];
final _nameController = TextEditingController();
CharacterType _selectedType = CharacterType.Survivor; // По умолчанию - выживший
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Column(
children: [
Padding(
padding: const EdgeInsets.all(16.0),
child: TextField(
controller: _nameController,
decoration: InputDecoration(
labelText: 'Имя персонажа',
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
),
Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
Radio<CharacterType>(
value: CharacterType.Survivor,
groupValue: _selectedType,
onChanged: (value) {
setState(() {
_selectedType = value!;
});
},
),
Text('Выживший'),
Radio<CharacterType>(
value: CharacterType.Hunter,
groupValue: _selectedType,
onChanged: (value) {
setState(() {
_selectedType = value!;
});
},
),
Text('Охотник'),
],
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
),
ElevatedButton(
onPressed: () {
final name = _nameController.text.trim();
if (name.isNotEmpty) {
setState(() {
_characters.add(
_selectedType == CharacterType.Survivor
? Survivor(name: name)
: Hunter(name: name),
);
_nameController.clear();
});
}
},
child: Text('Добавить персонажа'),
),
Expanded(
child: ListView.builder(
itemCount: _characters.length,
itemBuilder: (context, index) {
final character = _characters[index];
return ListTile(
title: Text(character.name),
subtitle: Text(character.getInfo()),
trailing: IconButton(
icon: Icon(Icons.delete),
onPressed: () {
setState(() {
_characters.removeAt(index);
});
},
),
);
},
),
),
],
],
),
),
);
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), );
}
}
}

View File

@ -1,4 +1,4 @@
name: identity
name: mobilefl
description: "A new Flutter project."
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.

View File

@ -8,12 +8,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:identity/main.dart';
import 'package:mobilefl/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);

View File

@ -23,13 +23,13 @@
<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="identity">
<meta name="apple-mobile-web-app-title" content="mobilefl">
<link rel="apple-touch-icon" href="icons/Icon-192.png">
<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png"/>
<title>identity</title>
<title>mobilefl</title>
<link rel="manifest" href="manifest.json">
</head>
<body>

View File

@ -1,6 +1,6 @@
{
"name": "identity",
"short_name": "identity",
"name": "mobilefl",
"short_name": "mobilefl",
"start_url": ".",
"display": "standalone",
"background_color": "#0175C2",

View File

@ -1,10 +1,10 @@
# Project-level configuration.
cmake_minimum_required(VERSION 3.14)
project(identity LANGUAGES CXX)
project(mobilefl LANGUAGES CXX)
# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
set(BINARY_NAME "identity")
set(BINARY_NAME "mobilefl")
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.

View File

@ -90,12 +90,12 @@ BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "com.example" "\0"
VALUE "FileDescription", "identity" "\0"
VALUE "FileDescription", "mobilefl" "\0"
VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "identity" "\0"
VALUE "InternalName", "mobilefl" "\0"
VALUE "LegalCopyright", "Copyright (C) 2024 com.example. All rights reserved." "\0"
VALUE "OriginalFilename", "identity.exe" "\0"
VALUE "ProductName", "identity" "\0"
VALUE "OriginalFilename", "mobilefl.exe" "\0"
VALUE "ProductName", "mobilefl" "\0"
VALUE "ProductVersion", VERSION_AS_STRING "\0"
END
END

View File

@ -27,7 +27,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
FlutterWindow window(project);
Win32Window::Point origin(10, 10);
Win32Window::Size size(1280, 720);
if (!window.Create(L"identity", origin, size)) {
if (!window.Create(L"mobilefl", origin, size)) {
return EXIT_FAILURE;
}
window.SetQuitOnClose(true);